Repository navigation
feat(dash): five-page dashboard, bottom line first (#473) - #477
Conversation
Measured on a 3.6 GB snapshot of a production database (187k requests, 1.76M request_components, 2.3M tool_declarations), one client, fresh process, all-time window. Before: Overview 12 s, /api/components 20 s, the Inventory reads 14-21 s, the KV-cache replays 46-52 s, /api/prompt 21 s, the keep-alive reads 4-6 s, and /api/series answered its default bucket with 12.9 MB. After, cold: every endpoint 0.4-4.7 s except Overview at 6.1 s; repeated reads of any endpoint 10-20 ms. Every number is unchanged (see the tests below). Root causes, each fixed where it lived: * Correlated subqueries and per-account re-runs. The replay-ceiling count and the ping-inflation sum ran one index walk per saving/ping row (11 s + 4 s); both are window functions now, over only the sessions that need them. The keep-alive behaviour panel re-ran its LAG CTE once per account for a median; it reads every account's gaps once. The keep-alive ledger, calculator and recommendation ran 4-6 independent full passes back to back; they run together. * Five passes over requests for five GROUP BYs, and four sorted OFFSET reads for two p95s and two medians: one grouped read and one value read each, re-grouped and ranked in Go with the same rank rule. * The components tab joined request_components (1.7M rows) to requests three times for the rows and the two read-time valuations, plus json_each over 945k gate/event strings (allocation-bound: 7 us a row, 2.7x on eight cores). One join at the finest grain feeds the rows and both valuations; the counters are summed in Go from the raw JSON when it is a flat integer object (anything else falls back to json_each); the join is read in eight id slices side by side. * The Inventory reads probed tool_declarations once per in-scope session (~1,000 rows each, 11 s) or sorted all 2.3M rows. A broad scope now makes one concurrent pass over the table and reduces it in Go; a narrow scope keeps the probe. The report and the observation windows share the pass. * Every KV-cache read rebuilt the same window-function dataset (4.5 s). An unbounded read is split in four shards of whole sessions (exact: a session never straddles two); a time-bounded one stays a single statement (sharding it repeats the index lookups per shard and measured slower). The row count and the median prefix skip the window when nothing narrows on a derived column. * BudgetPolicy.Windows asked the reuse model for 4n points and the model rebuilt its whole curve for each (25 of the 29 s of an all-history simulate). It builds it once per observation and reads it 4n times; the early exit it replaces could not change a read (documented at reuseCurve). The policy remembers its last answer, which Simulate asks for twice per request. Suggest cells and simulate arms are independent replays and run side by side. * /api/series answered the route's one-minute default bucket over all history as 78,000 buckets; it is widened to a whole multiple that fits 2,000 buckets (the UI's hourly request is unchanged: 1,305 buckets). * The remaining heavy GET routes had no response cache and the UI reads them on every tab switch. They go through the existing stale-while-revalidate singleflight cache (cachedRoute), with the heavy handler bound so the first reader after a restart waits for the real work. /api/prompt caches the UNSTRIPPED view and applies the per-address content strip to each reader's own copy, so nothing that depends on the address is shared. * The DSN ran journal_mode before busy_timeout, so a connection opened while the WAL was busy failed at once with SQLITE_BUSY; the fan-out reads open bursts of connections, so busy_timeout now comes first. No schema change and no new index: the pass over tool_declarations replaces the index a faster GROUP BY would have needed, and building one costs ~40 s of start-up downtime on this corpus. TestGoldenEndpoints pins 28 endpoint payloads, number for number (relative 1e-9 on floats), to files recorded from the code before this change. perf_equivalence_test.go pins each rewritten read to the one it replaced. Signed-off-by: Osher-Elhadad <[email protected]>
Signed-off-by: Osher-Elhadad <[email protected]>
|
Design review, round 1: dashboard. Reviewed the fold screenshots (desktop and phone, light and dark) against the five-second questions in 5-second test
Rubric
Findings
Next: the author fixes 1-9; I re-judge on new screenshots. |
|
Design review, round 2: dashboard. Re-judged the refreshed fold screenshots (light, desktop). Not PASS yet; 3 BLOCKING items remain, everything else from round 1 is fixed. 5-second test
Rubric
Remaining findings
Next: author fixes 1-3, then I re-judge. |
|
Design review, round 3: PASS. Re-judged the refreshed fold screenshots (all five pages, light and dark; phone spot-check on Sessions). All five pass the 5-second test. Round-2 blockers are fixed: unpriced items read "price unknown" and rank below dollar items, the Cache hero sentence is two lines, and only recommendation 1 shows on each page with the rest behind "More recommendations". Rubric: all items pass (bottom line, ranked recommendations with action, paragraph length, number budget on Home, Savings, Cache and Sessions, tooltips, realised vs estimated, header, contrast, units). Remaining POLISH, non-blocking:
|
|
Review of 458eee7 (superseded by the re-review below). Fresh worktree, nice 19. Verified
Findings
Approving on top of #445. Labelled ready-to-merge. |
|
Test result on the final build (commit "tools page within the number budget; Saved/Estimated badges"):
|
…faults, billed-elsewhere); fixture writer for demo databases Signed-off-by: Osher-Elhadad <[email protected]>
…ext, sessions) Signed-off-by: Osher-Elhadad <[email protected]>
d061eaf to
db0cd5c
Compare
|
Re-check after the force-push: Cache page, fold and full page. Still PASS. Hero, one recommendation, the input chart with legend and the collapsed "Why turns missed the cache" read cleanly, and the page is shorter. My earlier comments on this PR do not describe the removed section. One POLISH note: the keep-alive card badge now reads "Estimated", the same word as the green saved figure on other pages. The dashed amber card still keeps them visually apart, but "Could save" was clearer; consider restoring it. |
…he new home Signed-off-by: Osher-Elhadad <[email protected]>
|
Answers to the review points. Golden files (5, commit "test(dash): regenerate golden files after merging main"), by cause:
Links to Serial full-suite result follows when the run finishes. |
|
Re-review of db0cd5c (force-pushed): the campaign slot, its sample data and screenshots are gone (grep of dash/ finds only the existing strategy-campaign code), the golden regeneration is its own commit (b8e30ac), and the old bookmarks redirect to /dashboard/index.html. vet clean; V2 and served-UI tests pass; the full ./dash run showed only SQLITE_BUSY failures under host load 35-45 (different tests each run; TestGoldenEndpoints fails the same way on origin/main). Attribution clean. My earlier findings are resolved. Keeping ready-to-merge; merge #445 first. |
Redesigns the dashboard home as five pages: Home, Savings, Cache, Tools & context, Sessions. The previous 17-view dashboard stays at
/dashboard/index.html(linked from the footer) for settings, requests and admin.Stacked on #445: the pages read the same endpoints, and a cold 30-day read of
/api/toolscan still take about a minute on a 3.6 GB database, so the pages draw the fast parts first and retry the slow one. This branch also merges current main into #445's branch. The 5 golden files that merge moved (keep-alive defaults from #444, the billed-elsewhere change) are regenerated in their own commit,test(dash): regenerate golden files after merging main, so they can be reviewed apart from the feature. Merge #445 first and this reduces to the dashboard files.What changed
/api/sessions?sort=costreturns the costliest sessions first./dashboard/#/savings/usageopens the classic dashboard;#home,#savings,#cache,#tools,#sessionsopen the new pages./dashboard/index.htmlis unchanged.dash/v2.test.mjs(models, ranking, bookmarks, filler-word check), run fromTestV2Models;TestServedUIVersionsEveryAssetItReferencesupdated for the second document.Before and after (synthetic fixture data, 1280 px)
Dark and phone shots of every page:
https://raw.githubusercontent.com/rossoctl/context-guru/dashboard-v2-assets/after/(<page>-<light|dark>-<desktop|phone>.png).Checks
No horizontal scroll at 390 px on any page, light or dark. Numbers above the fold: Home 5, Cache 5, Tools 4 (priced fixture shows fewer), Savings 6, Sessions 5. The full
go test ./dashpassed once (302 s) on an earlier build; on the final build under heavy host load seven unrelated tests hit SQLITE_BUSY, and they pass when run alone with the dashboard tests. A full run on a quiet host is still pending.