Repository navigation
Conversation
…s table (ITL-1801) Building a SpiralDBTableSource opened its table, read its schema, then opened the dataset's schema table and read its rows, one round trip after another. The schema table does not depend on the table's open, so the build now reads it on a worker thread made for the build and joined before the constructor returns (SpiralDBConnector.schema_rows_meanwhile). Its rows are asked for where the sequential read asked for them, so every error (class, message, notes) is the one raised before: when both fail, the table's error wins. A name refused without a call starts nothing. SchemaTable.row is removed: its one caller now takes the rows it is given. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reached
This review includes 6 billable files and costs up to $1.50.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 20 minutes for your next included review. View limit details
|
|
@coderabbitai review Posted by a Claude Code agent on behalf of @eywalker. |
Action not completed
|
|
@coderabbitai review Posted by a Claude Code agent on behalf of @eywalker. |
Action not completed
|
|
Closing this PR without merging. The first source's build stays sequential, as on Why the overlap cannot be kept:
The independent review also found two problems that closing this PR resolves along with the rest:
The work is kept open on the tracker issue. It can be revisited if spiral-sdk documents that a client is safe to use from several threads, or adds an async API. The branch is kept. Posted by a Claude Code agent on behalf of @eywalker. |
Fixes ITL-1801
Related: ITL-1774, ITL-1768
What
The first
SpiralDBTableSourcein a process made its build round trips one after another: open the table, read its schema, then open the dataset's schema table, read its schema, plan its scan and read its rows. ITL-1457 keeps the schema-table rows per process, so a second source is fast; the first one paid the whole chain.The schema-table read does not depend on the table's open. The build now starts it on a worker thread first (
SpiralDBConnector.schema_rows_meanwhile) and hands the pending rows toSpiralDBTable.arrow_schema, which waits for them where the sequential code read them.schema()of the table). A schema-table error is raised by the call that asks for the rows, with the same class, message, notes andTableSchemaError.table. When both fail, the table's error is raised, as the sequential order did. A read nobody asks for is waited for and dropped.KeyboardInterrupt. A fork after the build sees no thread. A name thatlookup_tablerefuses without any call (empty, qualified, or the schema table's own) starts nothing, so it still makes no SDK call.try, beforeclose()runs on failure.SchemaTable.rowis removed; its one caller now takes the rows it is given.Proof
Live timings. Read-only, as the agent workload, on a keyed SpiralDB table of about 63k rows, reading 10 rows (
limit=10). Each sample is a fresh interpreter, imports outside the timer. 9 interleaved rounds of SDK / main / branch; medians.keyed_table,schema(), scan)26efe35aa)The build is about 12% faster (median −0.20 s). Phase timing of the branch build shows why it stops there. The schema-table chain (open,
schema(), scan plan, rows: four dependent round trips, about 0.8 s) now runs beside the table's open andschema()(about 0.45 s), and it is the critical path. Two measurements back this:schema()gains nothing. The scan plan fetches the schema anyway, which matches the ITL-1457 measurement.The target of about 1.5x is not quite reached for this case. What is left is listed under What is left below.
Live differential, main against this branch. Run twice on main as a control. Digests are identical for:
as_table(all_info=True),iter_data,async_iter_data;load_only=True.The function output's own source-info token holds a random result id. It is excluded from every digest, on main too.
Live refusals are identical: a missing table, an empty name, a qualified name and a missing project give the same class, message and notes.
Golden:
generate_golden_hashes.py --checkpasses (no golden file changed).Tests (
tests/test_core/sources/test_spiraldb_first_build.py, fake SDK):table). Both failing gives the table-open error, and a failed tableschema()beats the schema-table error;Every SpiralDB test file passes (3,668 passed). ruff, ruff format and basedpyright are clean, with no new error.
The run-start check (measured, report only, not changed here)
Measured on main, warm, against a warm SDK read of 10 rows on a kept handle.
check_for_new_datacosts about 4.3x that read: 3 round trips, namely the lookup, the new handle'sschema()and the schema-table open. The read itself is 0.9x.schema()per check) this would bring a warm check plus read from about 5.3x to about 2.7x. Adding the scan overlap would bring it to about 1.7x. This variant does not change when a refusal is seen, since everything is still inside the check. It is not done here, to stay out of perf(spiraldb): reuse the pinned snapshot's schema when a check finds the same version (ITL-1791) #684's lines.What is left
🤖 Generated with Claude Code