Repository navigation
Clear libfiu's fast-path flag when the last fail point is disabled - #129334
Conversation
The first `fiu_enable` sets libfiu's `has_any_failpoint_been_registered`, which is never reset, so every later `fiu_do_on` of the server takes libfiu's global rwlock and a hash lookup, also after `SYSTEM DISABLE FAILPOINT`. `Aggregator::drainAdaptivePartition` checks one per inserted key. The `iceberg_suite_*_synthio_*` tests of ClickHouse#119976 enable a failpoint, and the job runs all tests of a shard on the same two servers in name order, so since 2026-10-28 every test sorted after them is measured on such servers: about 17 tests 1.3-24x slower and noisier on both arches (`removing_group_by_keys #0` 0.13 -> 1.46 s on amd). Order the failpoint tests last in the job's test list, in compare.sh's confirmation reruns and in its standalone `run_tests`. The compare.sh paths do not measure when the order cannot be computed: the confirmation is skipped (original verdicts kept) and `run_tests` exits 1. Related: ClickHouse#100759 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review (click to expand)Own cold review + Gate B (codex) on
|
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-41:20261104-162100 |
|
cc @egor-click, could you review this and add the |
|
Workflow [PR], commit [e9d1a2c] Summary: ✅
AI ReviewSummaryUpdates libfiu so its fast-path flag is cleared when the last registered failpoint is disabled, restoring normal performance for subsequent tests sharing the server. Reviewed head Final VerdictStatus: ✅ Approve |
|
@groeneai I don't like this. Instead we should prevent any performance tests to use failpoints. Please ping the authors and adjust the tests or remove them, and add a check to prevent it happening again |
…r tests" This reverts commit 977e390. The performance tests must not use failpoints at all instead. Co-Authored-By: Claude Opus 5.5 <[email protected]>
libfiu never leaves its slow path once the first failpoint is enabled: `has_any_failpoint_been_registered` is set by `fiu_enable` and never reset, so from then on every `fiu_do_on` of the server process takes a global rwlock and a hash lookup. The perf job runs all the tests of a shard on the same two servers, so the `iceberg_suite_*_synthio_*` tests (ClickHouse#119976), which enable `s3_slow_response` or `local_object_storage_slow_response`, made every test that ran after them slower and noisier: a 10M-key GROUP BY checks a failpoint per key, and `removing_group_by_keys` went from 0.1% to 28% of master runs with a difference over 10% on amd (ClickHouse#100759). Each of these tests is a twin of an `iceberg_suite_*` test that only adds the failpoint, so without it they would duplicate the existing tests. Remove them, together with the `<failpoint>` element of `perf.py` (and its handling in test discovery and profile collection), which nothing else uses. The style check now rejects a failpoint in any performance test, fragment or file they pull in with a `file` attribute (the `tests/benchmarks` query files), both the element and a `SYSTEM ENABLE|DISABLE FAILPOINT` statement. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Done in 29f7e81, on top of a revert of the ordering commit:
@arsenmuk, these were your tests from #119976. After the first |
`FAILPOINT_STATEMENT_RE` is built for the stateless-test checks, which need the fail point name, so it misses statements the server accepts: `SYSTEM ENABLE FAILPOINT "s3_slow_response"` (double-quoted identifier), `SYSTEM /* setup */ ENABLE FAILPOINT ...` (comment between keywords) and `SYSTEM&ClickHouse#10;ENABLE FAILPOINT ...` (XML character reference). The prohibition does not need the name, so match the word `failpoint(s)` anywhere in the file, after decoding character references the way the XML parser in `perf.py` does (that also covers `FAILPO&ClickHouse#73;NT` and an encoded `file` path). The word also matches the `<failpoint>` element. No file in tests/performance or the files it pulls in mentions it today. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@Algunenano Iceberg performance depends on the number and the parallelism of IO requests much more than on the CPU performance. Which means - emulating slow IO is one of a few useful ways of testing Iceberg. |
|
The slow-IO tests can be kept without slowing down the tests after them. The side effect is only libfiu's So the fix can be in libfiu: clear the flag when the last enabled failpoint is disabled. @Algunenano, which do you prefer: (1) that libfiu fix, with the 8 |
As much as I believe we'd benefit from having Iceberg perf tests with simulated lags, it's okay if we can't currently accept failpoint-based solution. I'm working on some new suites in Stresshouse which would have that via failpoints and/or tc @Algunenano thank you for sorting this one out! |
|
@groeneai Fix it in libfiu please |
Reverts 29f7e81 and 82a8d47: the slowdown after a fail point is fixed in libfiu instead, so the iceberg_suite_*_synthio_* tests, the <failpoint> element of perf.py and its handling come back, and the no_failpoints_in_performance_tests style check goes away. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…isabled has_any_failpoint_been_registered was set by the first fiu_enable() and never cleared, so after one SYSTEM ENABLE + DISABLE FAILPOINT every fiu_do_on() in the server kept taking libfiu's lock and a table lookup until a restart. In the performance tests that slowed down every test that ran after a fail point test on the same servers. ClickHouse/libfiu#8 Co-Authored-By: Claude Opus 5.5 <[email protected]>
With the libfiu update the flag is cleared once no fail point is enabled. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Done in ClickHouse/libfiu#8:
Debug builds, one server, a 3M-key |
|
@groeneai I've merged the contrib, please update it here |
|
This fixes the tests that run after a synthio test. The synthio tests themselves still run their queries with a fail point enabled, so every On the master aarch64 binary b4fae47 (2026-10-27), Graviton3 with 4 vCPUs, warm Possible fixes, not tested: read the fail point once per drain call instead of once per key, or add a lock-free per-fail-point enabled check in |
|
Here is a measured patch for the first fix suggested in #129334 (comment). Release builds (clang-21) of master da712df with and without the patch (it applies unchanged to current master), Graviton3 with 4 vCPUs, warm
¹ On this pre-libfiu#8 build, that state sends every
@groeneai, would you fold this into this PR, or take it as a separate PR with its own performance run? Patch--- a/src/Interpreters/AdaptiveAggregation/Merge.cpp
+++ b/src/Interpreters/AdaptiveAggregation/Merge.cpp
@@ -4,6 +4,7 @@
#include <algorithm>
#include <bit>
+#include <optional>
#include <AggregateFunctions/IAggregateFunction.h>
#include <Columns/ColumnString.h>
@@ -426,6 +427,21 @@
using Key = AdaptiveRecordKey<Method>;
const bool prefetch = prefetchesStagedKeys<Key>(table);
StagedRecordWalk walk;
+
+ /// Once any failpoint is enabled, every failpoint check takes libfiu's global lock, so a check per new key
+ /// serializes the drains of all threads. Check once per drain, at its first new key (the failpoint is ONCE).
+ std::optional<bool> fail_creating_states;
+ auto throw_if_creating_states_fails = [&]() ALWAYS_INLINE
+ {
+ if (!fail_creating_states.has_value()) [[unlikely]]
+ {
+ fail_creating_states = false;
+ fiu_do_on(FailPoints::adaptive_aggregation_drain_create_states_throw, { fail_creating_states = true; });
+ }
+ if (*fail_creating_states) [[unlikely]]
+ throw Exception(ErrorCodes::FAULT_INJECTED, "Injected fault while creating the states of a merged key");
+ };
+
visitStagedRecordFormat<Key>(adaptive_argument_layout.get(), is_simple_count, [&]<typename Record>(Record format) ALWAYS_INLINE
{
if constexpr (Record::with_count)
@@ -473,10 +489,7 @@
it->getMapped() = nullptr;
/// Stands for the creation of the states failing, as on a memory limit: the key stays
/// in the table with a null state.
- fiu_do_on(FailPoints::adaptive_aggregation_drain_create_states_throw,
- {
- throw Exception(ErrorCodes::FAULT_INJECTED, "Injected fault while creating the states of a merged key");
- });
+ throw_if_creating_states_fails();
AggregateDataPtr place = arena->alignedAlloc(total_size_of_aggregate_states, align_aggregate_states);
createAggregateStates(place);
it->getMapped() = place;
@@ -510,10 +523,7 @@
it->getMapped() = nullptr;
/// Stands for the creation of the states failing, as on a memory limit: the key stays
/// in the table with a null state.
- fiu_do_on(FailPoints::adaptive_aggregation_drain_create_states_throw,
- {
- throw Exception(ErrorCodes::FAULT_INJECTED, "Injected fault while creating the states of a merged key");
- });
+ throw_if_creating_states_fails();
AggregateDataPtr place = arena->alignedAlloc(total_size_of_aggregate_states, align_aggregate_states);
createAggregateStates(place, use_compiled_functions);
it->getMapped() = place; |
Same tree as the previously pinned PR head f4a1ef5f668c. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks, done: |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units8 translation units recompiled, 4 s compile time in total, 8 of them have a recent master baseline. |
Related: #100759
Related: ClickHouse/libfiu#8
Related: #119976
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Description
Since #119976 (2026-10-28) about 17 performance tests run 1.3-24x slower and much noisier, on both servers and both arches:
removing_group_by_keys #00.13 -> 1.46 s (amd), 0.084 -> 1.29 s (arm); on amd its share of master runs with a difference over 10% went from 0.1% to 28%.Cause: libfiu's fast-path flag
has_any_failpoint_been_registeredis set by the firstfiu_enableand never cleared. Once aniceberg_suite_*_synthio_*test of #119976 has enabled and disableds3_slow_responseorlocal_object_storage_slow_response, everyfiu_do_onof that server takes libfiu's rwlock and a table lookup until a restart (Aggregator::drainAdaptivePartitionchecks one per inserted key), and all the tests of a shard share the same two servers.Change: update
contrib/libfiuto ClickHouse/libfiu#8, which keeps the flag equal to "at least one fail point is enabled", recomputed under libfiu's write lock on every enable and disable. The earlier commits of this PR (test order, then removing the synthio tests and adding a style check) are reverted, so the diff is the submodule and the comment ofhasAnyFailPointBeenRegistered.Validation, debug builds, one server, a 3M-key
GROUP BYon 8 threads: master takes 0.026 s fresh and 0.73-0.80 s afterSYSTEM ENABLE+DISABLE FAILPOINT, for the rest of the process; with this PR 0.021-0.064 s after the same, and it is slow only while a fail point is enabled. Fail points still fire while enabled (also with two enabled and one disabled, and after a re-enable), andSYSTEM DISABLE ALL FAILPOINTSclears the flag.Workflow [PR]
Sync PR [sync-upstream/pr/129334]
Version info
26.11.1.1836-master(included in26.11and later)