Repository navigation
Viewer: store the Overview CPU and I/O baselines once a day and read them first - #10441
Merged
Merged
Conversation
…st in the Viewer (#10435) V334 adds collect.overview_baseline_entries. The hourly store-maintenance tick writes the day's missing entries from 00:15 UTC within a 60 s budget, reopening its connection after a failed entry. The Viewer reads the entry for today's key first and computes as before when there is none, when the store is older than V334, or when the entry's window or compute version does not match. Retention keeps two key days.
There was a problem hiding this comment.
Verdict: CHANGES REQUESTED
Claims
- VERIFIED — V334 adds
collect.overview_baseline_entries, PK(server_id, metric_name, key_day), 193 tier rows as parallel arrays, window start, clock andcompute_version—OverviewBaselineEntries.csCreateSql; 193 asserted byTheWriter_WritesEachMissingEntryOnce_FromTheMargin_AndSkipsWhatIsWritten - VERIFIED — the writer is a new hourly-tick tenant after the pg_io_stats hourly rollup —
DarlingWorker.Passes.cs:1224-1226 - VERIFIED — from 00:15 UTC it writes the missing entries, I/O lane then CPU, for servers with rows in the last day, and skips written ones —
OverviewBaselineWriter.cs:66,Lanes,:79-90 - VERIFIED — the compute goes through the provider's existing single flight and shared tier —
PgBaselineProvider.ComputeEntryToStoreAsync→GetSharedEntryAsync - VERIFIED — the reader falls back to the compute when there is no entry, the store is below V334 (schema gate, not a caught error), or the window or version does not match —
PgBaselineProvider.cs:621,ViewerDataService.OverviewLanes.cs:255-257 - VERIFIED — retention keeps two key days in one statement —
DarlingRetention.cs:1343-1348,OverviewBaselineEntries.PruneSql - VERIFIED — the store probe gains the V334 sentinel and arm —
ViewerDataService.csprobe line and arm at:2016-2020; 310GetBooleanreads for 310 parameters - VERIFIED — the wait and blocking lanes stay computed —
StoredOverviewMetrics = [IoLatencyChart, Cpu]gate inReadStoredEntryAsync - VERIFIED — the web Overview's read is unchanged —
GetBaselineStepsSharedAsyncbody untouched; the only other provider change is theTierForextraction - VERIFIED — the 60 s budget and the compute's 90 s limit —
OverviewBaselineWriter.TickBudget;SharedComputeTimeout = AnalysisCommandTimeoutSeconds (60) + 30 - VERIFIED — a failed entry reopens the connection and the later entries still run —
OverviewBaselineWriter.cs:116-126;AnEntryThatBreaksTheConnection_FailsAlone_AndTheNextTickWritesIt - VERIFIED — Lite is unchanged — no Lite file in
gh pr diff --name-only - VERIFIED —
OverviewBaselineEntriesLiveTestshas 8 live facts — 8[Fact]in the file - VERIFIED — the window-check red proof targets a test that asserts it —
AnEntryWhoseKeyWindowOrVersionDoesNotMatch_IsNotRead_AndTheViewerComputesshiftswindow_startand expects the computed band, not 9999 - UNVERIFIED — lab rig timings (3.3 ms / 736.2 ms, 7.37e-15 worst difference, 58 KB WAL per entry, 17 MB at 300 servers) — need the 28.3M-row rig
- UNVERIFIED — field timings (42 servers, 2.95 s / 1.55 s / 0.37 s, ~86 s a day) — need the field store
- UNVERIFIED — the Linux gate run (3,343 ran, 55 failures none head-only) — needs a build and test run
- REFUTED — "8 live PostgreSQL facts on fixed clocks" —
TheRetentionSweep_DropsKeyDaysPastTwoDays_AndKeepsTheRecentOnesseeds fromDateTime.UtcNow.Date(OverviewBaselineEntriesLiveTests.cs:288), and its own summary says "It runs on the real clock"
Riskiest lines
Darling/PerformanceMonitor.Darling.Analysis/PgBaselineProvider.cs:621— the gate that decides whether a stored row stands in for the compute — covered byAnEntryWhoseKeyWindowOrVersionDoesNotMatch_IsNotRead_AndTheViewerComputesandTheViewer_DrawsTheComputesBand_FromTheEntryDarling/PerformanceMonitor.Darling.Service/OverviewBaselineWriter.cs:107— a null or faulted compute must not be stored — UNCOVERED (no test hands the writer a null orFaultedentry; the reopen path at:122is covered byAnEntryThatBreaksTheConnection_FailsAlone_AndTheNextTickWritesIt)Darling/PerformanceMonitor.Darling.Service/DarlingRetention.cs:1346— the prune cutoff — covered byTheRetentionSweep_DropsKeyDaysPastTwoDays_AndKeepsTheRecentOnes, which can flake across UTC midnight (see traps)
Traps near this diff
- "A live test that seeds at the wall clock (
DateTime.UtcNow, SQLnow()) and asserts an hour or day bucket splits its seed across two buckets when a run starts near the boundary, and fails only on the pull request that happens to run then (#10403)." — applies —OverviewBaselineEntriesLiveTests.cs:288seeds fromDateTime.UtcNow.Date; the sweep reads its own clock atDarlingRetention.cs:516. If midnight falls between those two reads, the cutoff (:1346) deletes thetoday-1row and the test sees 1 row, not 2. Inline comment posted. - "A test that reads the clock twice measures the CI scheduler" (#3676) — applies — the same test: the seed and the sweep each read the wall clock, so no single anchor owns both ends of the interval.
- "Lite and Darling ship in parity (CONTRIBUTING's two-store rule)" — does not apply — this is a Darling store and Viewer read-path optimization over a service-written table. Lite has no service/Viewer store split; it computes bands in-process from DuckDB. No reader, tool, alert or description changes (
PgBaselineProvider.csweb path unchanged). - "A retention-tiered store answers a 7-day question from a 4-day raw tier…" (#3590) — does not apply — the reader uses only today's key day, and rows outside it are rejected by key and window (
PgBaselineProvider.cs:607-621). - "Two copies of one definition pinned EQUAL to each other fail only after BOTH have drifted (#3684). Alias, do not copy." — does not apply — the tier rule moved into one
TierFor(PgBaselineProvider.cs:682-685) used by both the compute and the stored read, andOverviewBaselineEntries.Versionis the single number the migration,StorageVersionand the probe arm read.
Divergence (blind read vs PR body)
- The body says all 8 live facts run "on fixed clocks with no waits". One of them, the retention sweep, runs on the wall clock and carries a midnight race (trap #10403).
- The body doesn't mention that the writer stores the service's shared-cache entry. If the web Overview or the analysis pass computed today's key before 00:15, that earlier entry is what gets stored, so
WriteMargin's stated purpose (the collection lag has passed) is not guaranteed (OverviewBaselineWriter.cs:66,DarlingWorker.Passes.cs:1351). This is non-blocking because it is the same answer the service already serves. - The window check is described as rejecting an entry whose window "is not the one a compute at that key would use". The writer always writes
keyDay - 30whatever the compute read (OverviewBaselineWriter.csUpsertAsync). That is correct for Cpu/IoLatencyChart becauseClampToPlainViewPurgeHorizonAsyncclamps only event metrics, but in practice the check guards aBaselineWindowDayschange or a hand-edited row, not the compute's actual window.
Reviewer checklist
- Run
OverviewBaselineEntriesLiveTestsand the WPF Viewer tests on Windows; the gate run excluded 45 WPF tests. - On a live service, confirm the 00:15+ tick writes entries for all candidate servers within the expected number of ticks, and that the hourly tick's later tenants are not delayed beyond about 150 s.
- Open a server tab in the Viewer on a migrated store and confirm the CPU/I/O band timings drop to the PK read.
Owner
Author
|
One small follow-up in Verified in code
Concrete trigger and result
Fix (4 lines)Stop the loop when reopen returns if (!await TimescaleSupport.ReopenBrokenConnectionAsync(
connection, logger, cancellationToken,
"Overview baselines: the store connection is closed and could not be reopened, so the rest of this tick is deferred; the next tick tries again: {Message}"))
{
next++;
break;
} |
There was a problem hiding this comment.
Verdict: LGTM
Claims
- VERIFIED — The new commits list collect.overview_baseline_entries in the store table inventory — the one-line hunk in docs/darling/store-tables.csv:74 matches the CSV header and column format (relation,kind,export,note). The table name matches Darling/PerformanceMonitor.Darling.Storage/OverviewBaselineEntries.cs and PgMigrations.cs.
Riskiest lines
- docs/darling/store-tables.csv:74 — the kind and export values (derived,derived) were chosen by hand. They match the neighbouring derived tables. — UNCOVERED (docs-only change, no behaviour)
- docs/darling/store-tables.csv:74 — sort order, placed between oversized_plan_backlog_drops and perfmon_interval_baseline. It is alphabetical. — UNCOVERED (docs-only change)
- docs/darling/store-tables.csv:74 — the note text has no commas, so the CSV stays valid. — UNCOVERED (docs-only change)
Traps near this diff
- No trap applies: the range changes only a documentation CSV and no code, SQL or behaviour. I did not open .github/REVIEW-TRAPS.md for this range.
Divergence (blind read vs PR body)
None — the range is a single CSV row and I did not compare it against the PR body.
Reviewer checklist
- Confirm that no test parses store-tables.csv and expects a different
exportvalue for this table.
github-actions
Bot
dismissed
claude[bot]’s stale review
December 4, 2026 11:16
Superseded by claude[bot]'s LGTM on 6d41ba7: #10441 (review)
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.
Claude posting for Erik Darling.
Fixes #10435
A server tab's first open in the Viewer took 5.36 s and 5.49 s in the field, and its longest read was the Overview I/O baseline at 2.91 s and 3.29 s. That band and the CPU band are 30-day aggregates whose window ends at the UTC midnight, so each is the same all day. The service now stores both once a day and the Viewer reads the stored entry first.
What changes
collect.overview_baseline_entries. One row per server, lane and UTC key day (primary keyserver_id, metric_name, key_day). The row holds the 193 tier rows as parallel arrays, the window start, the server's clock (utc_offset_minutes,time_zone_id) and acompute_version. An older build ignores the table: it neither reads nor writes it and nothing it reads changes, so there is no rollback line.OverviewBaselineWriteris a new tenant of the hourly store-maintenance tick, after the pg_io_stats hourly rollup. From the first tick at or after 00:15 UTC it writes the missing entries for the I/O lane and then the CPU lane, for each server with rows in the last day. It is one serial pass that skips entries already written, so the first tick after a restart catches up and a compute that failed or timed out is tried again on the next tick. The compute goes through the provider's existing single flight and shared tier.compute_versionis not the one a compute at that key would use.Numbers
The six conditions
BaselineProvider, a single-pass aggregate over the local file, and no walk note times that read near the 5 s bar. Lite is unchanged.Tests
OverviewBaselineEntriesLiveTests, 8 live PostgreSQL facts on fixed clocks with no waits. The writer writes each missing entry once from 00:15 UTC, skips the written ones, gives a server with no rows in the last day no entry, and writes a later day after a gap. A tick on a clock the test moves stops at the budget and the next tick carries on. An entry whose compute ends the writer's store session fails alone, the three after it are written, and the next tick writes it. The Viewer draws the compute's band from the entry, and still does once the raw rows are deleted. The Viewer computes with no entry, on a V333 store (the gate reads 333 and the table is never read), and for an entry of another key day, another window or an unknown compute version. The retention sweep keeps two key days.ViewerSchemaVersionGateTestspin the V334 rung and move the V333 pins down one.OverviewBaselineEntriesLiveTests8 of 8,ViewerSchemaVersionGateTests34,MigrationProbeLadderTests196,DarlingRetentionTests56,StoreSelfMetricsTests44 andStoreSessionNamesTests4 are green.|| reader.GetDateTime(1) != AsNaive(windowStart), 1 match),OverviewBaselineEntriesLiveTestsran 8 with 1 failed,AnEntryWhoseKeyWindowOrVersionDoesNotMatch_IsNotRead_AndTheViewerComputes: Expected 24, Actual 9999. Reverted to 0 changed files.