Repository navigation
Conversation
|
Workflow [PR], commit [0d5e10a] Summary: ❌
AI ReviewSummaryThis PR refactors Missing context
Findings❌ Blockers
Tests
ClickHouse Rules
Final VerdictStatus: Minimum required actions:
|
It already wasn't, and also keeper-bench used to get stuck instead of quitting after the limit is reached. |
| info->clear(); | ||
| for (auto & t : threads) | ||
| t.thread_info.clear(); | ||
| requests_started = 0; |
There was a problem hiding this comment.
requests_started is reset while worker threads are still running and still doing fetch_add(1) unconditionally. Because warmup_complete is switched to true only after this reset, there is a window where warmup requests can increment the counter after reset and then be counted as measured requests.
This breaks the documented warmup semantics and can make iterations terminate early/non-deterministically.
Could we gate incrementing on warmup_complete (e.g. branch before fetch_add), or flip to a two-counter scheme (requests_started_total + measurement_start) so post-warmup accounting is race-free?
|
|
||
| try | ||
| { | ||
| for (size_t i = 0; i < concurrency; ++i) |
There was a problem hiding this comment.
runBenchmarkWithGenerator starts worker threads before resetting info->elapsed, total_watch, and start_timestamp_ms. With warmup_seconds = 0, workers can already generate and complete requests in that window, so those requests are counted in thread_info but excluded from elapsed/time-limit accounting. This biases throughput upward and can also make timelimit/iterations accounting inconsistent at startup.
Could you move the timer reset block before scheduling workers, or gate worker loops on a measurement_started flag that is flipped only after timers are reset?
| void Generator::startup(Coordination::ZooKeeper & zookeeper) | ||
| { | ||
| std::cerr << "---- Initializing generators ----" << std::endl; | ||
| if (thread_idx == 0) |
There was a problem hiding this comment.
With the per-thread generators, runs without generator.seed are no longer reproducible: every worker picks its own random seed, but only thread 0 logs one seed.
README.md still states that when seed is omitted, a random seed is generated and printed for reproducibility. After this change, that printed value is insufficient to replay the same workload across all threads.
Could we generate one base seed once (in Runner), log it, and derive each worker seed deterministically (e.g. base_seed + thread_idx) even when generator.seed is absent?
There was a problem hiding this comment.
this seed just seems PITA, we can remove it if you think there is no value in it.
| collect_request(slot); | ||
| return; | ||
| } | ||
| size_t iteration_idx = requests_started.fetch_add(1); |
There was a problem hiding this comment.
requests_started is incremented before the max_iterations guard, so this counter includes iterations that are never submitted/executed (iteration_idx >= max_iterations path). The final/periodic Requests executed: output can therefore exceed the configured limit and misreport benchmark results.
A minimal trace with max_iterations = 10:
- one worker does
iteration_idx = 10viafetch_add(counter becomes 11), - then immediately hits
iteration_idx >= max_iterations, setsshutdown = true, and skips submission, - final print reports at least
11"executed" requests although only10were started.
Could you either:
- reserve slots only when accepted (CAS loop / fetch-add rollback), or
- track two counters (
requests_reservedvsrequests_completed) and print the actually completed one?
|
You can merge anytime you think it's okay. |
|
I'm in CI hell again, all PRs are blocked on flaky tests, and I have to merge master into everything every day and hope to win the lottery :( |
LLVM Coverage Report
Changed lines: 0.00% (0/213) · Uncovered code |
|
Ooh, the |
|
@al13n321 it is broken! keeper-bench throws Root cause: commit The OLD version used a single shared Patch by claude which solves the problem: git diff --staged
diff --git a/programs/keeper-bench/Runner.cpp b/programs/keeper-bench/Runner.cpp
index 3b8470264dc..a23389f6a1e 100644
--- a/programs/keeper-bench/Runner.cpp
+++ b/programs/keeper-bench/Runner.cpp
@@ -257,6 +257,11 @@ void Runner::thread(std::vector<std::shared_ptr<Coordination::ZooKeeper>> zookee
auto generator = std::make_shared<Generator>();
generator->startup(*config_ptr, *zookeepers[0], thread_state.thread_idx);
+ /// Wait for all threads to finish initializing their generators before
+ /// any thread starts executing requests. This prevents early threads from
+ /// mutating the tree while late threads are still resolving `children_of` paths.
+ generator_init_barrier->arrive_and_wait();
+
/// Randomly choosing connection index
pcg64 rng(randomSeed());
std::uniform_int_distribution<size_t> distribution(0, zookeepers.size() - 1);
@@ -1212,6 +1217,10 @@ void Runner::runBenchmarkWithGenerator()
int64_t start_timestamp_ms = 0;
threads = std::vector<ThreadState>(concurrency);
+ /// All threads must finish generator initialization (which resolves
+ /// `children_of` paths) before any thread starts executing requests.
+ generator_init_barrier = std::make_unique<std::barrier<>>(concurrency);
+
try
{
for (size_t i = 0; i < concurrency; ++i)
diff --git a/programs/keeper-bench/Runner.h b/programs/keeper-bench/Runner.h
index 2579502a4ff..1a790848050 100644
--- a/programs/keeper-bench/Runner.h
+++ b/programs/keeper-bench/Runner.h
@@ -13,6 +13,7 @@
#include <Generator.h>
#include <Stats.h>
+#include <barrier>
#include <filesystem>
using Ports = std::vector<UInt16>;
@@ -138,6 +139,12 @@ private:
std::vector<ThreadState> threads;
+ /// Barrier so all threads finish generator initialization (which resolves
+ /// `children_of` paths via ZooKeeper listing) before any thread starts
+ /// executing requests. Without this, early threads mutate the tree while
+ /// late threads are still initializing, causing stale path caches.
+ std::unique_ptr<std::barrier<>> generator_init_barrier;
+
std::mutex mutex; // for writing to stdout
std::mutex connection_mutex;
|
|
Adding this fix to #101801 |
Example 2 in `SKILL.md` walked through "What changed in Keeper between 2026-04-01 and 2026-05-01?" and parenthetically said "none if 2026-04-01 → 2026-05-01; both bench changes were earlier". That was wrong — both bench-harness confounds documented in `references/known_confounds.md` (and elsewhere in `SKILL.md`) land **inside** the example window: - `ClickHouse#100670` "keeper-bench: go faster" — `2026-04-04` - `ClickHouse#101801` "keeper-bench: more features" — `2026-04-11` A user trusting the parenthetical would skip confound handling exactly when both confounds matter. The next line of the example already says to "always include the bench-harness confound notes from known_confounds.md if any of those PR dates fall in the window", so the parenthetical also self-contradicted. Replace the false claim with the correct list. The example now spells out both in-window confounds and what they affect. Addresses review comment ClickHouse#104118 (comment).
Captures the workflow used to validate Keeper PRs against the keeper-stress
Grafana dashboard (sourced from play.clickhouse.com / keeper_stress_tests).
Without this skill, every Keeper-stress validation question re-derives
methodology, data sources, and known confounds from scratch.
The skill bundles:
- 6 SQL queries for the staging tables (bench / prom rates / prom gauges /
mntr / container / pr_branches), with a {{TS_FILTER}} placeholder for
arbitrary date windows
- 7 Python scripts that join the staging files into per-PR + per-nightly
delta tables, cumulative window-vs-window gains, and PR-branch isolation
- rebuild.sh orchestrator that fetches data and runs the pipeline end-to-end
- 4 reference docs (methodology, known_confounds, metric_glossary,
slack_templates) carrying the hard-earned lessons:
* KeeperApproximateDataSize is the right Keeper memory metric, NOT
container_memory_bytes (cgroup includes page cache)
* ClickHouse#100670 keeper-bench:go-faster (bench harness PR, not Keeper) caused
the 2026-04-04 step in cgroup memory and bench-counted error rates
* ClickHouse#101801 keeper-bench:more-features caused the 2026-04-11 rocks-side
write-multi memory step
* Per-PR effects below ±5 % rps are below the dataset's noise floor
(typos PR ClickHouse#102739 measures at -5 % via PR-branch isolation)
* p95_cpu_cores is the right CPU metric, not max_cpu_cores
(which has counter discontinuities)
- 4 sample outputs (PERFORMANCE_GAINS.md, PR_PERF_TABLE.md, PR_PROGRESS.md,
INDEX.md) showing the expected deliverable formats
Triggers on terms like "keeper stress", "keeper PR", "keeper p99", "keeper
memory", "keeper validation", or any mention of the keeper-stress Grafana
dashboard.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Changelog category (leave one):
keeper-bench could do ~500K requests/s, which is less than what keeper can handle (for small reads). This PR gets rid of the pointless queue and the stats mutex. This takes it to 12M iterations/s, if keeper requests are replaced with no-op. That's comfortably more than the 1.2M requests/s that keeper can do before getting bottlenecked on ConcurrentBoundedQueue's mutex.
Version info
26.4.1.562