Repository navigation
Conversation
- `GeneratedRunner` (generated mode) and `LogRunner` (replay and setup-nodes-collection modes) replace the two-mode `Runner`. - `--input-request-log` now always selects replay mode, taking precedence over the config's `generator` section instead of being silently ignored. - `BenchmarkContext` is renamed to `NodesSetup` and moved to its own file; the setup tree walk now emits `Create` requests into a callback, which `StorageRunner` reuses instead of a hand-rolled tree walk. - Shared helpers are extracted to `RunnerCommon`: `getOption` (command line > config > default), `ConnectionFactory`, `BenchmarkOutput`. `StorageRunner` uses `getOption` too. - Generators are initialized sequentially up front in `GeneratedRunner`, removing `generator_init_barrier`. - SIGINT is now blocked process-wide at program entry, so Ctrl+C is always seen by the `InterruptListener` polls instead of sometimes terminating the process via a global-thread-pool thread that didn't block it. `StorageRunner` and `LogRunner` now also shut down gracefully on SIGINT and print the final report. Co-Authored-By: Claude Fable 5 <[email protected]>
Previously, when a write multi failed, all sub-request callbacks received nullptr, losing the per-op error codes. Now each sub-op callback receives its own sub-response. Sub-ops of a failed transaction whose own check passed (reported as `ZOK` even though nothing was applied) receive a synthesized response with `ZRUNTIMEINCONSISTENCY` so they are not taken for applied ones. This is preparation for dynamic path sets, where Create/Remove callbacks need to distinguish "node is really gone" (`ZNONODE`) from "operation was not applied" to keep the set contents correct. Co-Authored-By: Claude Fable 5 <[email protected]>
Generators used to be constructed per worker thread, each re-parsing the
config and building its own copy of every path list (including the results
of `children_of` listings), multiplying memory usage by the concurrency.
Now a single `Generator` is built once on the main thread and shared; the
only per-call mutable state is the rng, passed in via `GenerateContext`
(`{rng, thread_idx}`) by each thread.
This also deletes the `setSeed`/`setSeedImpl` cascade with its per-component
seed offsets: with a fixed `generator.seed`, each thread's rng is simply
seeded with `seed + thread_idx`. `children_of` parents are now listed once
instead of once per thread, and the workload description is printed once.
Co-Authored-By: Claude Fable 5 <[email protected]>
…red sets Each `PathGetter` now draws from exactly one `PathSet` — a literal path list, one `tagged` reference, or one `children_of` reference (mixing sources in one `path` is no longer supported). Sets are registered in `NodesSetup` while parsing the setup and generator configs, so generators referencing the same tag or parent share one in-memory copy of the paths instead of each generator merging its own copy. The initialization sequence is reordered accordingly: parse generators (registering sets), create the setup tree (populating tag sets on the fly), resolve `children_of` sets by listing each distinct parent once, then validate. Tag sets nobody reads are not populated at all. The setup tree now stores `repeat` counts unexpanded, mirroring the config; instances are expanded during the creation traversal (root names are recorded for cleanup). For repeated subtrees this removes the per-instance child pointers from memory. Co-Authored-By: Claude Fable 5 <[email protected]>
Path sets that a `create` generator outputs to are now dynamic: created nodes are added to the set on success and `remove_factor` removes take nodes out of it (before sending; put back unless the outcome shows the node is gone). The output set is the explicit `tag` from the create generator's config, the `children_of` set of its fixed parent, or an anonymous set when only `remove_factor` needs one; it is only populated if some generator reads it. This allows pointing e.g. a `set` generator at nodes produced by a `create` generator, and replaces the old per-generator `paths_created` bookkeeping (along with the name uniqueness enforcement, which never worked across threads anyway). Dynamic sets are sharded by worker thread, so each thread reads and updates only its own shard (shard mutexes still guard against response callbacks running on client/commit threads). Since a dynamic set may lag behind the real state, requests drawing paths from one report `ZNONODE`/ `ZNODEEXISTS` results as a separate `ignored_errors` counter instead of failing, even without `continue_on_errors`. Generators whose input set is currently empty decline, and another generator is picked instead. Co-Authored-By: Claude Fable 5 <[email protected]>
`keep_count: <n>` (or `auto`) on a create generator keeps its output path set at a roughly constant size, so the dataset doesn't drift over a long benchmark: each operation chooses between Create and Remove with a probability based on the current shard size — 0.5 at the target, approaching 0/1 as the size deviates (logistic curve, 5% of the target as the scale). The last path in a shard is never removed, so a set can only be empty if it started empty. `auto` snapshots the size at the end of setup as the target. Mutually exclusive with `remove_factor`. Sizes and targets of dynamic path sets are now printed with each periodic report in both the generated and storage modes. Co-Authored-By: Claude Fable 5 <[email protected]>
Two forms: - `remove_recursive: true` (with `remove_nodes_limit`) on a create generator makes its `remove_factor`/`keep_count` removes use `RemoveRecursive` requests, removing whole subtrees. Needed when other generators create children under the removable nodes, where a plain `Remove` would fail with `ZNOTEMPTY`. - a standalone `remove_recursive` request generator that recursively removes random nodes drawn from a path set (making it dynamic). Only the removed root is taken out of the set; descendants tracked in other sets go stale and surface as ignored errors. Since it competes with creates purely by weights, the node count random-walks; `keep_count` with `remove_recursive: true` is the count-stable alternative. Example workload this enables: one create maintains ~N tagged nodes (removing recursively), a second create makes children under the tagged nodes, gets read them — total node count stays stable in steady state. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Workflow [PR], commit [1cb4b19] Summary: ✅
AI ReviewSummaryThis PR splits Findings❌ Blockers
💡 Nits
Final Verdict
LLVM Coverage ReportMeasured on commit 1cb4b19.
Changed lines: Changed C/C++ lines covered: 621/1543 (40.25%) · Uncovered code |
| { | ||
| size_t num_shards = set->shards.size(); | ||
| size_t total_target = *set->keep_count == 0 ? set->totalSize() : *set->keep_count; | ||
| set->target_count_per_shard = std::max<size_t>(1, total_target / num_shards); |
There was a problem hiding this comment.
keep_count is a total target, but this turns it into max(1, total_target / num_shards) per shard. With concurrency = 32, keep_count: 1 (or keep_count: auto on an initially empty set) becomes a target of 32 live nodes, and any non-multiple of concurrency is silently rounded down. That breaks the new contract that keep_count keeps the set "about the same as on startup". This needs a global target, or at least validation that the requested total can be represented by the sharded algorithm.
| /// Resolve the set that tracks the created nodes: an explicit output `tag`, | ||
| /// the `children_of` set of a fixed parent, or an anonymous set if the | ||
| /// removes need one. | ||
| auto fixed_parent = parent_path.pathSet()->singleStagedPath(); |
There was a problem hiding this comment.
singleStagedPath only covers the one-parent literal case. If a create uses path: ["/a", "/b"] together with tag: kids, another generator can still read children_of: "/a" and validatePathSets never rejects it. New children under /a then go only into the tag-backed dynamic set while the children_of set stays frozen at startup, which recreates the stale-path bug this PR is trying to remove. We need to register/check conflicts for every fixed parent in the source set, or reject tag + multi-parent sources outright.
|
|
||
| return request_from_log; | ||
| } | ||
| default: |
There was a problem hiding this comment.
The PR adds remove_recursive to generated workloads, but replay still has no Coordination::OpNum::RemoveRecursive branch here. Any request log that contains those operations now falls through to Unsupported operation ..., so the new workload cannot be replayed or fed into --setup-nodes-snapshot-path. Please deserialize RemoveRecursive here too, and extend SetupNodeCollector once that request can reach replay mode.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 0/1529 (0.00%) · Uncovered code |
A `PathGetter` can now reference several `tagged` sets; paths are drawn uniformly from their union by first picking a set with probability proportional to its size and then a path within it. Sizes are read from a new per-shard atomic `cached_size` (relaxed loads) instead of locking the shard mutex, so the weights can lag slightly behind concurrent updates of dynamic sets, which is acceptable. `PathGetter::takePath` was unused and is removed. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Literal paths, `children_of` and `tagged` entries can be combined freely in one `path` section, as on master. Sets are weighted by an estimate of their total size: the calling thread's shard size scaled by the number of shards, so a per-thread sharded dynamic set is not underweighted against an unsharded one. Co-Authored-By: Claude Fable 5.1 <[email protected]>
| if (output_set->keep_count && *output_set->keep_count != keep_count) | ||
| throw DB::Exception( | ||
| DB::ErrorCodes::BAD_ARGUMENTS, "Multiple create generators set different keep_count for {} (key '{}')", output_set->name, key); | ||
| output_set->keep_count = keep_count; |
There was a problem hiding this comment.
This only rejects conflicting keep_count values. Another create can still write the same output_set with no balancing or with remove_factor, and at runtime only generators whose own config had keep_count consult the target (generateImpl looks at the member, not output_set->keep_count). The set-level target reported for the shared tag / children_of set then stops being enforceable. Please either reject mixed producer policies for one PathSet, or drive every producer from a set-level balance policy.
| return; | ||
| ops.push_back(std::move(request_with_callbacks.request)); | ||
| inner_callbacks.push_back(std::move(request_with_callbacks.callback)); | ||
| ignore_missing_nodes |= request_with_callbacks.ignore_missing_nodes; |
There was a problem hiding this comment.
ignore_missing_nodes is a per-subrequest property, but multi collapses it to one bool here. Once any nested request draws from a dynamic PathSet, GeneratedRunner treats a top-level ZNONODE/ZNODEEXISTS as an ignored dynamic-set miss for the whole transaction, so the same errors from fixed-path siblings get hidden as well. Please keep this flag per subrequest and classify ignored errors from the actual subresponses instead of the aggregate MultiResponse::error.
Build profile diff (arm_release)Comparing Binary sizes
The official master build is compiled with Object file sizes
|
| Object file | Master | PR | Δ |
|---|---|---|---|
programs/keeper-bench/CMakeFiles/clickhouse-keeper-bench-lib.dir/LogRunner.cpp.o |
new | 429.78 KiB | +429.78 KiB |
programs/keeper-bench/CMakeFiles/clickhouse-keeper-bench-lib.dir/NodesSetup.cpp.o |
new | 278.89 KiB | +278.89 KiB |
programs/keeper-bench/CMakeFiles/clickhouse-keeper-bench-lib.dir/GeneratedRunner.cpp.o |
new | 221.44 KiB | +221.44 KiB |
programs/keeper-bench/CMakeFiles/clickhouse-keeper-bench-lib.dir/RunnerCommon.cpp.o |
new | 98.83 KiB | +98.83 KiB |
programs/keeper-bench/CMakeFiles/clickhouse-keeper-bench-lib.dir/PathSet.cpp.o |
new | 45.27 KiB | +45.27 KiB |
programs/keeper-bench/CMakeFiles/clickhouse-keeper-bench-lib.dir/Generator.cpp.o |
338.40 KiB | 316.80 KiB | -21.61 KiB (-6.38%) |
programs/keeper-bench/CMakeFiles/clickhouse-keeper-bench-lib.dir/KeeperBench.cpp.o |
243.68 KiB | 260.88 KiB | +17.20 KiB (+7.06%) |
717 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.
Compile time of recompiled translation units
15 translation units recompiled, 49 s compile time in total, 10 of them have a recent master baseline.
Translation units without a recent master baseline:
programs/keeper-bench/LogRunner.cpp: 8.3 sprograms/keeper-bench/GeneratedRunner.cpp: 5.5 sprograms/keeper-bench/NodesSetup.cpp: 5.3 s
|
|
||
| auto callback = [&, candidate = std::move(node_candidate)](const Coordination::Response * response) mutable | ||
| ZooKeeperRequestWithCallbacks result{.request = request}; | ||
| result.ignore_missing_nodes = parent_path.isDynamic(); |
There was a problem hiding this comment.
parent_path.isDynamic() only tells us that some source in the PathGetter is dynamic. After path started allowing mixed literal/children_of/tagged sources again, that is too coarse for error classification: a create that actually picked a fixed parent from the literal half of the union will still ignore ZNONODE, and any create under a dynamic parent will also ignore ZNODEEXISTS even though that error is about the generated child-name collision, not stale parent membership. The same path.isDynamic() pattern below does the same thing for set/get/list. Please return the chosen-set metadata from PathGetter::getPath and decide ignored errors from that specific source; for create, this should probably only forgive ZNONODE.
|
|
||
| path_picker = std::uniform_int_distribution<size_t>(0, paths.size() - 1); | ||
| initialized = true; | ||
| return chosen->samplePath(ctx.rng, ctx.thread_idx); |
There was a problem hiding this comment.
getPath assumes a nonzero approximateSize guarantees that samplePath will succeed, but dynamic sets only expose that size through a relaxed cached_size load. If path is a union of a dynamic set and another non-empty source, a remove callback can empty the chosen dynamic shard after the size read and before samplePath locks it. In that case this returns nullopt even though the union still has candidates, so the generator can decline or even trip the "all generators declined" exception while valid paths remain. Please retry with the remaining sets when samplePath comes back empty, or choose only from sets proven non-empty under the relevant lock.
| try | ||
| { | ||
| request_with_callbacks = generator.generate(); | ||
| request_with_callbacks = generator->generate(ctx); |
There was a problem hiding this comment.
After switching storage mode to generator->generate(ctx), this runner now receives ignore_missing_nodes for dynamic-set requests but never carries it forward. generatorThread enqueues only the request and callback, and drain_reads / commitThread later count every Keeper response as a committed op without looking at response->error. A ZNONODE / ZNODEEXISTS from a dynamic set in --storage mode is therefore silently treated as success instead of an ignored_error, and fixed-path Keeper errors are still invisible too. Please propagate the flag through QueueItem and classify responses the same way GeneratedRunner does.
| catch (...) | ||
| { | ||
| DB::tryLogCurrentException("Unexpected exception in bench thread"); | ||
| std::abort(); |
There was a problem hiding this comment.
handle_request_exception intentionally rethrows when continue_on_error is false so the benchmark stops on the first Keeper error. Wrapping thread in a catch-all that immediately calls std::abort() turns that normal stop path into a hard process abort: a single ZNONODE/ZBADVERSION now skips the final report and prevents GeneratedRunner's destructor from cleaning the setup roots.
The local ThreadPool already catches job exceptions and rethrows them from wait(), so this wrapper should not abort on ordinary request failures.
| create: | ||
| path: "/bench/creates" # PathGetter | ||
| path: "/bench/creates" # PathGetter (parent for created nodes) | ||
| name_length: 10 # IntegerGetter, default: 5 |
There was a problem hiding this comment.
This create section still describes the old remove_factor-only behavior. The PR adds keep_count, remove_recursive, and remove_nodes_limit, but none of them are documented here, and the inline default for name_length is now wrong: Generator.cpp defaults it to 10, not 5.
Since these knobs change how dynamic PathSets are maintained and are part of the user-facing workload contract, the README should document them in this section and show a minimal example.
|
@al13n321 @antonio2368 — ClickGap found the following in this PR:
Close anything that's wrong or already addressed. |
Changelog category (leave one):
This PR is stacked on top of #108583
creategenerators at runtime. Things likechildren_ofandtaggedused an immutable list of paths taken at startup, so you couldn't e.g. dogetorseton nodes produced bycreateduring the bench. Now you can: addtagto thecreateand usetaggedon other generators to refer to the nodes. keeper-bench will keep track of the set of existing paths for the tag. The same tag may appear insetupand increates.create'sremove_factorseems like a wrong approach: the number of nodes would continuously grow or drift during the test, so results from test runs wouldn't be meaningfully comparable because they had different number of nodes. Addedkeep_count- use it instead ofremove_factorto keep number of nodes (with the given tag) approximately constant (doing Remove more often if there are too many and doing Create more often if there are too few). Usekeep_count: autoto keep the number of nodes about the same as on startup (aftersetup).createcan now do RemoveRecursive (useremove_recursiveflag in config). So you can have acreategenerator for tag A withremove_recursiveand anothercreategenerator for children of tag A (with no output tag), to do nontrivial RemoveRecursive requests continuously.The first 6 commits can be reviewed separately one by one.
Workflow [PR]
Sync PR [sync-upstream/pr/111155]
Version info
26.9.1.1521(included in26.9and later)