Skip to content

Color the fastcache-cc stats report and add an HTML dashboard - #50

Merged
Yaraslaut merged 2 commits into
masterfrom
feature/fastcache-cc-stats-dashboard
Aug 18, 2026
Merged

Color the fastcache-cc stats report and add an HTML dashboard#50
Yaraslaut merged 2 commits into
masterfrom
feature/fastcache-cc-stats-dashboard

Conversation

@Yaraslaut

Copy link
Copy Markdown
Member

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

  • Colorized --show-stats: hits (green), misses/uncacheable (yellow), and unavailable/"CACHE NOT REACHED" (red), reusing the launcher's existing StdoutSupportsColor()/UsageColor seam — the same one --help already 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 from FormatReport'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's ScopedStateDir: its per-process counter collided across concurrent ctest -j-spawned processes, since catch_discover_tests runs each TEST_CASE as its own process and each one's counter restarts at 1. Folding the process id into the temp directory name fixes it — confirmed flaky on master before 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.

Yaraslau Tamashevich 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
Yaraslaut force-pushed the feature/fastcache-cc-stats-dashboard branch from eba06e9 to 1f1579c Compare August 18, 2026 11:49
@Yaraslaut
Yaraslaut merged commit 150894f into master Aug 18, 2026
19 checks passed
@Yaraslaut
Yaraslaut deleted the feature/fastcache-cc-stats-dashboard branch August 18, 2026 14:16
@christianparpart christianparpart added type/feature New capability, or a user-visible extension of one area/launcher apps/fastcache-cc/ - the compiler launcher and its cache key labels Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/launcher apps/fastcache-cc/ - the compiler launcher and its cache key type/feature New capability, or a user-visible extension of one

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants