Repository navigation
Hold the plan in the bridge instead of replanning every read - #2
Merged
Merged
Conversation
mlake_plan now takes the column selection with the filter, plans once, and returns a handle to the file scan tasks plus the schema, specs and name mapping a read needs. mlake_plan_read reads one task from it through iceberg.mojo's read_data_file; reads only look at the plan, so DataFusion's threads share one. Rust owns the handle as a Plan and frees it on drop. The bridge used to keep nothing between calls, on the grounds that Mojo could not hold an object with a destructor on the heap. Mojo 1.1 can (unsafe_alloc + unsafe_write). Without that, every read reopened the metadata and replanned the manifests to find its own ticket again, about 3 ms per read. taxibench, 1 thread: 0.63-1.34x iceberg-datafusion (was 0.78-1.62x); 10 threads: 0.16-0.46x (was 0.19-0.47x). All 16 answers agree. About 2.5 ms per task remains, inside read_data_file; the README records what it is not. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KxW5zazz1MvVNCxeZzQBRL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #1. That head-to-head found the Mojo scan paying about 5 ms per ticket, because the bridge kept nothing between calls and every read re-planned the table to find its own byte range.
What changed
mlake_plan(dir, columns, filter, split)plans once and returns a handle. It holds the file scan tasks (data file and range, delete files, residual) and the schema, column ids, specs and name mapping a read needs.mlake_plan_read(plan, i)reads taskiwith iceberg.mojo's publicread_data_file, so iceberg.mojo itself doesn't change. A read only looks at the plan, so DataFusion's threads read one plan concurrently.Planowns the handle (Send + Sync, freed on drop), andMlakeExecholds anArc<Plan>.mlake_read_split,mlake_plan_ticketand the string tickets are removed. "Tickets" is renamed "tasks" throughout, including theEXPLAINline.unsafe_allocplusunsafe_write, so the docstring now explains the handle instead.Results (taxibench, M4, both legs re-run)
All 16 answers agree.
sum(trip_distance)probeEvery query that reads the whole table got 160–220 ms faster single-threaded. The Mojo scan now wins 5 of 8 queries on one thread, up from 4.
Still open
About 2.5 ms per task remains, and it's inside
read_data_file. Calling it directly on the 87 tasks takes 433 ms, against 275 ms for the same rows read as 24 whole files. What I ruled out:That leaves a per-call cost somewhere in iceberg.mojo or parquet.mojo. The README says this.
Testing
pixi run test: 4 unit tests and 6 oracle tests pass.cargo clippy --all-targetsis clean.cargo fmtandmojo formatapplied.pixi run benchre-run on both legs.🤖 Generated with Claude Code
https://claude.ai/code/session_01KxW5zazz1MvVNCxeZzQBRL