Skip to content

allow stack to grow dynamically - #48

Merged
yuvalif merged 2 commits into
lancedb:mainfrom
yuvalif:add-coroutine-example
Jun 18, 2026
Merged

yuvalif merged 2 commits into
lancedb:mainfrom
yuvalif:add-coroutine-example

Conversation

@yuvalif

@yuvalif yuvalif commented May 19, 2026

Copy link
Copy Markdown
Collaborator
  • this should demonstrate how to call lancedb code from a boost asio coutoutine
  • no async-io is implemented at this point
  • it shows the necessary stack size needed for the datafusion sql interperter code

@yuvalif
yuvalif force-pushed the add-coroutine-example branch from 7047a5b to 3fd6bd7 Compare May 20, 2026 07:03
@yuvalif
yuvalif force-pushed the add-coroutine-example branch from 3fd6bd7 to b5be4f0 Compare June 8, 2026 15:41
@yuvalif yuvalif changed the title adding a boost asio coroutine example allow stack to grow dynamically Jun 8, 2026
@yuvalif
yuvalif force-pushed the add-coroutine-example branch from b5be4f0 to 0cfea9b Compare June 8, 2026 15:46
@yuvalif
yuvalif requested a review from Copilot June 8, 2026 15:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR demonstrates calling LanceDB C API from a Boost.Asio spawn coroutine, while also addressing coroutine stack limitations by allowing certain Rust FFI entrypoints to grow the stack dynamically.

Changes:

  • Wrap lancedb_table_merge_insert and lancedb_table_delete execution in stacker::maybe_grow to avoid stack overflows when called from small-stack coroutine contexts.
  • Add a new C++ example (examples/asio_coroutine.cpp) showing upsert/delete/query flow structured as Asio spawn coroutines.
  • Update CMake and CI to build the new example and install Boost coroutine/context dependencies; add the stacker Rust dependency.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/table.rs Adds dynamic stack growth around high-stack operations (merge_insert, delete) in Rust FFI.
examples/asio_coroutine.cpp New example demonstrating Boost.Asio coroutine structure around LanceDB operations.
CMakeLists.txt Builds and links the new Boost.Asio coroutine example.
Cargo.toml Adds stacker dependency to enable dynamic stack growth.
Cargo.lock Lockfile updates reflecting the new dependency graph (including stacker).
.github/workflows/ci.yml Installs Boost dependencies for example builds; disables examples for Windows cross-compile job.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread examples/asio_coroutine.cpp Resolved
Comment thread examples/asio_coroutine.cpp Resolved
@yuvalif
yuvalif force-pushed the add-coroutine-example branch 3 times, most recently from 60e4cc0 to da360ad Compare June 9, 2026 09:48
@yuvalif
yuvalif requested a review from Copilot June 9, 2026 11:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.

Comment thread src/connection.rs Resolved
Comment thread tests/test_table.cpp Resolved
Comment thread valgrind.supp Resolved
Comment thread include/lancedb.h Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 6 comments.

Comment thread tests/test_table.cpp Resolved
Comment thread tests/test_table.cpp Resolved
Comment thread src/connection.rs Resolved
Comment thread include/lancedb.h Resolved
Comment thread examples/asio_coroutine.cpp Resolved
Comment thread examples/asio_coroutine.cpp Resolved
@yuvalif
yuvalif force-pushed the add-coroutine-example branch from ead91d6 to 59f77fe Compare June 18, 2026 16:47
yuvalif added 2 commits June 18, 2026 17:19
* this should demonstrate how to call lancedb code from a boost asio
  coutoutine
* no async-io is implemented at this point
* it shows the necessary stack size needed for the different operations

Signed-off-by: Yuval Lifshitz <[email protected]>
this is to allow for deep call stacks that happening
when the query planner is needed. and the invoking code has a limited
stack size (e.g. when using boost asio coroutines).

example of deep call (63 frames) stack backtrace in upsert:
C++                  --- frames 63-61
tokio                --- frames 60-50
lancedb merge logic  --- frames 49-45
lance execution      --- frames 44-28
df physical planning --- frames 27-18
lance scanner        --- frames 17-10
SessionState clone   --- frames 9-0

backtrace:
https://gist.github.com/yuvalif/7b3c78bd56765a03163f17377c20544b

this also allow using the same increased size stack in multiple calls.
e.g. when the same coroutine with limited stack size calls multiple
apsi, this will avoid allocating and freeing the increased stack
multiple times.

also, fixes to memory handling in the example file

Signed-off-by: Yuval Lifshitz <[email protected]>
@yuvalif
yuvalif force-pushed the add-coroutine-example branch from 59f77fe to aa68879 Compare June 18, 2026 17:19
@yuvalif
yuvalif merged commit 36bb519 into lancedb:main Jun 18, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants