Repository navigation
Conversation
Admission found the keys whose stored outputs an input's range covers by paging every output membership of the derivation, archived ones included, and reading each live output's payload, because the range an output covers was recorded only there. One admission cost a pass over the derivation's whole history: about 3,800 pages for state.intervals on the deployed store. A derivation now declares what its outputs cover, once, and the store keeps that range for every live output of a declared type in derivation.output_ranges: written by the batch that makes the output a member of a key, deleted when it is archived. The lookup reads a range index over ended outputs and an index of open outputs one key at a time. An upgrade step fills the table from the stored live outputs. A replaced reading is counted under its source from its replacement's live row instead of a lookup of its own on the events. A bench case records what the lookup reads at three sizes of stored outputs. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UuFixsXwismFLxbfWcuXHU
Owner
Author
|
@codex review |
Codex Review Summary: ✅ CompletedThis 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. |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This branch has not been deployed
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.
Admission now finds the stored outputs an input's range touches through an index over the range each live output covers. It no longer pages every output membership of the derivation and reads each output's payload. The lookup reads the ended outputs that overlap and one row per key that has an open output, whatever the derivation has stored.
What was wrong
The range an output covers was recorded only in its payload. For every admission batch that carried an input with an affected range, the writer walked all memberships of the derivation in pages of 256, archived ones included, and read the payload of every live one. On the deployed store
state.intervalshas 976,228 memberships, 89,917 of them live: about 3,800 pages per affected batch. On 2026-11-26, in 240 one-second samples of the writer, seven had a transaction older than 5 s and 39 of the 114 in-transaction samples were in the paged membership read.What changed
Keyed::OUTPUT_RANGESnames, per output type, the payload fields for the start, the end, an open flag and a fence.AffectedRangecarries only the output type and the range the input asks about. The five declarations are the ones every input repeated before (state.intervals,work.episodes,activity.days,activity.sessions,analysis.products).key_matchhad no user left after unit runs got their own derivation and is removed with its key paging.derivation.output_rangesholds one row per key and live output of a declared type: start, and end (the fence when the payload has no end; null when there is neither or the output is declared open). The batch of keys that makes an output a member writes the row from the staged payload; an output stored earlier that joins another key keeps the range stored with it.archive_atdeletes the output's rows in the transaction that archives it. Times are read withcore.payload_time, so an unreadable time is absent instead of an error, and an output with no readable start has no row.sinex_store::output_ranges::affected_keys) joins the ranges of one admission where they share an instant, then runs two statements. Ended outputs come from a GiST index on(derivation, event_type, [start, end]), with the stored bounds compared afterwards, inclusive on both sides as before. Open outputs come from a B-tree on(derivation, event_type, key, started_at), read one key at a time for the key's earliest open output.output_rangescreates the table, fills it from the live outputs of the five derivations and builds the indexes.archive_atcounted a replaced reading under the source it read fromcore.events, one lookup per reading, because the live row already named the replacement. The replacement is a reading of the same record, so its row gives the source. On the deployed store that lookup decompressed about 27,000 rows per reading for ten oldstate.intervalsoutputs; 495,517 of that derivation's archived outputs were archived this way.cargo xtask bench output-rangesruns the two lookup statements over generated ranges at 10,000, 100,000 and 1,000,000 stored outputs and records what each read.Decisions
derivation.outputs. Memberships outlive their outputs: nine in ten ofstate.intervals' are archived. Keeping those out of an index over membership rows needs a liveness flag written at every archive, and every membership of a derivation that declares nothing would carry the columns. A table of live rows is deleted from at archive and holds only what is asked about.core.live_intervals. It keeps no fence, has no row for an instant and no key, andwork.episodeandactivity.dayare not interval kinds with these fields.state.intervalsoutputs have neither an end nor a fence, in 5 keys. An index of open outputs by start would return all of them to every lookup and need a membership probe for each; by key it reads one row per key.The upgrade on the deployed store
Schema 52 to 53 (the number is the next free one at landing). With
sinexdstopped, the step reads the events of the five derivations by source and type and writes one row per key and live output. Measured read-only on the deployed store on 2026-11-26: the fill's read forstate.intervalstook 33.5 s (1,090,652 events read, 89,919 rows returned, 386,246 blocks read from disk); the other four derivations hold 131 live outputs between them. Expect about a minute, and up to a few minutes when the disk is contended; three index builds over about 90,000 rows follow.unit.intervalsdeclares no range and gets no rows.Verified
admission/tests/dirty_ranges.rs: the boundary, missing-end, open, archived, wrong-kind and other-derivation cases of the former test with the same expected keys, the outputs now admitted through a batch of keys so the rows are the ones admission writes; fences, unreadable times and reversed bounds; rows written, copied to a second key, kept by a repeat and deleted by an archive; and the plan of both statements reading the same rows at 4,096 and 65,536 stored outputs.sinex-schema: the step fills the rows of live outputs per key on compressed chunks, and leaves the upgraded catalog equal to a fresh one.cargo xtask bench output-ranges(agentctl job 4480, generated ranges of one derivation with 256 keys, half of them with open outputs, on this machine's disk):The rows read are the same at the three sizes; the blocks follow the depth of the index. The traversal this replaces read every membership and every live output's payload: about 3,800 pages and 90,000 payloads for
state.intervalson the deployed store. That figure is from the deployed store, not from this bench, which has no case for the removed code.The store, schema and daemon tests the change can affect, locally on the rebased tree (agentctl job 4467, after compile job 4466); the hosted
checkandtestjobs on this head.Not verified here: the step on a restored copy of the deployed database, and the writer's transaction ages on the deployed daemon. Both need the deploy.
Task: sxnext-pib.16
🤖 Generated with Claude Code
https://claude.ai/code/session_01UuFixsXwismFLxbfWcuXHU