Skip to content

Add asynchronous metrics for executable UDF memory usage - #107300

Merged
vdimir merged 19 commits into
ClickHouse:masterfrom
HanziJiang:hanzi/udf-memory-async-metrics
Jun 22, 2026
Merged

vdimir merged 19 commits into
ClickHouse:masterfrom
HanziJiang:hanzi/udf-memory-async-metrics

Conversation

@HanziJiang

@HanziJiang HanziJiang commented Jun 12, 2026 •

Copy link
Copy Markdown
Contributor

Adds asynchronous metrics for executable and executable_pool UDFs:

  • ExecutableUserDefinedFunctionMemoryResidentBytes is the sum of VmRSS over all live executable and executable_pool UDF processes and their descendant processes, in bytes.
  • ExecutableUserDefinedFunctionProcesses is the number of processes the sum was taken over.

Live UDF pids are tracked in a new UDFProcessRegistry. ShellCommand registers each pid at spawn with a generation stamp and removes only its own entry at reap, so a stale reap can't evict a later process that reused the pid. Zombies have no VmRSS line, so they are not counted towards the metrics, and sampling prunes their registry entries.

Summing VmRSS counts shared pages once per process. PSS was measured and rejected because its cost scales with resident memory.

The metrics are instance-wide aggregates instead of per-function dynamic names because metric names built from user-defined identifiers have unbounded cardinality, as users can define arbitrarily many functions. Dynamic name suffixes are reserved for small bounded sets.

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Added asynchronous metrics ExecutableUserDefinedFunctionMemoryResidentBytes and ExecutableUserDefinedFunctionProcesses, reporting the resident memory (VmRSS) and number of live processes of executable and executable_pool user-defined functions, including descendant processes and idle pool workers.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.6.1.1125

Two new server asynchronous metrics, sampled every
`asynchronous_metrics_update_period_s`:

- `ExecutableUserDefinedFunctionMemoryResident`: sum of VmRSS over all
  live executable and executable_pool UDF processes and their descendant
  processes, in bytes.
- `ExecutableUserDefinedFunctionProcesses`: number of processes the sum
  was taken over.

Unlike the per-invocation ProfileEvents (ClickHouse#105618), this is a
point-in-time view that includes idle executable_pool workers, which
hold their memory between invocations.

Live UDF child pids are tracked in a new `UDFProcessRegistry`:
`ShellCommand` registers the pid at spawn (a new Config flag set only
by the executable UDF path) and removes it at the two points where the
pid stops being ours: at reap in `tryWaitImpl`, and before
`waitForPid` in `tryWaitProcessWithTimeout` on destructor teardown.
A reused pid can therefore never be sampled or unregistered by a stale
wrapper. The sweep reuses `UDFProcfs::walkSubtree` plus a new
`readCurrentRss` (VmRSS from /proc/<pid>/status), deduplicating pids
across subtrees; a zombie has no VmRSS line and drops out of both
metrics.

Summing VmRSS counts shared pages once per process, so the metric is an
upper bound on the unique physical footprint; the limitation is
documented in the metric description. PSS from smaps_rollup was measured
and rejected: its page-table walk cost scales with resident size, which
is unacceptable inside the once-per-second update loop.
@CLAassistant

CLAassistant commented Jun 12, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@clickhouse-gh

clickhouse-gh Bot commented Jun 12, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [297af55]

Summary: ✅


AI Review

Summary

This PR adds instance-wide asynchronous metrics for executable and executable_pool UDF process residency and process count, backed by UDFProcessRegistry, Linux procfs sampling, documentation, gtests, and integration coverage for pool workers, descendants, in-flight executable calls, timeout cleanup, killed workers, and non-UDF exclusion. I found no remaining correctness, lifecycle, metadata, or coverage findings that need a new inline review comment.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Jun 12, 2026
@HanziJiang HanziJiang added can be tested Allows running workflows for external contributors and removed can be tested Allows running workflows for external contributors labels Jun 12, 2026
@HanziJiang HanziJiang added the can be tested Allows running workflows for external contributors label Jun 12, 2026
The suite verified return-to-baseline only after a successful query (reap
path) or an externally killed pool worker. This covers the failure path:
the script allocates ~128 MiB and hangs, `command_read_timeout` fails the
query, and the error-path teardown must SIGTERM the stuck process and
release its registry entry, returning both metrics to baseline. A leaked
wrapper on the error path would keep the gauge stuck high; no other test
would catch that.
Comment thread src/Common/ShellCommand.cpp Resolved
- Remove the per-root registry membership re-check from
  `UDFProcessRegistry::sample`: it only narrowed an already negligible
  pid-reuse window (a full pid-space wraparound within a sub-millisecond
  span, self-correcting on the next sweep) at the cost of extra locking
  every reader had to reason about. The global dedup across subtrees
  stays.
- Fix two comments: `sampleExecutablePeak` is also a try/catch caller
  of `UDFProcfs`; the registry tracks pids rather than live processes
  (a killed pool worker stays registered as an unreaped zombie until its
  wrapper is destroyed, and is excluded from the metrics by having no
  VmRSS line).
- Harden `test_timed_out_executable_is_killed_and_leaves_metrics`:
  widen the observation window to 25 s for slow sanitizer runners, check
  both metric deltas in one predicate so a separate count snapshot
  cannot land after the timeout kill, and assert the query thread
  finished.
Address review comments:

- Remove the registry entry in `tryWaitProcessWithTimeout` only when
  `waitForPid` actually reaped the child. An unreaped child keeps its
  pid un-reusable (alive, then zombie), so the retained entry can never
  alias another process, and a process that outlives
  `command_termination_timeout` or ignores SIGTERM stays counted
  instead of vanishing from the metrics while it still holds memory.
  Once it dies, the zombie has no VmRSS line and drops out of both
  metrics; the stale set entry costs tens of bytes alongside the
  pre-existing leaked zombie.
  ClickHouse#107300 (comment)
- Wait in the test fixture until the metrics are published before any
  test takes numeric baselines.
  ClickHouse#107300 (comment)
Comment thread src/Common/UDFProcessRegistry.h Resolved
Comment thread src/Common/ShellCommand.cpp Outdated
bool process_terminated_normally = waitForPid(pid, timeout_in_seconds);

if (process_terminated_normally && config.register_in_udf_process_registry)
UDFProcessRegistry::instance().remove(pid);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wanted to callout: #107300 (comment)

- Remove the cross-subtree dedup from `UDFProcessRegistry::sample`:
  registered roots are direct children of this server, so their subtrees
  are disjoint, and `walkSubtree` already dedups within one subtree.
- Tests: restart the server at the top of every pool test, making the
  suite order- and repeat-independent; fork two generations in the
  descendant test so the ballast lives in the grandchild and the
  assertion pins recursive subtree walking; add a two-UDF test asserting
  the gauge reports the sum of both workers; assert memory deltas as
  bands of `BALLAST +/- TOLERANCE` (25 MiB, ~3x the measured 7-9 MiB
  interpreter overhead) instead of one-sided thresholds, and process
  count deltas as exact equalities, so overcounting fails the suite as
  loudly as undercounting.
The registry entry is removed only when the child is reaped; a child
that survives the bounded wait in `tryWaitProcessWithTimeout` stays
registered (alive, then a zero-RSS zombie that contributes nothing to
the metrics). The class doc and the `ShellCommand::Config` flag comment
still claimed removal at wrapper destruction.

ClickHouse#107300 (comment)
- Wrap the registry sweep and metric emission in try/catch: an
  allocation failure under memory pressure now costs only the two UDF
  metrics for that cycle instead of discarding the whole asynchronous
  metrics snapshot. Memory pressure is exactly when these metrics are
  read, so blanking every metric for the cycle was the worst failure
  mode.
- Pin `asynchronous_metrics_update_period_s` to 1 in the test config:
  the suite's polling windows are calibrated to a 1 second sweep and
  previously relied on the server default.
- Fix the `sample` comment: on non-Linux the metrics are absent, not 0
  (the call site gates emission).

The number of uncorrectable ECC memory errors. A non-zero number of this value indicates bad RAM which has to be immediately replaced, because it indicates potential data corruption. Source: `/sys/devices/system/edac/mc/`

### ExecutableUserDefinedFunctionMemoryResident {#executableuserdefinedfunctionmemoryresident}

@andreev-io andreev-io Jun 15, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of the name. What is "memory resident" (compare this with "memory resident size")? What are the units? Maybe ExecutableUserDefinedFunctionVmRSSBytes?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For regular MemoryResident bytes suffix is also missing, so for me either works

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the Bytes suffix. I kept the MemoryResident because it parallels the server's async memory metrics using VmRSS

### MemoryResident {#memoryresident}

Lmk if we still prefer to change MemoryResident into VmRSS

Comment thread src/Common/ShellCommand.h
/// When true, the child pid is tracked in the global `UDFProcessRegistry`
/// from spawn until the child is reaped. Set for both executable and
/// executable_pool UDFs.
bool register_in_udf_process_registry = false;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ShellCommand is not UDF-specific, right? So what does this do for non-UDF callers? As per comment, a non-UDF process would also be tracked?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, ShellCommand is not UDF-specific. Non-UDF callers will have register_in_udf_process_registry to false, so the pid is not tracked. register_in_udf_process_registry is only set to true if is_user_defined_function = true here. Updated comments to be more clear.

if (pid <= 0)
return;

std::lock_guard lock(mutex);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to unlock? Does it unlock itself at the end of scope?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. It acquires the mutex in its constructor and releases it in its destructor, when it's out of scope

Comment thread src/Common/UDFProcessRegistry.h Outdated
*
* `ShellCommand` adds the pid at spawn and removes it when the child is
* reaped, so idle pool workers stay registered for as long as they live.
* A never-reaped child stays registered: its pid stays pinned, and a zombie

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand why how a zombie, if it's registered, is not contributing to the metrics?

@HanziJiang HanziJiang Jun 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andreev-io @vdimir Yeah this is guaranteed by the procfs implementation, although I couldn't find an official documentation. Also did some experiments to validate it.

Procfs only emits the Vm lines in /proc/<pid>/status when mm != NULL, mm is set to NULL when the task is terminating. And our implementation guarantees that if the Vm line is missing, we don't attribute the pid to the metrics.

I added some comments in commit



def _wait_for(predicate, timeout=30, interval=0.5):
"""Poll until predicate() is truthy; async metrics update once per second,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

async metrics update once per second

Is this strictly true?

@HanziJiang HanziJiang Jun 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is defined via asynchronous_metrics_update_period_s, with a default of 1s. The test config pins it to 1s with <asynchronous_metrics_update_period_s>1</asynchronous_metrics_update_period_s>

The flag is assigned in `ShellCommandSource` from `is_user_defined_function`,
not directly by the executable-UDF loader. State only that it is enabled for
executable and executable_pool UDFs.
Two reviewers asked why a registered-but-zombie child contributes to neither
`ExecutableUserDefinedFunctionMemoryResidentBytes` nor
`ExecutableUserDefinedFunctionProcesses`. State the mechanism in the
`UDFProcessRegistry` comment: a zombie has released its address space, so
`/proc/<pid>/status` has no `VmRSS` line and `sample` skips it.
@vdimir

vdimir commented Jun 16, 2026

Copy link
Copy Markdown
Member

@groeneai check out CI failures, if they all are known and fixed, merge master otherwise prepare fixes in separate PRs

@groeneai

Copy link
Copy Markdown
Collaborator

@vdimir Triaged both failures on the latest run (56a087f). Neither is caused by this PR (it only touches UDF async metrics / ShellCommand; both failures are unrelated code paths).

  1. Unit tests (amd_llvm_coverage) "Backup checksum should not be zero (test.bin) (LOGICAL_ERROR)" in the BackupDataFileNameGenerator gtest. Transient master breakage on 2026-06-15: 13 master runs failed between 12:00 and 17:00 UTC, plus ~40 unrelated PRs in the same window. Master has been green on this job since 2026-06-16 00:00 UTC (14 OK / 0 fail). The gtest source is unchanged since Nov 2025, so this was a trunk-side interaction that has since cleared. Merging master resolves it. We also have an open hardening PR for this exact gtest: Mark caught LOGICAL_ERROR exception as logged in BackupDataFileNameGenerator gtest #106668.

  2. Stress test (arm_asan_ubsan, s3) "Hung check failed, possible deadlock found". Known chronic flake on this job: a single hit here, spread over 16 unrelated PRs in the last 30 days, 0 master occurrences in 30 days. The dumped stack is a normal parse exception in one query thread, not a crash. Clears on re-run.

Recommendation: merge master into the branch and re-run. No code change is needed in this PR for either failure.

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107300&sha=56a087f40d1e076a2605d6c7eb731140ff3dbf83&name_0=PR

@vdimir

vdimir commented Jun 16, 2026

Copy link
Copy Markdown
Member

@groeneai why do we see many 'Hung check failed' error in PRs? Should we find a root cause and fix?

@groeneai

Copy link
Copy Markdown
Collaborator

@vdimir Short answer: "Hung check failed" is not one bug. It is the Stress test's single catch-all: after the test suite finishes, if ANY query is still in the processlist after the 90s drain, the whole stress job is failed with this one generic name. So it is an umbrella over several independent server-hang signatures, surfaced heavily because Stress runs the server/AST fuzzer under sanitizers (5-10x slower), which exposes timing-sensitive hangs. Each PR's stress run trips one of them roughly once, at random, so it shows up on many unrelated PRs without being caused by any of them.

Quantifying "many" (CIDB, last 30d, exact test names "Hung check failed..." + "Possible deadlock on shutdown..."):

  • PRs: 275 hits across 196 distinct PRs (~1.4 hits/PR, the chronic-flake signature)
  • master: 313 hits
  • Spread evenly across every Stress sanitizer variant (arm_tsan / amd_asan_ubsan / arm_debug / amd_msan / ... 9-21 each in 7d), plus the master-only serverfuzz lanes.

Yes, it is being root-caused, per-signature (the generic name itself cannot be "fixed" as one thing). Known signatures and status:

  1. Leaked local ThreadPool at GlobalThreadPool::shutdown ("Possible deadlock on shutdown"). Root cause identified: a function-local / subsystem ThreadPool outlives its scope, GlobalThreadPool::shutdown() then joins a worker blocked on the inner pool's shutdown flag that is never set. Diagnostic PR Log live local thread pools at GlobalThreadPool shutdown #105905 (open) logs the live local pool names at shutdown so the leak can be attributed to a specific subsystem from CIDB.
  2. Local distributed-plan cancellation deadlock (shuffle-join / multistage path). Fixed by davenger, merged via Revert "Revert "Multistage distributed queries" (#106020) — fixes ASan heap corruption on master" #107146 (06-15). The same multistage feature (Multi-stage distributed queries #106020) had also caused an ASan heap-corruption spike, reverted by Revert "Multistage distributed queries" (#106020) — fixes ASan heap corruption on master #107122 (06-11). Together these explain the 06-09..06-11 master spike (43 / 21 / 32 hits/day, vs single digits before and after).
  3. 04007_pipeline_stuck ping-pong deadlock. Fix PR Fix flaky test 04007_pipeline_stuck_ping_pong_deadlock #107565 (open).
  4. AST-fuzzer cancelled-INSERT / serialization-timeout hangs (e.g. SerializationObjectSharedData ADVANCED under tiny block sizes). No lock cycle, just a cancelled pipeline that does not unwind within 90s under fuzzer+sanitizer load; more a fuzzer-load artifact than a product deadlock.

Infra unblocker already merged: #103551 stopped the stress script from deleting hung_check.log and embeds its tail into CIDB test_context_raw, so every new hit now ships the stuck-thread stacks for per-signature triage.

Recommendation: keep attacking it per-signature. Highest-leverage next step is landing #105905 to pin the shutdown-leak subsystem; the distributed-plan fixes above should already pull down the recent spike. For this PR specifically, the single hung-check hit is one of these chronic instances and is unrelated to the UDF async-metrics change, so it is safe to merge master and proceed. Happy to break any specific signature into its own fix PR if you want one prioritized.

Stamp each registered pid with a generation so a stale reap cannot evict a successor that reused the pid, and prune zombie roots during sampling.
@HanziJiang
HanziJiang force-pushed the hanzi/udf-memory-async-metrics branch from ccdb1a7 to afb8a5c Compare June 17, 2026 03:35
Comment thread src/Common/UDFProcessRegistry.cpp Resolved
@vdimir

vdimir commented Jun 18, 2026

Copy link
Copy Markdown
Member

Stateless tests (amd_tsan, s3 storage, parallel, 2/2) FAIL
03040_dynamic_type_alters_2_compact_merge_tree FAIL cidb
Stress test (arm_debug) FAIL
Unknown error FAIL cidb

@groeneai please check out this failures

@groeneai

Copy link
Copy Markdown
Collaborator

@vdimir Checked both. Neither is caused by this PR (diff touches only the executable-UDF async metrics path: UDFProcessRegistry, ShellCommand, ShellCommandSource, ServerAsynchronousMetrics; no MergeTree, serialization, or stress-harness code).

1. 03040_dynamic_type_alters_2_compact_merge_tree (amd_tsan, s3 storage, parallel) - known rare flaky.
CIDB: 3 FAIL / 49,789 runs in 14d (~0.006%), 0 on master, spread over 4 unrelated PRs in 30d (each a different sanitizer/storage variant). It is a low-frequency race in the _compact_merge_tree variant under randomized dynamic_serialization_version=v2; not locally reproducible (750+ iterations, 0 fails). Unrelated to this PR.
Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107300&sha=458f287565f4b100cc3564bea658e2551b9e191a&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20s3%20storage%2C%20parallel%2C%202%2F2%29

2. Stress test (arm_debug) "Unknown error" - benign lost-connection, not a crash.
This is the stress log-parser fallback: after the server dropped the connection it scanned clickhouse-server.err.log + stderr.log and matched none of its fatal patterns (segfault, Received signal, Logical error, assertion, sanitizer, OOM). I pulled the full job log: zero <Fatal> / Received signal / Segmentation fault / sanitizer / Logical error lines, and every integrity sub-check is OK (Server successfully started, Test script exit code OK, No SharedMergeTree lost forever, No lost s3 keys). 10 of 11 stress variants on this sha passed, including amd_debug (identical workload) and all five sanitizer builds (asan/ubsan/tsan/msan), which would flag a real crash or UAF. Single occurrence in 30d, 0 on master.
Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107300&sha=458f287565f4b100cc3564bea658e2551b9e191a&name_0=PR&name_1=Stress%20test%20%28arm_debug%29

Recommendation: both are flaky/benign and unrelated to the PR. Just re-run the two jobs; no code change needed here.

@vdimir

vdimir commented Jun 18, 2026

Copy link
Copy Markdown
Member

both are flaky/benign and unrelated to the PR. Just re-run the two jobs; no code change needed here.

@groeneai we still need to figure out how to fix it separately

@groeneai

Copy link
Copy Markdown
Collaborator

@vdimir Will pursue separately. Key point: 03040_dynamic_type_alters_2_compact_merge_tree is not settings-flaky, it looks like a real (very rare) data-loss bug.

30d CIDB: 3 hits / 3 unrelated PRs, 0 on master, ~3 in 90k runs, all with the identical signature: after alter rename column 1 the whole Dynamic column collapses to None (the typed UInt64/String values written before the rename disappear). The CI rerun with the same randomized settings passes 12/12 and 27/27, so it is a timing race (background merge vs the rename mutation on compact parts under dynamic_serialization_version=v2), not a setting effect. Pinning the version in the test would just mask the data loss, so I will root-cause the engine path (Dynamic/JSON serialization, area owner @ Avogar) and open a separate fix PR linked here, rather than patch the test.

The Stress (arm_debug) "Unknown error" was a single benign lost-connection (no crash signature anywhere in the full log, 1 occurrence in 30d, 0 master); nothing to fix there beyond a re-run unless it recurs.

@groeneai

Copy link
Copy Markdown
Collaborator

@vdimir Root-caused it, and it turned out bigger than a flaky test: 03040_dynamic_type_alters_2_compact_merge_tree is hitting a real, general data-loss race. Not Dynamic/v2/compact specific (that correlation was coincidental; Dynamic just renders the loss as None).

Deterministic repro (any column type, any part type):

-- table with a few unmerged parts that contain column d, then:
OPTIMIZE TABLE t FINAL SETTINGS mutations_sync=0;   -- async, in background pool
ALTER TABLE t RENAME COLUMN d TO d1 SETTINGS mutations_sync=1;  -- concurrently
-- ~15-30% of races: d1 reads back entirely empty/None. Data is gone.

Confirmed on v2 and v3, packed/compact/wide, String and Dynamic. Control: ALTER MODIFY COLUMN (type change, no rename) racing the same merge never loses data, so the trigger is the name change.

Mechanism: the merge captures metadata_snapshot at part-selection time (already post-rename: column d1) but selects the original parts (data version 0, still d on disk). MergeTask::prepare then builds its mutations snapshot lazily at execute time, by which point the synchronous rename has fully applied and been purged (min_part_data_version advanced past it, num_metadata->0), so getMutationsSnapshot returns empty and getAlterConversionsForPart has an empty rename_map. The merge reads d1 from parts that only have d with no conversion -> empty, and stamps the merged part with the post-rename metadata version so it is unrecoverable. The "expire absent columns" optimization (MergeTask.cpp, PR #88860) then also drops d1, but guarding that alone does not fix it (the reader still cannot map d->d1), so it is a symptom amplifier, not the root.

So the metadata snapshot (selection time) and the mutations snapshot (execute time) are captured inconsistently and the rename falls into the gap. Fixing it cleanly means making the merge's mutation snapshot consistent with the parts/metadata version it selected (and likely mirroring to ReplicatedMergeTree). That is a core merge/mutation coordination change with real trade-offs, so before I open a PR: do you want the snapshot pinned at selection time, the metadata_snapshot pinned to the selected parts, or another approach? No GH issue exists yet; I can file one with this repro.

@clickhouse-gh

clickhouse-gh Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.20% 85.30% +0.10%
Functions 92.30% 92.30% +0.00%
Branches 77.40% 77.50% +0.10%

Changed lines: Changed C/C++ lines covered by tests: 141/155 (90.97%) | Lost baseline coverage: none · Uncovered code

Full report · Diff report

@clickhouse-gh

clickhouse-gh Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 38 queries analysed

This PR only adds two asynchronous metrics that track memory and process counts for executable user-defined functions; it touches the UDF process registry, the shell-command wrapper (behind a flag that is off for normal queries), and the periodic async-metrics sweep. None of these are on the query-execution path that ClickBench Q4, Q15, or Q28 exercise, and with no UDFs registered the new sampling does no work. The three flagged improvements (-19.6%, -12.5%, -5.7%) cannot plausibly come from this change, so they are downgraded as run-to-run variance rather than a real PR effect.

clickbench

⚠️ 3 inconclusive

Flagged queries (3 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 4 not_sure 265 213 -19.6% <0.0001 PR only adds executable-UDF process metrics; Q4 runs no UDF, so this -19.6% is run-to-run variance
⚠️ 15 not_sure 236 206 -12.5% <0.0001 Server query hot path untouched (UDF registry sample is empty with no UDFs); -12.5% is noise
⚠️ 28 not_sure 7033 6636 -5.7% <0.0001 Async-metric UDF accounting only; Q28 invokes no executable UDF, -5.7% not attributable to PR

q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: ae455b9a-6f35-46bc-aaa8-8eba9d98edc3
  • MIRAI run: bf018d13-0266-49fb-9f35-8de629fde281
  • PR check IDs:
    • clickbench_40725_1782130365
    • clickbench_40731_1782130365
    • clickbench_40741_1782130365
    • tpch_adapted_1_official_40752_1782130365
    • tpch_adapted_1_official_40761_1782130365
    • tpch_adapted_1_official_40773_1782130365

@vdimir
vdimir enabled auto-merge June 18, 2026 21:09
@vdimir
vdimir added this pull request to the merge queue Jun 22, 2026
Merged via the queue into ClickHouse:master with commit a627314 Jun 22, 2026
165 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 22, 2026
@groeneai

Copy link
Copy Markdown
Collaborator

@Algunenano Correct, and already handled. Those two subtests (test_inflight_executable_invocation_is_visible, test_timed_out_executable_is_killed_and_leaves_metrics) are added by this PR and were flaky on master. Root cause: baseline contamination. Earlier subtests in the file leave idle executable_pool workers registered in the async metrics, and these two snapshotted mem_before/procs_before without a clean restart, so the residual showed up as a nonzero delta.

Fixed in #108275 (merged 2026-06-23 17:24 UTC): restart + wait for a clean 0/0 baseline before the snapshot, matching the 6 sibling subtests that already did this. 0 FAIL/ERROR in ~24.8k runs since merge (last failure was 06-23 09:06, before the merge).

For the record, the other failure originally flagged on this PR, the Stateless 03040_dynamic_type_alters_2_compact_merge_tree mismatch, is a different class. It root-caused to a real OPTIMIZE FINAL racing ALTER RENAME COLUMN data-loss race (mechanism in issuecomment-4741167096), still open and tracked separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants