← Back to Pull requests

feat(presto): add --cache-mode for reproducible cold/hot/lukewarm benchmark runs #419

Closed
unknown closed this pull request without merging on Sep 10, 2026 02:21 UTC
View on GitHub
unknown unknown commented on Sep 08, 2026 04:09 UTC
Author

What

Adds --cache-mode {lukewarm,hot,cold} to the Presto TPC-H/TPC-DS pytest
benchmark harness (run_benchmark.sh), so cache-reset behavior for cold-IO
benchmarking is explicit and correct, instead of an accidental side effect
of a single session-start OS-cache drop.

Why

The harness reported a Lukewarm(ms) column (iteration 0's raw time) next
to Hot(ms) stats (iterations 1..N-1), but the only automatic cache reset
was a single OS page-cache drop at the very start of the whole pytest
session — presto-native's own Velox memory/SSD cache and the Hive
connector's file-handle cache were never cleared at all. So "Lukewarm" was
only meaningfully cold for the very first query of a run; every later
query's "Lukewarm" number silently rode on whatever cache warmth earlier
queries left behind — not comparable across queries, query order, or runs.

The modes

Adapted from @kjmph's c5a43f9, which contributed the cold-once shape, the idle-cluster check, exact success-body matching, and concurrent clears.

| Mode | Reset schedule | What gets reported |
|---|---|---|
| off (default) | Legacy behavior: OS page-cache drop once, no worker cache clearing. The only mode Java workers support. | Lukewarm(ms) + Hot(ms) — unchanged from today |
| lukewarm | Full reset once, before the first measured query. | Lukewarm(ms) + Hot(ms) |
| cold-once | Full reset before each query's iteration group. | Cold(ms) (iteration 0) + Hot(ms) (the rest) |
| cold | Full reset before every iteration. | Cold(ms) aggregates only |
| hot | No resets. First --warmup-iterations prime the cache. | Hot(ms) aggregates only — warm-ups never reported |

                    Q1 iter0    Q1 iter1    Q1 iter2    Q2 iter0    Q2 iter1
off/lukewarm  reset─┬───────────────────────────────────────────────────────▶
                    └─ once per run

cold-once     reset─┬─────────────────────▶ reset─┬─────────────────────────▶
                    └ Cold   └ Hot  └ Hot         └ Cold   └ Hot

cold          reset─┼─ reset─┼─ reset─┼─ reset─┼─ reset─┼─▶
                    └ Cold   └ Cold   └ Cold   └ Cold   └ Cold

hot           ──[ warm-up ][ measured ][ measured ]─────────────────────────▶
                 not reported    └ Hot      └ Hot

Cache clearing hits presto-native's /v1/operation/{connector,server}/clearCache
REST endpoints (GET, per PrestoServer.cpp's registerGet — not POST, which
404s) on every worker discovered via the coordinator's /v1/node, concurrently,
followed by the OS page-cache drop.

Resets fail closed. The cluster must be idle before and after
(AsyncDataCache::clear() keeps pinned entries, so clearing mid-query is only
partly cold), every worker must be cleared, and responses are matched against the
exact success body — the endpoint answers 200 with No memory cache set on
server
for no-ops, so trusting the status code reports warm numbers as cold.

A tier that simply isn't configured is reported, not failed: this repo's GPU
worker ships without an AsyncDataCache, so cold modes there control the
file-handle and OS page caches only. The run metadata records the layers actually
cleared, so it can't claim a reset that never happened.

Known limitation: drop_cache() writes /proc/sys/vm/drop_caches on the host
running pytest only. That covers workers sharing that kernel (the single-node
Docker setup this was tested on), but does nothing for remote workers — so cold
numbers from a multi-node cluster are not truly cold. A real per-worker drop would
be a follow-up.

New flags

  • --cache-mode {off,lukewarm,cold-once,cold,hot} (default off)

  • --warmup-iterations N (default 1) — leading iterations per query that prime the cache and are excluded from the aggregate stats. Validated at startup: must be >= 0 and < --iterations.

  • --connector-id ID (default hive) — the catalog to clear. The connector type is always hive: native's clearConnectorCache only implements name == "hive" and VELOX_USER_FAILs on anything else.
  • Compatibility

  • The default is now off, which is behaviorally identical to today: OS page-cache drop once, no worker clearing, same reported columns, no Cache Mode: line. Existing baselines and Java clusters are unaffected.

  • Opting into any other mode changes timings by design (they clear caches the old code never touched). lukewarm/cold-once/cold require native workers; the run fails fast with a clear message on presto-java.

  • Cache Mode: / cache_mode / cache_reset_layers appear in the report and JSON context only for non-off modes (post_results.py filters context to known fields, so the extra keys are ignored there).

  • spark_gluten never registers --cache-mode, so its report stays byte-identical.
  • Testing

  • common/testing/cache_mode_reporting_test.py (new, 16 cases): header/stat shape invariants across all modes and iteration counts, per-mode column expectations, the spark_gluten unregistered---cache-mode fallback, and degenerate inputs (failed queries, --warmup-iterations >= --iterations). Matches the existing *_test.py convention in common/testing/; like its siblings there it is run manually, not by CI.

  • Live runs against a presto-native GPU cluster (TPC-H SF10) for all three modes: reset cadence (1 reset for lukewarm, 0 for hot, one-per-iteration for cold), successful worker REST calls, and correct per-mode report columns.

  • Failure path verified live with a bogus --connector-id: the run now aborts with a RuntimeError and reports NULL instead of printing plausible-looking Cold(ms) numbers from caches that were never cleared.

  • presto/testing/cache_reset_test.py (new, 3 cases): all-workers-cleared succeeds and strips the /v1/status suffix, partial clear raises, no-nodes raises.
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: patdevinwilson Review duration: 2771m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.52) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #419"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.5% · Safe to merge
    22.5%