Color the fastcache-cc stats report and add an HTML dashboard - #50
Merged
Conversation
added 2 commits
August 18, 2026 14:48
Stats.cpp/hpp: - Record gains timestampUnixSeconds (an 11th log column), so a later trend-over-time view has something to bucket by. Zero means "unknown" (pre-upgrade log lines or a caller that never set it) and is excluded from time-bucketed views rather than plotted as a false epoch-zero point. - ParseLog() is extracted from FormatReport's inline parsing loop, so the fold over decoded records is shared rather than duplicated -- the HTML renderer and a test both need the raw records, not just the formatted text. - FormatReport(cohortFilter, UsageColor) colors hits (green), misses/ uncacheable (yellow), and unavailable/"CACHE NOT REACHED" (red) when colored, reusing the existing StdoutSupportsColor()/UsageColor seam fastcache-cc already carries for --help -- no new capability-detection code needed. Plain output (the default; piped/redirected/NO_COLOR) stays byte-identical to before. - FormatHtmlReport() renders the same data as a self-contained HTML dashboard (inline CSS/JS, no network dependency, no third-party chart library): headline hit rate, per-outcome tallies, a hit-rate-over-time trend (bucketed by day from the new timestamp field), latency histograms as inline SVG bars, ranked fall-back reasons, a per-cohort comparison table, and the translation units that never hit. Record::hasPhaseColumns preserves FormatReport's existing tolerance for pre-upgrade log lines that predate the phase-breakdown columns: without it, folding a record with no recorded preprocess/cache split would push a false zero into those histograms instead of leaving them empty. Signed-off-by: Yaraslau Tamashevich <y.tamashevich@lastrada.net>
New Action::HtmlStats, a HtmlStatsOptionTable ("--cohort", "--out"),
and dispatch to FormatHtmlReport() in main.cpp -- one new row in the
existing data-driven flag table, per the project's CLI convention.
ParseStatsOptions() gains a baseAction parameter (defaulted to
ShowStats, preserving every existing call site) so the same table-
driven sub-option parser serves both --show-stats and --html-stats
without a second hand-written loop.
--html-stats writes the dashboard next to the statistics log by
default (DefaultHtmlReportPath()) or to --out's path, and prints where
it went. The existing --show-stats path also picks up color now that
FormatReport takes a UsageColor, decided from StdoutSupportsColor() at
the same call site --help already uses.
A distinct "HTML STATS OPTIONS" help section (rather than folding --out
into StatsOptions()) keeps --out from silently doing nothing after
--show-stats, which writes to stdout unconditionally.
Signed-off-by: Yaraslau Tamashevich <y.tamashevich@lastrada.net>
Yaraslaut
force-pushed
the
feature/fastcache-cc-stats-dashboard
branch
from
August 18, 2026 11:49
eba06e9 to
1f1579c
Compare
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.
fastcache-cc's --show-stats report is a good, information-dense summary, but it's plain ASCII text with nowhere to see trends over time, and there was no way to hand someone a shareable view of cache health. This adds color to the existing terminal report and a new --html-stats flag that renders the same data as a self-contained HTML dashboard.
Changes
--show-stats: hits (green), misses/uncacheable (yellow), and unavailable/"CACHE NOT REACHED" (red), reusing the launcher's existingStdoutSupportsColor()/UsageColorseam — the same one--helpalready uses. Plain output (piped, redirected,NO_COLOR) stays byte-identical to before.--html-stats [--out <path>] [--cohort <id>]: renders a self-contained HTML dashboard (inline CSS/JS, no network dependency, no third-party chart library) — headline hit rate, per-outcome tallies, a hit-rate-over-time trend, latency histograms as inline SVG bars, ranked fall-back reasons, a per-cohort comparison table, and the translation units that never hit. Writes next to the statistics log by default, or to--out's path.Record::timestampUnixSeconds: a new 11th log column so the trend chart has something to bucket by day. Pre-upgrade log lines simply have no timestamp and are excluded from the trend rather than plotted at a false "day zero".ParseLog(): extracted fromFormatReport's inline parsing loop so both renderers share one fold over the log instead of duplicating it.While building this I also found and fixed a real, reproducible test-isolation race in
Stats_test.cpp'sScopedStateDir: its per-process counter collided across concurrentctest -j-spawned processes, sincecatch_discover_testsruns eachTEST_CASEas its own process and each one's counter restarts at 1. Folding the process id into the temp directory name fixes it — confirmed flaky onmasterbefore this change, clean after.Separately, while testing this I found a stale-cache bug in fastcache-cc's direct mode (unrelated to this PR's changes) and filed it as #49.