Repository navigation
Conversation
…first) A sample of a window already committed, still within its view's retention, is to merge into that window: after a producer's pause past the idle close, after a barrier, through the result cache, and across a restart over the view files. One past retention is still dropped and counted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
…tention
A sample of a window already committed, while that window (or a window
of a group reading it) is within retention, is merged into it instead of
being dropped. The ingest coordinator batches a window's late samples per
pass; the precompute committer runs the window's views over them alone
and merges the rows into the stored window (equal plain columns merge
their states by each kernel's merge), then the change into the committed
windows of the groups reading those views. It applies a merge once those
groups have committed through it, so no run in flight read the window
first. Push shards hand the samples of their sealed windows to the same
merge.
The merged window replaces the stored one in memory and is written again
as a record of a higher revision; the view files index the highest
revision of each window (record heads without one read as 0, so the
format stays 5). The window cache keys windows by revision, and the
result cache and query-time results record the views' revision they were
computed from and recompute an answer that read a window revised since.
Beyond retention a late sample is still dropped and counted. The
samples_late_for_views counter becomes samples_merged_late
(asap_samples_total{outcome="merged_late"}).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
…bench call site Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
Push mode merges the samples of sealed windows as the window path does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
zzylol
added a commit
that referenced
this pull request
Nov 29, 2026
…within retention A collector request's staged windows close when the request ends, and the request is answered once they are committed: no commit grace (the 8 s grace cost every window about 6 s of freshness, while states arrive within half a second of the window's end). A state that comes later for a committed window still kept merges into it through the late merge of #892 (and into the windows of the groups reading the view); one of a window past retention, or closed without states, is dropped as late. The hashes of each committed window's states are kept while the window is, per series, so a resent state or request merges nothing twice. CollectorViewOptions::commit_grace_ms is removed; the report and asap_collector_states_total gain late_merged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
…le routed while its window closes is kept (failing first) The second test needs a test hook, routing_delay_after_flush_ms: the coordinator waits between the flush every shard answered and the routing it publishes, which is when the race happens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
… insert missing windows; shards wait for a pass's routing - A group whose states depend on the order of their samples (Counter for rate/increase, IRate) keeps its raw samples for its views' retention. A late sample of it is stored as raw data too, and its window is computed again from the raw data whole and replaces the stored one; the windows built from it are computed again from the views. Such a group is not built by push. KLL and float sums keep the merge. - A pane's raw rows stay in time order: an out-of-order append (a late sample) rebuilds the pane as one chunk sorted by time. - ViewStore::replace_window replaces a window, or inserts one missing behind the newest within retention (for a collector view's window whose first states come late, #890); merge_late can insert likewise. - After answering a flush, a shard holds its samples until the routing of that pass (the Maintain the coordinator now sends after every flushed pass), so no sample is routed by windows a pass has closed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
…rs not closed yet take no change A merge waited until every reader group had committed through the window holding it, which never happens when that reader's window failed (it read a window still missing). It now waits while a window holding it is closed and not committed, and a reader's window not closed yet takes no change: it reads the changed window when it closes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
…s; T12 over the gauge queries A window read from a late-changed window is computed again from the views; when that run fails (a window it reads is already gone) the reader keeps its rows and the change already made stays, instead of failing the whole merge after the store changed. T12 measures the raw buffer of pushed pipelines over the dashboard's gauge queries: its counter queries are no longer pushed (their windows are computed again from raw samples kept for retention). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
zzylol
added a commit
that referenced
this pull request
Nov 29, 2026
… window's is stored Collector states of a closed window still kept that was never stored (its first states came after a later window committed, e.g. from a collector lagging more than a window) go to the late path with insert set: the window is stored behind the newest (#892's replace_window / merge_late), and the wider windows read from it that closed meanwhile are computed again (inserted when their first run failed on the missing window). They count as late_merged; only a window past retention is late_dropped. Collector windows also count in the committer's closed-through, which decides which readers take a change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
…tion reaches the wide level (failing first) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
…w levels kept as long as the levels computed again from them - storage::xor_chunk: one series' samples as a Prometheus-style XOR (Gorilla) chunk, delta-of-delta timestamps and XOR'd value bits, lossless on any bit pattern. - RawData keeps a metric's closed panes that only windows computed again read (behind every window still to close, within an order-sensitive group's floor) as CompressedPanes, one XOR chunk per series; a read decodes them, and a late sample of one makes the pane columnar again. The routing carries both cutoffs: compress, then evict. - A group a chain computed again reads keeps its windows as long as the readers' windows reach back (their retention plus their width), and the late-sample floor of an order-sensitive group takes its readers' floors, so a late sample within the widest level's retention always has the narrow windows to compute every level again from. The path that kept a reader's old rows when its run failed is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
zzylol
added a commit
that referenced
this pull request
Nov 30, 2026
… window's is stored Collector states of a closed window still kept that was never stored (its first states came after a later window committed, e.g. from a collector lagging more than a window) go to the late path with insert set: the window is stored behind the newest (#892's replace_window / merge_late), and the wider windows read from it that closed meanwhile are computed again (inserted when their first run failed on the missing window). They count as late_merged; only a window past retention is late_dropped. Collector windows also count in the committer's closed-through, which decides which readers take a change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
zzylol
added a commit
that referenced
this pull request
Nov 30, 2026
…k and are stored empty
Collector windows closed only when states arrived, so while a collector
stream was idle none closed and every range over the idle period failed
("has no rows tiling", HTTP 422), for good if the stream never resumed.
As #889's idle close does for samples, a collector view's group now has
an idle watermark on the monotonic clock: the newest state's window end
(capped at its arrival's wall-clock time) plus the monotonic time since
it arrived, less the collector's close delay and skew allowance
(CollectorViewOptions::idle_close_ms, default 6 s + 2 s). Windows it
passes close with no state and are stored empty; states or corrections
of them coming later merge in (#892). Nothing closes on the clock before
a group's first states.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
…of walking every pane - RawData keeps its samples and bytes held, updated as panes are appended, compacted, compressed, made columnar again and evicted. The ingest coordinator reads them after every flush for the raw-data gauges; it no longer walks every stored pane and chunk each pass. - A compressed pane's bytes are taken once, when it is made. - A chunk's bytes no longer count the series identity column a read builds later: it is a read cache, and a chunk's bytes must be fixed when it is made for a running total. `asap_raw_data_bytes` is lower by those identity columns. - Test: the running totals equal a walk over every pane after appends in and out of order, late samples of sealed and compressed panes, sealing, compressing and evicting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
- Each metric remembers how far its panes are sealed; a seal visits only the panes after that and the sealed panes a late sample gave another chunk since (kept in a set by the append). Since the shards get a maintenance message after every flush, the seal no longer walks every pane each pass. - Compressing returns at once when no columnar pane ends at or before its cutoff: compressed panes leave the columnar map, so only newly closed panes, or ones a late sample made columnar again, are left there. - Test: a late chunk in a sealed pane is compacted by the next seal; the running totals still equal a walk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
… for chunk building - The series interner keeps one name per metric, shared by its series, so two series' metrics are equal exactly when the pointers are (`Series::metric_key`). - RawData::append groups a request's samples by (metric pointer, pane), checking the last group first, instead of a BTreeMap keyed by the metric name that compared the names byte by byte per sample. The routing finds a sample's metric by pointer too. - Chunk::new maps series ids to codes with ahash instead of SipHash. - Test: series of one metric share its name; other metrics do not. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
…e blocks, off the ingest shards - A compressed block takes consecutive closed panes of a metric, enough for 120 samples per series (COMPRESSED_SAMPLES_PER_SERIES), and keeps one XOR chunk per series over all of them: at 1 sample/s a 15 s pane gave each series a chunk of 15 samples, whose header and slack dominated. The newest panes that do not fill a block yet stay columnar. - A late sample within a block's span makes the block's panes columnar again (one chunk per pane), so a window computed again reads exactly the samples it did; the panes are compressed again later. A read decodes the blocks overlapping its range and keeps the rows in it; an eviction drops the blocks ending at or before the cutoff. - Compression runs on one thread of its own (`raw-compress`), not on the ingest shards: a shard's maintenance takes the panes to compress (RawData::panes_to_compress) and sends them; the shard installs the encoded blocks at its next maintenance (RawData::install_compressed), each only if its panes are as they were taken, else the panes are taken again later. One metric has at most one batch in flight. - RawData::compress_through still compresses here and now (tests). - Test: blocks of several panes read back as the columnar panes over ranges inside, across and outside blocks, after late samples in a block's first, middle and last pane and on a block boundary, after compressing again, after a late sample while a block was encoded, and after evicting part of a block; running totals and pane counts equal a walk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
…d pane (failing first) Concurrent senders deliver requests out of time order. Today each such request rebuilds its whole pane (every row so far, sorted again), so a window-mode raw store does work in the pane's size per request. The test swaps each pair of requests, checks no pane is rebuilt, and that reads return exactly the rows, in the order, of one pane sorted by time (equal times in arrival order), before and after sealing and after a late request into sealed panes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
…hunk; the pane is merged in time order when read or sealed - Concurrent senders (an OTLP exporter, a feeder with several requests in flight) deliver requests out of time order. Each such request used to rebuild its whole pane: every row so far collected, sorted and made one chunk again, work in the pane's size per request. With the raw samples kept (window mode), this was most of the ingest shards' CPU over OTLP. - Now the request's rows (sorted among themselves if needed) become a chunk of their own, and the pane is marked unsorted. The first read of an unsorted pane merges its chunks in time order (equal times in arrival order, as the rebuild did) and keeps the merged chunk for later reads and clones; an append replaces it. Sealing compacts the pane in time order, reusing that merged chunk when a read built it. Panes not sealed in time order yet are not compressed. - Reads return the same rows in the same order as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
zzylol
added a commit
that referenced
this pull request
Nov 30, 2026
… window's is stored Collector states of a closed window still kept that was never stored (its first states came after a later window committed, e.g. from a collector lagging more than a window) go to the late path with insert set: the window is stored behind the newest (#892's replace_window / merge_late), and the wider windows read from it that closed meanwhile are computed again (inserted when their first run failed on the missing window). They count as late_merged; only a window past retention is late_dropped. Collector windows also count in the committer's closed-through, which decides which readers take a change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
zzylol
added a commit
that referenced
this pull request
Nov 30, 2026
…k and are stored empty
Collector windows closed only when states arrived, so while a collector
stream was idle none closed and every range over the idle period failed
("has no rows tiling", HTTP 422), for good if the stream never resumed.
As #889's idle close does for samples, a collector view's group now has
an idle watermark on the monotonic clock: the newest state's window end
(capped at its arrival's wall-clock time) plus the monotonic time since
it arrived, less the collector's close delay and skew allowance
(CollectorViewOptions::idle_close_ms, default 6 s + 2 s). Windows it
passes close with no state and are stored empty; states or corrections
of them coming later merge in (#892). Nothing closes on the clock before
a group's first states.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
… pushed (failing first) A refresh group mixing a counter's rate (computed again from raw samples on late data) with other views is not pushed at all today, so in push mode the whole group falls back to the window path and keeps raw samples for every metric it scans. The test plans sum_over_time(data[30s]) with rate(data_total[30s]) in one group and checks that in push mode the other views are built by push, with every answer equal to the window path's, late samples included. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
…so the rest stays pushed A group was pushed only if none of its views was order-sensitive (a counter's or an instant rate's state, computed again from raw samples on late data). One rate(...) in a group therefore sent all its views to the window path, and raw samples of every metric they scan were kept: the collector e2e's W1 plans its five views into one 5 s group, so at the data plane's default push mode W1 lost push entirely. Ingestion::new now runs such a group as two groups of the same window: the order-sensitive views (window path, raw samples kept, recomputed) and the others (pushed when they qualify). The part read by the other comes first; a group whose two parts read each other stays whole. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
…encode their panes themselves When ingest outran the one raw-compress thread (an unpaced backfill at 2-4 M samples/s), each metric had one batch in flight and the panes behind it waited columnar until it came back: the dashboard shape's max RSS went from 2.8 to 4.8 GB. - A metric may now have several batches in flight: a take gets only panes newer than every batch in flight (RawData keeps their newest ends), so panes no longer wait for an earlier batch to come back. - The shards count the samples queued for the thread; past 4 M samples (about 64 MiB columnar) a shard encodes and installs its batch itself, which slows its ingest instead of growing memory (backpressure). - Test: two batches in flight, installed in either order, read as the columnar panes; a block a late sample changed in flight is taken again once the newest batch is installed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
zzylol
added a commit
that referenced
this pull request
Nov 30, 2026
… window's is stored Collector states of a closed window still kept that was never stored (its first states came after a later window committed, e.g. from a collector lagging more than a window) go to the late path with insert set: the window is stored behind the newest (#892's replace_window / merge_late), and the wider windows read from it that closed meanwhile are computed again (inserted when their first run failed on the missing window). They count as late_merged; only a window past retention is late_dropped. Collector windows also count in the committer's closed-through, which decides which readers take a change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
zzylol
added a commit
that referenced
this pull request
Nov 30, 2026
…k and are stored empty
Collector windows closed only when states arrived, so while a collector
stream was idle none closed and every range over the idle period failed
("has no rows tiling", HTTP 422), for good if the stream never resumed.
As #889's idle close does for samples, a collector view's group now has
an idle watermark on the monotonic clock: the newest state's window end
(capped at its arrival's wall-clock time) plus the monotonic time since
it arrived, less the collector's close delay and skew allowance
(CollectorViewOptions::idle_close_ms, default 6 s + 2 s). Windows it
passes close with no state and are stored empty; states or corrections
of them coming later merge in (#892). Nothing closes on the clock before
a group's first states.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
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.
Summary
L + Gand then resumes has the windows of its pause closed from part of their samples, and the rest are dropped: those windows are lost for good.ingest_shards.rs::samples_after_a_pause_merge_into_the_window_closed_by_wall_clock): lateness 0, samples through 35 s, then a pause until the clock reads 50 s. The idle watermark (49 s) closes(30, 40]with 31..=35 s only. The producer resumes with 36..=60 s: today the 64 × 5 samples at 36..=40 s are dropped andsum_over_time(data[30s])at 40 s stays short.merge_with; other rows are added. The change is then merged into the committed windows of the groups that read those views (wider chain levels), transitively.samples_dropped_late, as before).samples_merged_latecounts 320 andsamples_dropped_late0.Follow-ups (2026-11-30, approved), at 3b3eaac
storage::xor_chunk,RawData::compress_through).CompressedPane).land/sample-block-codecbranch, in the old layout. The encoder here (~200 lines) uses that codec's bit layout.window_levels.rs::a_late_counter_sample_reaches_the_wide_level_past_the_narrow_retention: a sample at 3 495 s with the newest window at 7 200 s is past the narrow level's own floor (3 540 s) but inside the 15 min window(2 700, 3 600]. The 1 hincreaseat 6 300 s equals on-time arrival. Before the change it failed withsamples_dropped_late: 1and a 1 011 difference.store.rs::compressed_panes_read_as_the_columnar_ones: compressed panes read row for row as the columnar ones and take fewer bytes, and a late sample of a compressed pane joins it in time order. This is the "recompute from chunks equals recompute from rows" check at the read level.ingest_shards.rs::a_late_counter_sample_recomputes_its_window_from_the_raw_samplesnow recomputes from compressed panes.xor_chunk.rs::chunks_read_back_exactly: NaN payloads, ±0, ±∞, jitter, backwards timestamps and extreme times all read back exactly.Memory and ingest CPU
ingest_bench, release build, in process, views in memory. Each binary was built in its own target directory.rate/increase, 10k series × 1/s, 3 600 s unpaced:asap_raw_data_bytesrate(data_total[1m]), 10k series × 10/s), paced 180 s:asap_raw_data_bytesThe e2e's rise comes from outside this change set.Wrong: see "Why e2e ingest CPU on W1 rose" below (push mode lost for W1's group, and pane rebuilds on out-of-order OTLP requests).Ingest CPU follow-ups (2026-11-30)
Pure efficiency: no answer changes. Commits on top of 3b3eaac:
perf(storage): raw data keeps running sample and byte totals …RawDatakeeps its sample and byte totals, updated on append, compaction, compression, decompression and eviction. The coordinator no longer walks every pane per pass for the raw-data gauges.perf(storage): sealing and compressing visit only the panes not done yetperf(storage): appended samples grouped by the interned metric; ahash for chunk buildingSeries::metric_key), soRawData::appendand the routing compare metrics by pointer.Chunk::newuses ahash instead of SipHash.perf(storage): counter raw kept for recompute compressed in multi-pane blocks, off the ingest shardsraw-compressthread: a shard's maintenance takes the panes, and the shard installs each block at its next maintenance, unless a late sample changed those panes in the meantime.test(storage): out-of-order requests …(failing first) +perf(storage): a request older than its pane's newest sample adds a chunk …Chunk::newover every row so far). Now it adds its own chunk and marks the pane unsorted. The first read of the pane merges its chunks in time order (equal times in arrival order, as before) and keeps the merged chunk. Sealing then compacts the pane.asap_raw_data_bytesno longer counts the series identity column that a read builds lazily on a chunk. That column is a read cache, and leaving it out lets the total stay exact.Tests:
running_totals_equal_a_walk_over_the_panes,multi_pane_blocks_read_as_the_columnar_ones(late samples in a block's first, middle and last pane and on a block boundary, compressing again, a late sample while a block is being encoded, evicting part of a block),out_of_order_requests_read_as_one_sorted_pane(reads give the rows of one sorted pane, in the same order), andseries_of_one_metric_share_its_name. The storage, precompute, ingest_shards, window_levels, push_precompute, server and ingest_protocols tests pass. One parity test,push_precompute_answers_what_the_planner_executor_answers, fails withEMFILE(Too many open files) under a 1024 open-files limit. It fails the same way on 3b3eaac, so this change did not cause it.Measured (ingest_bench, in process, release; each binary built in its own target directory; one 56-core host; 3 runs at once on disjoint cores; median of 3)
W1 shape: the collector e2e's 5 queries, including
rate(data_total[1m]). 10k series × 10/s for each of 2 metrics, paced, 200 s, lateness 2 s, 2 ingest shards and 2 precompute threads, views in memory. CPU is in seconds over the 200 s run.raw-compressasap_raw_data_bytes† This row ran while another benchmark used the host's other cores, so its precompute times are not comparable. The in-process feeder sends requests in order, so the last commit changes nothing here. Over OTLP (below) it is the one that matters.
"All data-plane threads" is the run total minus the bench's own sender thread.
W1 shape over OTLP/HTTP: the paced feeder, 2 metrics × 10k series × 10/s, 4 requests in flight per metric, as the e2e feeds it. Data plane at the restacked #891, CPU over 100 s of steady state:
raw-compressDashboard shape: 1 h
rate/increaseand thelatgauge, 10k series × 1/s per metric.asap_raw_data_bytesat the endraw-compress‡ Unpaced, ingest runs at 2–4 M samples/s, faster than the single
raw-compressthread encodes (about 3 M samples/s of CPU). Panes therefore wait columnar until the thread catches up. Before, the shards encoded inline, which throttled ingest instead (3 716 vs 691 Remote Write 503 retries; every write acknowledged after 32.7 s vs 19.0 s). At live rates (100k samples/s) the thread keeps up.§ At 1 sample/s, a block needs 8 panes (2 min) to reach 120 samples per series, so up to 8 counter panes wait columnar. With 10 min of data that wait outweighs the saving. With 1 h kept, the saving wins: 497 → 285 MB, −43 %.
Why e2e ingest CPU on W1 rose from 0.19–0.20 to 0.59–0.61 cores (b8a6b34 → #891), and the in-process bench rose only ~0.06
This corrects the earlier note above ("comes from outside this change set"). There are two causes, and both come from this PR.
data_planedefaults to--precompute-mode push. 712272c excludes from push any group that recomputes from raw samples (!precompute.recomputes(g)inInstalledPrecompute::start). W1 plans all 5 views into one 5 s group (views="1,6,10,15,20"), and that group includes the order-sensitiverate(data_total[1m]). So the whole group falls back to window mode: raw samples are kept, and every window is a per-window ingestion run./metricsshows this. At b8a6b34,precompute_push≈ 17.5 s per shard,precompute0,asap_raw_data_bytes0. At Collector views: control plane rule and collector-views file, data plane --collector-views #891,precompute_push0,precompute56.9 s, raw bytes 217 MB.ingest_benchdefaults toPRECOMPUTE_MODE=window, so in process both heads ran window mode and only the raw-store costs showed, about +0.06 cores.RawData::appendre-sorted and re-chunked the open pane for every request older than the pane's newest sample. The collector exporter and the feeder keep several requests in flight, so this is the common case. The in-process bench sends requests in order and never hit it.Chunk::newand 8.5 % in the row collect.The OTLP decode path is not the cause. The OTLP adapter is identical between b8a6b34 and #891, and the e2e
otlp_decodephase was 11.0 s at b8a6b34 and 11.1 s at #891.Expected e2e effect on W1 now: ingest shards about 0.07 cores, plus
raw-compressabout 0.1 and per-window precompute about 0.14. That is still above b8a6b34's push mode. The remaining gap is cause 1.Resolved in Follow-ups 2: the backend splits the group's execution, and the planner is unchanged.
Follow-ups 2 (2026-11-30, approved): push kept beside recompute, bounded compression queue
test(precompute): order-sensitive views leave the rest of their group pushed(failing first) +feat(precompute): a refresh group's order-sensitive views run apart, so the rest stays pushedIngestion::newnow splits a refresh group that mixes order-sensitive views (counter / irate state) with other views into two groups with the same window. The order-sensitive part takes the window path, keeps its raw samples and is recomputed on late data. The other part is pushed when it qualifies. Whichever part the other reads goes first. A group whose two parts read each other stays whole. The planner is unchanged; this is execution only.perf(precompute): the raw-compress queue is bounded; past it, shards encode their panes themselvesraw-compressthread. Past 4 M samples (about 64 MiB columnar), a shard encodes its batch itself. That is backpressure on ingest instead of memory growth.Tests:
push_precompute.rs::order_sensitive_views_leave_the_rest_of_their_group_pushed. It planssum_over_time(data[30s])andrate(data_total[30s])into one group. In push mode it checks that push runs happen and that every answer equals the window path's, late samples included. Before the change it failed: no push runs.store.rs::batches_in_flight_install_in_any_order.W1 over OTLP: b8a6b34 vs now
Paced feeder, 2 metrics × 10k series × 10/s, 4 requests in flight per metric, straight to
data_plane(push mode, the default) with the e2e's flags: lateness 2 s, 2/2/2 threads, no view persistence. CPU is over 100 s of steady state, median of 3, alternating core sets.raw-compressratewindows run on the window path: 0.031 cores.Dashboard shape: compression backpressure
1 h
rate/increaseand thelatgauge, 10k series × 1/s per metric, in-process bench.asap_raw_data_bytesat the endraw-compresslatgauge's raw samples only as long as its own windows need them.fetch_add/fetch_subinstead offetch_update, which newer toolchains deprecate.Routing wait (approved follow-up 3)
ingest_bench 10000 600 raw, #889 e6c41e3 vs #892 3b3eaac, alternating:No measurable cost, so no optimization is proposed. A paced 120 s run had no precompute backlog on either. (An earlier comparison mistakenly ran #889's code for both binaries, because worktrees shared one release target. It was redone with separate target directories.)
Review guide
feat/idle-wall-clock-close(feat(precompute): close an idle stream's last windows by wall-clock time #889, e6c41e3), stacked on chore: range step cap in the query engine, one plan test helper, QueryOutcome as Result #888 → fix(otlp): OTLP/HTTP replies, Prometheus resource-attribute labels, DELTA sums rejected, in-place decoder #887 → chore: pin ASAPPlanner 566b35c and its asap_sketchlib d050037 (view format 5) #886. Draft; do not merge.crates/precompute/src/ingestion.rs:Routing::route: a sample in a closed window of a raw-path group that is still kept goes toRouted::late. A raw sample at or beforelate_throughis still not stored as raw data; it is dropped only if no window takes it.Ingestion::kept_after_ms: a group's floor is the lowest of its own and its readers' floors, so a change still reaches a wider level after the narrow window itself is gone.Precompute::late_readyandPrecompute::merge_late.crates/storage/src/store.rs:ViewStore::merge_late,merged_rows,revisionandchanged_since.crates/precompute/src/engine.rs:ShardReport::lateand the coordinator's per-window batches:PrecomputeJob::Late.serve_precompute, andmerge_late.ToPersistnow carries the slots taken at commit time.crates/precompute/src/push.rs:PushShard::pushkeeps the samples of windows the shard already sealed (take_late); the shard routes those still kept to the same merge.late_ready): once no window holding it, of its group or of a group reading it (transitively), is closed and not yet committed. So no run still in flight read the window before the merge.closed_throughon the committer).ExactAggregate(Counter | IRate):rate,increase,irate) is not merged. Merging would take a late sample between two on-time ones as coming after them, and miss a reset.ViewStore::replace_window).ViewStore::replace_windowandmerge_latecan insert a window that is missing behind the newest, within retention. Collector view states: ingest OTLP states of the views a collector builds, staged and committed as the view's windows #890 uses this for a collector window whose first states come after a later window's; the raw path never inserts.Maintainafter every flushed pass. So no sample is routed by windows the pass has closed, which would leave it in neither the window nor a late merge. The cost: a shard waits for one coordinator pass per flush before routing more.Design choices
Persistence
The merged window is written again as a new record at a higher revision. Nothing is rewritten in place:
RecordHeadgains#[serde(default)] revision: u64. Records written before this change read as 0, soFORMAT_VERSIONstays 5 and existing files load.ViewFiles::indexkeeps, per view and range, the record with the highest revision, whatever segment it is in. After a restart, the next append of an old window can start a segment named by an older end than the original's, so segment order cannot decide which record wins.WindowLocationandWindowKey, so it survives restarts and the window cache never serves the rows of an older revision under the new key.Cache invalidation
Invalidation is lazy, and is checked against the reader's snapshot:
ViewStorecounts the late merges (revision) and remembers the window end of the newest 4096 merges.changed_since). If the merge is older than the 4096 remembered, the entry is also treated as stale.CompiledQueries::cachedtakes the snapshot. The range path now takes its snapshot before the cache lookups, and the instant path takes one for its lookup.Other choices
merged_latecount (T13).IngestionStats::samples_late_for_views,Routing::views_closed_through, the per-sample "late for views" check, andPushShard::fold's late count. The/metricsoutcomelate_for_viewsbecomesmerged_late.Behavior: before → after
(30, 40], then resumes with 36..=60 ssamples_dropped_late)samples_merged_late); answer as if on timeTthat read a revised windowlate_for_views)increase: on time 10 @ 2 s, 12 @ 8 s; late 3 @ 5 s (a reset)Interfaces
crates/storage/src/store.rsimpl ViewStore { + pub fn merge_late(&mut self, view: &MaterializedView, time_range_ms: (i64, i64), revision: u64, late: Vec<Batch>, insert: bool) -> Result<Option<Vec<Batch>>, Error>; + pub fn replace_window(&mut self, view: &MaterializedView, time_range_ms: (i64, i64), revision: u64, batches: Vec<Batch>, insert: bool) -> Result<Option<Vec<Batch>>, Error>; + pub fn window_revision(&self, view: PhysicalASAPNodeId, end_ms: i64) -> Option<u64>; + pub fn revision(&self) -> u64; + pub fn changed_since(&self, revision: u64, time_ms: i64) -> bool; } impl RawData { + pub fn emptied(&self) -> Self; } impl<E: Clone> QueryTimeResults<E> { - pub fn get_or_compute(&self, node, time_ms, watermark_ms, compute) -> …; + pub fn get_or_compute(&self, node, time_ms, watermark_ms, views: &ViewStore, compute) -> …; }crates/storage/src/window_cache.rs,segment.rs,persist.rs,persist_pool.rspub struct WindowKey { pub view: PhysicalASAPNodeId, pub end_ms: i64, + pub revision: u64, } pub(crate) struct RecordHead { + #[serde(default)] + pub revision: u64, } impl WindowLocation { + pub fn revision(&self) -> u64; } impl ViewFiles { - pub fn append(&mut self, group, range_ms, views) -> std::io::Result<Written>; + pub fn append(&mut self, group, range_ms, views, revision: u64) -> std::io::Result<Written>; } impl PersistPool { - pub fn queue(&self, group, range_ms, views, slots); + pub fn queue(&self, group, range_ms, views, slots, revision: u64); }crates/precompute/src/ingestion.rspub struct IngestionStats { - pub samples_late_for_views: u64, + /// Samples merged into a window already committed, counted once per group window they changed. + pub samples_merged_late: u64, }crates/query/src/result_cache.rs,lib.rsimpl ResultCache { - pub fn get(&self, root, time_ms) -> Option<Answer>; - pub fn insert(&self, root, time_ms, answer, watermark_ms); + pub fn get(&self, root, time_ms, views: &ViewStore) -> Option<Answer>; + pub fn insert(&self, root, time_ms, answer, watermark_ms, revision: u64); } impl CompiledQueries { - pub fn cached(&self, root, time_ms) -> Option<Answer>; + pub fn cached(&self, root, time_ms, snapshot: &Snapshot) -> Option<Answer>; }crates/precompute/src/engine.rs,crates/data-plane/src/engine.rs(test hook)pub struct PrecomputeOptions { + pub routing_delay_after_flush_ms: u64, } pub struct EngineOptions { + #[doc(hidden)] pub routing_delay_after_flush_ms: u64, }/metrics:Tests
Test-first: the first commit adds the tests below; on the base, (a), (c), (d) and the merged-on-any-shard test fail (answers short / cache stale / restart loads the unmerged window), (b) passes (it guards the unchanged drop).
ingest_shards.rs::samples_after_a_pause_merge_into_the_window_closed_by_wall_clock: manual clock; pause past the idle close, resume; answers at 40/50/60 s equal the no-pause answers; 320 merged, 0 dropped.ingest_shards.rs::a_late_sample_past_retention_is_dropped: merged 0, dropped 1, answer unchanged.result_cache.rs::a_late_merge_drops_the_cached_answers_reading_its_window: a cached range answer is recomputed after the merge and equals the on-time data plane's.view_persistence.rs::a_merged_window_is_loaded_merged_after_a_restart: a new series merged into the window ending at 600 s; the restarted data plane answers with it.ingest_shards.rs::a_late_sample_merges_into_its_closed_window_on_any_shard_count(wasa_late_sample_is_dropped_on_any_shard_count), 1 and 8 shards.window_levels.rs::a_late_sample_reaches_the_wider_levels_built_from_its_window: a sample 40 min late reaches the 1 h sum's wider levels after the narrow window was dropped; every answer equals the samples'.persist.rs::the_highest_revision_of_a_window_is_indexed(unit): revision precedence across segments after a restart; a pre-revision head decodes as 0.push_precompute.rsT13: window path and push give equal windows and equalmerged_late.persist.rs::appends_never_truncate_an_existing_segment: a window appended twice indexes as one window (was 2 entries).10659b35, both failed on the previous head):ingest_shards.rs::a_late_counter_sample_recomputes_its_window_from_the_raw_samples: on time 10 @ 2 s, 12 @ 8 s, then 3 @ 5 s late. The answer equals the data plane that got all three on time. Before: merged, 3.67 vs 19 extrapolated.ingest_shards.rs::a_sample_routed_while_its_window_closes_is_not_lost: needs the test hookrouting_delay_after_flush_ms. The coordinator waits 1 s between the flush and the routing, and series 5's sample of(20, 30]comes in that gap. Before: job1 14 short.store.rs::a_missing_window_is_inserted_behind_the_newest(unit): insert behind the newest; no insert withoutinsert, when overlapping, or past retention.a_window_whose_first_states_come_after_a_later_windows_is_storedexercises the insert and the reader rebuild end to end.Gates
At 8f5588f:
cargo fmt --all --checkandcargo clippy --workspace --all-targets --locked -D warnings: clean.storagelib 46,precomputelib 10,querylib 4.data_planeintegration (ulimit -n 65536), all pass:ingest_shards17,window_levels3,push_precompute16 (+3 ignored),result_cache6,view_persistence8,server10;view_tiering9,view_memory1,ingest_protocols6,precompute_pool6;planner_executor_parity6 (1055 s).ingest_bench.Open questions
Resolved (approved 2026-11-29):
Still open:
🤖 Generated with Claude Code
https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf