Repository navigation
perf: apply a per-table hook's rows at stdout EOF, before its exit is reaped - #1565
Merged
Merged
Conversation
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.
Fixes #1562
Root cause
On a watched change, a per-table
on-filecommand's rows were applied only afterwait()reaped the child.catcloses stdout beforeexit_group, so its exit teardown (about 21us) sat on the critical path between the last row and the event.Change
command::drain_then_reapdrains stdout in whole-line blocks, callson_eofonce stdout closes, and only then reaps the child.refresh_tablestages the rows at EOF inside adirsql_unitSQLite savepoint (foreign_key::stage), while the child is still exiting. It keeps them (RELEASE) on a zero exit and discards them (ROLLBACK TO) on a nonzero exit or failure. The hook error event outranks everything else, as before.dirsql server:catproduces oneupdateevent and the new row; a command that prints rows then exits 3 produces oneerrorevent and leaves the old row.Measurements
apply_file_eventsper change,cathook (median of 3000 iterations, 5 interleaved runs)watch_speed_testpasses (1.1x bar), 40 interleaved roundswatch_speed_testmedian ratio, second batch of 25 roundsThe host load average was about 15 on 32 cores. The rounds ran interleaved (main, then branch), with the two release CLIs on PATH.
Changelog / Migrations
packages/rust/changelog.d/(2026-11-02-stage-per-table-rows-at-eof.md)packages/rust/migrations.d/(every subsection but Summary_None._)E2E Verification
cargo test -p dirsql --features cli)packages/python/e2e-attestations/<branch>.jsonreceipt writtenpackages/ts/e2e-attestations/<branch>.jsonreceipt writtentesting-conventions e2e attest 'uv run python -m pytest tests/e2e/{on_file_query,query_contract,declared_table_name,fanout,use_case_dossier,use_case_join,use_case_notebook,use_case_transcripts,watch_speed}_test.py -q'inpackages/python(aftermaturin develop --release);just e2e-attest-ts