Skip to content

clickhouse-web: drop the filesystem cache before the cold try, not every try - #1092

Merged
alexey-milovidov merged 10 commits into
mainfrom
clickhouse-web-cold-only-cache-drop
Jul 27, 2026
Merged

clickhouse-web: drop the filesystem cache before the cold try, not every try#1092
alexey-milovidov merged 10 commits into
mainfrom
clickhouse-web-cold-only-cache-drop

Conversation

@alexey-milovidov

Copy link
Copy Markdown
Member

The problem

clickhouse-web/query ran SYSTEM DROP FILESYSTEM CACHE before every try, so all three tries re-fetched from S3 and "hot" was never hot. Since the 2026-05-07 refactor (1f352ad) hot has tracked cold and the gap never closed:

machine hot, 2026-05-01 hot, 2026-05-09 onwards
c6a.metal 7.5 s 22.2 s
c6a.2xlarge 47 s 105 s
c8g.metal-48xl 3.8 s 19.7 s

It also contradicts the design of the entry itself: ./install bind-mounts tmpfs onto the cache directory and create.sql wraps the web disk in disk(type = cache) precisely so repeat reads stay local.

And it is what turned the eu-central-1 → us-east-1 move (#1091) from a latency penalty into a 30x one: with every try cold, every try paid the transatlantic round trips.

The change

Move the drop into ./flush-caches, the hook d8d65e0 added for the datalake entries. The harness calls it once per query, before the cold try, so try 1 is honestly cold and tries 2–3 measure the engine rather than the network.

It has to delete the files rather than issue SYSTEM DROP FILESYSTEM CACHE: bench_flush_caches runs between ./stop and ./start, with no server to talk to. Two details follow from that — the cache is in tmpfs, which drop_caches does not evict, and the tmpfs is bind-mounted onto the cache directory, so the script removes the contents and leaves the mount point in place.

Testing

Measured against the real web disk, one query three times, cache in tmpfs:

cold 7.415s, hot 0.524s, hot 0.530s      (14x)
flush -> 332M cache emptied, directory and mount point intact
cold 7.496s, hot 0.530s                  (cold is honestly cold again)

So the cold number stays honest and the hot number starts measuring what it is supposed to.

Not covered: the sudo path in flush-caches — this dev box has no passwordless sudo. It matches existing usage in bench_flush_caches (echo 3 | sudo tee /proc/sys/vm/drop_caches) and ./install (sudo mount --bind), both of which already rely on it on the runners.

Expect clickhouse-web hot sums to drop back toward their pre-2026-05-09 levels once this lands. Independent of #1091, but the two compound: that PR removes the transatlantic round trips, this one stops paying them three times per query.

🤖 Generated with Claude Code

…ery try

./query ran SYSTEM DROP FILESYSTEM CACHE before every try, so all three tries
re-fetched from S3 and "hot" was never hot. Since the 2026-05-07 refactor
(1f352ad) hot has tracked cold: on c6a.metal 7.5s -> 22.2s, on c6a.2xlarge
47s -> 105s, and the gap never closed.

This also contradicts the design of the entry itself: ./install bind-mounts
tmpfs onto the cache directory and create.sql wraps the web disk in
disk(type = cache) precisely so repeat reads stay local.

Move the drop into ./flush-caches, the hook d8d65e0 added for the datalake
entries. The harness calls it once per query, before the cold try, so try 1
is honestly cold and tries 2-3 measure the engine rather than the network.

It has to delete the files rather than issue SYSTEM DROP FILESYSTEM CACHE:
bench_flush_caches runs between ./stop and ./start, with no server to talk
to. The cache is in tmpfs, which drop_caches does not evict, and the tmpfs is
bind-mounted onto the cache directory, so remove the contents and leave the
mount point in place.

Measured against the real web disk, one query three times, cache in tmpfs:

  cold 7.415s, hot 0.524s, hot 0.530s      (14x)
  flush -> 332M cache emptied, directory and mount point intact
  cold 7.496s, hot 0.530s                  (cold is honestly cold again)

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Results for clickhouse-web are ready for: c6a.4xlarge, c6a.metal, c7a.metal-48xl, c8g.4xlarge, c8g.metal-48xl.
The result files are committed as b29c8c0.

Logs:

@github-actions

Copy link
Copy Markdown
Contributor

Results for clickhouse-web are ready for: c6a.2xlarge.
The result files are committed as e5198f4.

Logs:

@github-actions

Copy link
Copy Markdown
Contributor

Results for clickhouse-web are ready for: c6a.xlarge.
The result files are committed as 21d35a5.

Logs:

@github-actions

Copy link
Copy Markdown
Contributor

Results for clickhouse-web are ready for: t3a.small.
The result files are committed as 3727a63.

Logs:

@github-actions

Copy link
Copy Markdown
Contributor

Results for clickhouse-web are ready for: c6a.large.
The result files are committed as 2c17ef5.

Logs:

Take main's clickhouse-web/results/20260726/ files on both sides of the
add/add conflict, dropping the ones the PR's own benchmark runs committed.

Those runs (02:41-11:33 UTC) cloned this branch, which did not yet contain
c6b4951 "Read the dataset from the copy in this machine's region", so every
cold try still crossed the Atlantic: 894s cold on c6a.metal against 31s for
the same-region run on main, and on the smaller machines the tmpfs cache is
too small to hold the working set, so hot paid the round trips too (c6a.large
hot 8156s vs 513s). The hot/cold split this PR is about was visible in them
(c7a.metal-48xl hot 8.8s vs 20.7s), but the absolute numbers measured the
network, not the change.

With the region fix now merged in, the push re-triggers the PR benchmark and
the rerun measures the entry as it will actually run.
…6a.metal, c6a.xlarge, c7a.metal-48xl, c8g.4xlarge, c8g.metal-48xl)
@github-actions

Copy link
Copy Markdown
Contributor

Results for clickhouse-web are ready for: c6a.2xlarge, c6a.4xlarge, c6a.metal, c6a.xlarge, c7a.metal-48xl, c8g.4xlarge, c8g.metal-48xl.
The result files are committed as d6a7bd4.

Logs:

@github-actions

Copy link
Copy Markdown
Contributor

Results for clickhouse-web are ready for: c6a.large.
The result files are committed as 9171cbd.

Logs:

@github-actions

Copy link
Copy Markdown
Contributor

Results for clickhouse-web are ready for: t3a.small.
The result files are committed as 8ba98b6.

Logs:

@alexey-milovidov
alexey-milovidov merged commit 6245cd5 into main Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

machine:all PR benchmark on every machine type

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant