Repository navigation
3.x.x: summarize the recovery evidence in parallel, byte-identical to the serial summarizer (cutover window) - #728
Merged
Conversation
… the serial summarizer The summarizer parsed every row in one process at about 29 MB/s, about 45 minutes for the 65.9M-share export, and its migrated-side run sits on the cutover's critical path. #721 parallelised only the database export. Worker processes now parse and canonicalize newline-aligned byte ranges of the export, and the summarizing process applies every check to their results in file order: the rows of kinds only hashed and counted arrive as runs of canonical bytes, share runs with their sequence bounds and accepted sum, and every other row whole. The checks themselves are one state machine that the serial path (--jobs 1) and the parallel path share, so the summary, its notes and every refusal are the serial ones byte for byte. A range a worker cannot read as a text-mode read does (invalid UTF-8, a read error) sends the rest of the file through the serial reader from the start, and a refusal next to an invalid byte is summarized serially from scratch, so decoding errors are the serial ones too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lit a growing line, and keep tracebacks serial From the high-effort code review: - A host that can't create the process pool or fork a worker (no POSIX semaphores, out of processes or memory) now summarizes serially from the lines already checked, instead of failing a valid export. - The last range is open, read to the end of the file by its worker, so a line still being written is never split between two ranges. - The decode window for a refusal next to an invalid byte comes from the interpreter's TextIOWrapper chunk size, kept to at least 1 MiB, rather than a copy of CPython's 8 KiB. - The default job count follows the process's CPU affinity. - The serial summarizer and the serial continuation share one call into summarize(), so even an uncaught error's traceback is the serial one. - Runs accumulate into one bytearray; the test harness's summarize() delegates to summarize_with(); --jobs refuses with the parallel export's wording. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
RobertClarke
added a commit
that referenced
this pull request
Oct 8, 2026
Set VERSION and [workspace.package].version to 3.0.0-rc.5: rc.4 plus #737's fixes in #742 (fatal-state clear accepts a tip that only grew, takes --timeout-seconds, and runs the integrity report under its own statement timeout) and #744 (migration 026: the report computes each set once); the deferred share-hash backfill in #743 and #746 (migrate --defer-share-hashes, then the throttled backfill-share-hashes after go-live); #745 (migrate --offline-indexes, which composes with --defer-share-hashes); the cutover tooling merged after rc.4's tag (#728, #732, #736, #740); and #747, a test-only fix for #724. Both Cargo.lock files move only their workspace-member entries. doc/release-notes-3.0.0-rc.5.md, dated 2026-10-08, covers: - the changes, with the report's estimated 57 to 29 s since 026, the migrate --defer-share-hashes command measured on the pair at 5 min 06 s (539d6c9, before #745), backfill-share-hashes' throttle, record of 2 and safe rerun, the evidence scripts' changes, and the offline index builds' estimated gain; - upgrading: migrate is needed again (a binary-only upgrade refuses "missing migration(s) 26", and this export refuses a database without 026), the cutover's migrate step with both flags, and finishing the backfill after go-live under #738's snapshot rule, with self-check only at low share rates. Rolling back to rc.4 at fence 2 goes only by finishing the backfill first or from the pre-migrate backup or physical copy, and each rc.4 refusal is quoted where it applies: a start meets the cursor first and says to run migrate, which rc.4's migrate refuses. The rules still in force: #737's statement timeout for rc.4's tools, 026 or not, #738's snapshot rule, and fatal-state clear --timeout-seconds, whose bound ends before the commit; - the same evidence set as rc.4's, with each PR's merge SHA, the pair's serving evidence carried, and the rehearsal's full measurements left to the cutover's go/no-go record; - the known issues: rc.4's, minus #737's F1, F2, F4 and F5, plus #737's open part, #738 (its fix planned for rc.6), #739, #741, #731 and #734, with #582 closed and #712 and #724 updated. docs/prism-rust-migration.md now says how earlier candidates refuse a database at fence 2: a start with the backfill's own refusal, whose advice to run migrate holds only for this release, and their migrate, or a start with PRISM_POSTGRES_INIT_SCHEMA=1, with the fence. The development-line notes name 3.0.0-rc.5, and they and the 3.0.0 notes link all five candidates' notes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
The recovery-evidence summarizer parsed every row of the export in one process, at about 29 MB/s on the 65.9M-share restore. That export is about 80 GB, so the summary took about 45 minutes. The migrated side's summary sits on the cutover's critical path. #721 made the database export parallel, but the summary stayed single-threaded.
This PR parses in parallel and keeps the output byte for byte what it was.
How it works
One state machine, shared by both paths. The summary's checks now live in
_Summary: share order, the carry chains and head, candidate counts, integrity and completion ordering, and the final integrity checks.summarize(lines), which the serial path (--jobs 1) and the existing tests call, feeds it line by line exactly as before.Workers parse ranges.
--jobs Nworker processes (default: the CPU count, at most 8) each read a newline-aligned byte range of the file themselves. Each one decodes it as UTF-8 and splits it into lines as a text-mode read does (universal newlines), then parses and canonicalizes the rows with the samejson.loads/json.dumpscalls the serial path uses. What it returns, in order:acceptedflag is a bool or int. Any other share row comes back as a record, with only the fields the checks read.The parent replays in file order. It runs every check against those results:
hashes[kind].update(run)is the serial path's per-row update, and a share run's first sequence is checked against the last one seen. So the first refusal in file order is the serial path's first refusal, with the same message.Reading differences fall back to the serial reader. A range a worker cannot read exactly as text mode does, through invalid UTF-8 or a read error, is the case where the serial reader's 8 KB decoding blocks decide which error comes first. From that range on, the file is read by the serial reader from its start. Lines the workers' ranges already checked are read but not checked again, so even the
UnicodeDecodeErrormessage, with its block-relative position, is the serial one.Other guards.
sys.modulesentry, whose_parse_rangethe forked workers could not find by name.summarize(), so even an uncaught error's traceback (aRecursionErroron absurdly nested JSON) has the serial frames. Python 3.14 reports the C stack used in that message, which varies with argv length even between two serial runs, so the test masks that one number.--jobsfollows the process's CPU affinity.Proof
tests/test_prism_recovery_evidence_jobs.py(15 tests) runs the CLI with--jobs 1and with--jobs 2..4at chunk sizes of 1 byte (a range boundary after every line), 37 bytes, 300 bytes and 1 MiB. It compares the exit code, stdout and stderr exactly for:kindorrow, a JSON string record, an unhashable kind, an unknown kind, records after completion (malformed and valid), a missing completion marker, a duplicate integrity report, and accounting rows after the integrity report;It also checks in-process:
RecursionErrorprints the serial traceback.The gated recovery harness (
migration_rollback::the_parallel_evidence_export_prints_the_serial_export_byte_for_byte) now also summarizes the fixture export with--jobs 1,--jobs 3 --chunk-bytes 1and--jobs 2 --chunk-bytes 4096. It requires identical exit codes, stdout and stderr, on a 2.x source and on its migrated three-partition ledger.Speed
On a 3.25 GB export of 4M production-shaped share rows plus their header rows, on this build host (a shared 16-core Ryzen 9 9955HX):
--jobscmp)The parent's own work is hashing the canonical bytes and replaying the checks. It stays well below the workers' parsing, so 8 jobs gives about 6.5×. At the restore's 29 MB/s serial rate, that's the 45-minute summary in about 7 minutes. Peak memory is about 230 MB per process at 8 jobs.
Review
The high-effort review raised nine findings; eight are fixed in the second commit.
--jobson a quota-limited host, as the runbook says.Scope
This is tooling only: the summarizer script, its tests, the gated harness's comparison, and the runbook paragraphs in
docs/prism-ledger-ops.mdanddocs/prism-rust-migration.md. There's no server code. It lands after rc.4's tag, as a pinned tooling commit, as #721 did with rc.2.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.