Testing the Performance of ClickHouse
ClickHouse catches performance regressions in CI by running the reference and patched servers side by side on the same machine and alternating about 3000 end-to-end test queries between them. This cancels out environmental systematic errors. A non-parametric bootstrap on the difference of median run times yields a noise threshold T, and a change is flagged only when it exceeds both T and 5%. Queries with T of 10% or more are marked unstable. Regressions are investigated with the built-in sampling profiler (system.trace_log), differential flamegraphs, ProfileEvents and hardware counters, while historical results stored in ClickHouse help locate when a change was introduced. Keeping false positives low matters more than producing a green check, and many test queries turned out to measure nothing meaningful.
Related posts
- How well is ClickHouse tested? A detailed view of increasing our own coverage
ClickHouse mediumAdept
ClickHouse's ~2.6M-line C++ codebase reaches 91.8% line, 81.0% branch and 91.8% function coverage, measured with Clang source-based coverage across 23 CI shards every 3 hours and published at coverage.clickhouse.com. Basic blocks, edges and the two Clang instrumentation modes (SanitizerCoverage vs. source-based) are explained, along with the profraw → profdata → llvm-cov pipeline and the continuous-mode trick that keeps profiles from servers that tests kill on purpose. An AI agent in ClickGap finds stable zero-hit gaps and writes guarded, flakiness-checked tests, merging 16 PRs that cover about 5,600 new lines. Per-test line coverage stored in CIDB (about 36B rows) drives test selection, so expensive sanitizer jobs run only the tests that touch changed code.
- ClickHouse Over the Years with Benchmarks
ClickHouse mediumAdept
Every ClickHouse release from 1.1.54378 (April 2018) onward was installed on one AWS m5.8xlarge and run through the Star Schema Benchmark, the Brown University benchmark and ClickHouse's own hits benchmark to see how performance changed over time. The setup pulls 328 versions from the old Yandex and new packages.clickhouse.com apt repositories, then exports the hits dataset to CSV with clickhouse-local. Getting the data into old versions meant workarounds for missing features: dropping index_granularity_bytes, replacing LowCardinality with String and IPv4 with String, and splitting DateTime64 into DateTime plus a milliseconds column. Star Schema Benchmark results come with a caveat, since its random value distribution does not resemble real datasets.
- Building ClickCannon - a tool for benchmarking ClickHouse
ClickHouse mediumAdept
ClickCannon is an open-source Go tool for benchmarking ClickHouse insert and query workloads, built to produce hardware sizing recommendations for ClickStack observability deployments. It replays real OpenTelemetry data stored as ZSTD-compressed Native format at a precisely controlled uncompressed throughput. A feedback-loop rate limiter combines a sliding window with a token-bucket gate. Independently scaled disk and insert worker pools exchange reusable ch-go blocks through Go channels, which avoids allocations. Block and connection retirement kept memory flat across 30-day runs, and configurable workflows with think times, time ranges and latency percentile targets simulate concurrent users querying while data arrives.
- Decorating a Christmas Tree With the Help Of Flaky Tests
ClickHouse mediumAdept
ClickHouse treats flaky tests as bugs to investigate rather than noise to mute or retry, and deliberately makes tests flakier to surface hidden issues. Its practices include randomizing the environment on every run, running new tests 100 times before merge, using new tests as a fuzzing corpus, injecting random sleeps and core switches around mutex operations, and running in parallel on slow machines. Results of all test runs, nearly 1.8 billion records and 5–9 million runs per day, are stored in ClickHouse itself. A 561-day by 3772-test pass/fail pixel map of the stateless functional tests, rendered by JavaScript querying ClickHouse directly, forms a 'Christmas tree' where horizontal red lines mark flaky tests and vertical red lines mark days master was broken.
- Fuzzing ClickHouse
ClickHouse mediumAdept
ClickHouse's AST-based query fuzzer takes SQL queries from the regression test suite, parses them, and randomly mutates the AST. It swaps in bad numeric values such as NaN and integer limits, perturbs strings and arrays, and splices function arguments, expressions and tables from other test queries. The core is about 700 lines of C++ and has found more than 200 bugs, including segfaults and logic errors. Much of that comes from pairing it with assertions, a distinct LOGICAL_ERROR exception for internal bugs, and clang sanitizers. In CI it weights permutations toward new tests in pull requests and needs settings constraints, since it once disabled its own execution-time limit.