Skip to content

CI Fix: kill orphaned test process groups on macOS when clickhouse-test is SIGKILL'd - #3

Closed
leshikus wants to merge 27 commits into
masterfrom
fix/clickhouse-test-orphan-processes
Closed

leshikus wants to merge 27 commits into
masterfrom
fix/clickhouse-test-orphan-processes

Conversation

@leshikus

Copy link
Copy Markdown
Owner

When clickhouse-test (or its parent fast_test.py) is killed with SIGKILL, each .sh test subprocess runs in its own process group (start_new_session=True). Because the cleanup handlers never run, those subprocesses are re-parented to launchd and keep running. On Linux the Docker container boundary removes them; on macOS Darwin CI (no Docker, no cgroups) they accumulate across test runs.

Solution: track each test's PGID in a per-worker file atomically written right after Popen(). A new clickhouse-test --cleanup command reads all such files, kills each process group, and removes the files. Pre- and post-hooks in the job config call --cleanup so orphans are removed both before a run starts (leftover from a previous run) and after fast_test.py exits.

Key changes:

  • tests/clickhouse-test: per-worker PGID files (ci/tmp/clickhouse_test_group_pid.<pid>) written via write_text_atomic; --cleanup mode; setpgid guard; process listing in kill_process_group restricted to sanitizer builds
  • ci/tests/test_cleanup_test_groups.py: end-to-end pytest that launches clickhouse-test with 00058_select_sleep_3, SIGKILLs it, asserts 7 orphaned processes remain (2 bash + 5 sleeping clients), then verifies --cleanup kills them all
  • tests/clickhouse-test-process-management.md: design doc covering the cleanup layers and a known-issues section

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

...

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

maxknv and others added 27 commits April 2, 2026 17:53
… killed

When clickhouse-test was killed with SIGKILL (OOM, external kill), all .sh test
subprocesses it had spawned with start_new_session=True became orphans: they were
re-parented to init/launchd and continued running indefinitely. In Docker this
was invisible because the container boundary killed everything on exit. On macOS
without Docker the orphans accumulated across test runs.

Solution: use session-based containment.

clickhouse-test now calls os.setsid() instead of os.setpgid(0, 0), making itself
a new session leader (session ID == its PID). .sh tests are spawned with
preexec_fn=os.setpgrp instead of start_new_session=True, giving each test its own
process group for per-test os.killpg kills while keeping it in clickhouse-test's
session. Session membership survives re-parenting, so survivors can always be
found with ps -A -o pid,sess even after clickhouse-test exits.

run_test() in clickhouse_proc.py kills the entire session in a finally block after
process.wait() returns, covering the case where clickhouse-test itself was killed.

For the case where fast_test.py is killed before the finally block runs, run_test()
writes the session ID to ci/tmp/clickhouse_test_session_id immediately after
Popen() (before any blocking call). A new post-hook registered on
darwin_fast_test_jobs reads that file and kills the session after fast_test.py
exits, regardless of how it died.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
1. clickhouse-test: guard os.setsid() with a session leader check.
   When run_test() uses start_new_session=True, the child is already a
   session leader and os.setsid() raises PermissionError.  The session
   ID already equals the PID in that case, so skipping the call is safe.

2. _kill_session / cleanup hook: replace ps -o sess with os.getsid() loop.
   On macOS, ps -o sess prints the controlling terminal device number,
   not the session ID, so it returns 0 for all detached processes.
   Iterating all PIDs from ps -A -o pid= and calling os.getsid() directly
   works correctly on both Linux and macOS.

Verified with a unit test that confirms:
- runner session ID == its PID after setsid() / start_new_session
- .sh test (preexec_fn=os.setpgrp) is in the same session, different pgid
- os.getsid() scan finds both processes
- 0 processes remain after _kill_session

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
The previous guard `os.getpid() != os.getsid(0)` only checked for
session leadership, but `setsid` also fails when the caller is a
process-group leader (pid == pgid), which is the normal case in a
foreground shell job.  Replace the guard with try/except and fall
back to `setpgid(0,0)` when `setsid` fails.

ClickHouse#101636 (comment)

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Run clickhouse-test --cleanup before the job starts to kill any orphans left
by a previous run whose post-hook never fired.  Update the doc to reflect the
current PGID tracking design.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…port

Add `ci/tests/test_cleanup_test_groups.py` with an end-to-end test that
verifies the orphan-cleanup flow introduced by `_track_pgid` / `_untrack_pgid`
/ `cleanup_test_groups`:

1. A helper subprocess (simulating `clickhouse-test` running a test) starts a
   `sleep 300` child in its own process group and writes the PGID to
   `_GROUP_PID_FILE`, exactly as `_track_pgid` does.
2. The helper is killed with `SIGKILL` (simulating an OOM kill before
   `_untrack_pgid` can run), leaving the `sleep` process orphaned.
3. The test asserts the `sleep` process is still alive — it is in its own
   process group, so the parent's `SIGKILL` cannot reach it.
4. The test runs `clickhouse-test --cleanup` and asserts the `sleep` process
   is dead and the pid file is gone.

Also fix a missing `from pathlib import Path` import in `tests/clickhouse-test`:
`_GROUP_PID_FILE` (added by this branch) uses `Path` on module load, but
`pathlib` was never imported, causing a `NameError` on startup.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
The `skipif` guard restricted the test to Linux because it assumed
`kill_process_group` relied on the `pgrep --pgroup` system command.
In practice, the `pgrep` helper in `tests/clickhouse-test` uses
`ps -eo pid,ppid,pgid,command` (POSIX), so it works on macOS as well.

Replace the `importlib` boilerplate with `runpy.run_path` to load
`pgrep` directly from `tests/clickhouse-test` (the hyphen and missing
`.py` extension make a plain `import` statement invalid). Remove the
`skipif` decorator so the test runs on both Linux and macOS. Add a
`pgrep(pgid=test_pid)` assertion before the kill step to exercise the
imported helper.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…0058_select_sleep_3`

Replace the fake helper-script parent with a direct invocation of
`clickhouse-test` running the new `00058_select_sleep_3.sh` test, which
spawns 5 concurrent `SELECT sleep(3)` clients and one `SELECT 1`.

The test now:
- starts `clickhouse-test 00058_select_sleep_3` as the parent process
- imports `_GROUP_PID_FILE` and `pgrep` directly from `clickhouse-test`
  via `runpy` so path changes propagate automatically
- waits for the PGID file to be populated by `_track_pgid`, then waits
  for at least 2 processes to appear in the group
- kills `clickhouse-test` with `SIGKILL`, asserts the test process group
  is still alive, runs `clickhouse-test --cleanup`, and asserts all
  processes are dead and the pid file is gone

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…-orphan-processes

# Conflicts:
#	ci/defs/job_configs.py
#	tests/clickhouse-test
…n stacktrace helpers

- `shell_get_output`: add `check` parameter (default `False`) so callers
  can opt into exception-on-failure behaviour.
- `get_stacktraces_from_gdb` / `get_stacktraces_from_clickhouse`: pass
  `check=True` so a failing `gdb` or `clickhouse-client` invocation
  raises `CalledProcessError`, which is caught by the existing
  `except Exception` handler and returns `None` — restoring the original
  exception semantics instead of returning error text as stacktrace data.
- `cleanup_test_groups`: guard against PGID reuse by checking that the
  process group still contains at least one process whose command matches
  a test-related keyword (`clickhouse`, `bash`, `python`, `/bin/sh`)
  before calling `kill_process_group`.  A completely unrelated group that
  happens to have reused the PGID is skipped with a warning.
- `cleanup_test_groups`: add a docstring note clarifying that the `pgrep`
  helper is a Python function using POSIX `ps` (not the system `pgrep`
  binary), so the cleanup path is cross-platform, and that the `ESRCH`
  catch in `kill_process_group` prevents early loop abort on stale PGIDs.
Each worker process now writes its own ``_GROUP_PID_FILE.<pid>`` (atomic
write via tmp + `os.replace`) and deletes it on normal exit.  This
eliminates the `fcntl.LOCK_EX` cross-process lock: each worker owns its
file exclusively, so no coordination is needed.

`_track_pgid` and `_untrack_pgid` are inlined at their single call sites
and the helper functions are removed.  `cleanup_test_groups` globs for
all ``_GROUP_PID_FILE.*`` files (excluding ``.tmp``) instead of reading
a single shared file.  The pytest test is updated to match.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…errors

Use `sys.executable` + repo-relative path in `clickhouse_proc.py` so
`--cleanup` works on macOS CI where `clickhouse-test` is not in `PATH`.

Wrap `write_text_atomic` body in `try/except` so a disk or permission
error does not abort the test — a warning is printed instead.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…t file

Before launching `clickhouse-test`, remove any leftover
`00058_select_sleep_3*.stdout` files from the previous run so the
subsequent wait loop gets a clean signal.

After launching, wait up to 15 s for the stdout file to appear in
`tests/queries/0_stateless/`.  `clickhouse-test` opens that file just
before spawning the test subprocess, giving an early confirmation that
the harness has reached the test-execution phase rather than still
connecting to the server or parsing options.

Also move `pgid = None` to before the `try:` block so the `finally:`
clause never sees an `UnboundLocalError` when the inner `for` loop
never executes (empty `pgid_files` on the first iteration).

Update `tests/clickhouse-test-process-management.md` to reflect the
current implementation: per-worker group pid files (one per worker PID,
written atomically via `write_text_atomic`, deleted in each test's
`finally` block) instead of the old single shared file with
`_track_pgid` / `_untrack_pgid`.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
The test runs for 3 s, so waiting 15 s for the stdout file to appear
was excessive.  5 s is still generous for slow CI startup.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
ci/tests/test_cleanup_test_groups.py:
- Fix FIXME: read the PGID directly from the group pid file once the
  stdout file has content.  The file is written by `clickhouse-test`
  synchronously right after `Popen()`, before the bash script starts,
  so it is likely to exist by the time `SELECT 1` has returned and the
  stdout file has content.
- Assert exactly 7 processes in the group before and after SIGKILL:
  two bash processes (`/bin/bash -c script` + `bash script`, due to
  `shell=True`) and the 5 `SELECT sleep(3)` clients.
- Wrap the pre-kill assertions in `try/finally` so `clickhouse-test`
  is always killed even when an assertion fails mid-test.
- Use a single `pgrep` result variable in the final assertion instead
  of calling `pgrep` twice.

tests/clickhouse-test:
- Print process list in `kill_process_group` only under `SANITIZED`
  to reduce noise in normal (non-sanitizer) runs.

tests/clickhouse-test-process-management.md:
- Add "Known issues" section documenting that `kill_process_group` is
  not called when the test bash script exits normally, so background
  jobs that the script did not `wait` for are silently orphaned and
  unreachable by `--cleanup`.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@leshikus leshikus closed this Apr 14, 2026
leshikus pushed a commit that referenced this pull request Apr 27, 2026
…079-3df0)

`LimitSeekableReadBuffer::seek` used the expression
`pos + position_change` inside its in-buffer fast-path check. When the
inner buffer has not materialized its memory yet — as is the case for
`EmptyReadBuffer`, `ParallelReadBuffer`, and `ReadWriteBufferFromHTTP`,
all of which start with `pos == nullptr` — and a non-zero seek is
requested before the first `next()`, this triggers undefined behavior
per [expr.add]: "applying non-zero offset N to null pointer". On master
BuzzHouse (arm_asan_ubsan) this surfaced from the BACKUP write path as
STID 3079-3df0:

```
src/IO/LimitSeekableReadBuffer.cpp:97:34: runtime error: applying non-zero offset 1178 to null pointer
  #0 DB::LimitSeekableReadBuffer::seek(long, int)
  #1 DB::BackupWriterDefault::copyDataToFile(...)
  #2 DB::BackupImpl::writeFile(...)
  #3 DB::BackupsWorker::writeBackupEntries(...)
```

Replace the pointer-arithmetic comparison with an equivalent check
expressed via pointer *differences* and integer arithmetic, which is
well-defined regardless of whether `pos` is null. The condition is
mathematically identical to the original for all legal inputs.

Add `gtest_limit_seekable_read_buffer.cpp` covering the null-`pos`
regression plus two sanity tests for the in-buffer and out-of-buffer
seek paths. Without the fix the first test reproduces the exact UBSan
error from CI; with the fix all three pass cleanly under
`-fsanitize=address,undefined`.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=4b8132993ce0625e9c0ed0bf15ed16eb6df8262b&name_0=MasterCI&name_1=BuzzHouse+%28arm_asan_ubsan%29
leshikus pushed a commit that referenced this pull request May 21, 2026
…ax indices

Address PR ClickHouse#101170 review feedback (CI #2):

- Drop the 5 add_minmax_index_for_* members from ProjectionDescription. They
  were stale ad-hoc fields duplicating MergeTreeSettings; with the new generic
  SettingsChanges flow the effective MergeTreeSettings is already the canonical
  representation.
- Thread the already-computed effective MergeTreeSettings (defaults from the
  projection index plus user WITH SETTINGS overrides) into fillProjectionDescription
  and fillProjectionDescriptionByQuery as a new parameter, instead of
  reconstructing it. fillProjectionDescriptionByQuery reads the implicit-minmax
  flags via strongly-typed MergeTreeSetting accessors.
- Add the 5 add_minmax_index_for_* names to ALLOWED_PROJECTION_SETTINGS so the
  feature added in ClickHouse#105137 (Enable Implicit Skip Indices for Projections) keeps
  working under the new settings flow.

The ATTACH validation gap raised by review item #3 is intentionally left as
`mode <= LoadingStrictnessLevel::CREATE` to match the project-wide convention
(InterpreterCreateQuery, registerStorageMergeTree, etc. all validate user input
on CREATE/SECONDARY_CREATE only). The previous loadSettings validated
unconditionally because it had no access to mode; now that we do, aligning with
the rest of the codebase is the consistent choice.
leshikus pushed a commit that referenced this pull request May 26, 2026
The point-lookup queries (#4-ClickHouse#7) in apply_patch_parts_join produced
18-30% test noise because the four UPDATE statements that build the
patch parts ran with default parallelism. Parallel threads racing into
the patch builder produce different patch-part split boundaries on
every run, which changes how many patch granules a point lookup at
id=5000000 ends up reading. Per-server timing then depends on the
random split, not on the code being measured.

Force INSERT and UPDATE to use a single thread plus a block size large
enough to fit each whole patch, so the patch-part layout is the same
on every run. Locally verified deterministic over 20 cycles. Setup
time goes from ~4.2s to ~6.3s. Scan queries (#0-#3) still detect
patch-apply-path regressions as before.

Refs ClickHouse#100759.
leshikus pushed a commit that referenced this pull request Jun 8, 2026
ClickHouse#106278 tried to remove the LIMIT-without-ORDER-BY non-determinism by
sampling with WHERE cityHash64(WatchID) % N = 0. Post-merge master data
showed it did not work: it made the measured queries scan the whole table on
every run, so instead of reducing the noise it regressed it badly:

  classification #0: 6.5% -> 76% noisy
  classification #1:  10% -> 90% noisy

(#2/#3/#4 were already clean.)

Materialize the deterministic subset once into its own single-part table
(single-threaded insert + OPTIMIZE FINAL) and measure over that, so the
determinism lives in the setup (like ClickHouse#106249 for reading_from_file) and the
measured queries read only the subset instead of rescanning the source.
alexey-milovidov pushed a commit that referenced this pull request Aug 20, 2026
A query flagged in `report.html` was dropped when `all-query-metrics.tsv` had
no `client_time` row for it, and a shard whose TSV could not be read dropped
all of its flagged queries. With every flagged query dropped the run ended with
"the comparison ran and was clean" - a non-empty CI report turned into an
all-clear. The cause is deliberate on CI's side: `compare.sh` retracts a query
from the TSV when its confirmation rerun demoted it, while the report still
lists it under both "Changes in Performance" and "Unconfirmed Changes". On
PR ClickHouse#115255 that is `round_down` #2 and #3 and `and_compare_chain_derived` #2.

Those rows carry their own numbers, so they are now read from `report.html` and
marked `*` in the report - CI's verdict on them was already in doubt, which
makes them the most interesting queries to rerun, not the ones to discard. A
flagged query readable from neither source is reported as unresolved, and if
that leaves nothing to rerun the run fails instead of reporting a clean
comparison.

The commit under test drove only the report and binary lookup; the XMLs,
`perf.py`, its `stat_threshold`, and the configs still came from the working
tree. Query indices are positional and substitutions expand them, so a tree
that differs from the measured commit silently reruns a different query - on a
checkout one commit behind master, `and_compare_chain_derived.xml` has no query
#2 at all while CI flagged exactly that, and a `refs/pull/<n>/merge` checkout
is never the commit CI measured. `tests/performance`, `programs/server` and
`tests/config/top_level_domains` are now extracted from that commit into the
work dir and everything runs from there, fetching the commit when the clone
lacks it. `--use-working-tree-tests` opts out for iterating on a local test.

Verified: all six flagged queries of PR ClickHouse#115255 are now kept, the three the TSV
retracts carrying the report's numbers and flagged as unconfirmed; a dry run of
PR ClickHouse#112688 recovers `date_time_64` #5, which had been dropped the same way, and
runs against the extracted tree.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=115278&sha=baefff6dcc4dbb3201337a52b5ca54453fb34562&name_0=PR&name_1=Style%20check
Pull request: ClickHouse#115278

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GYYbBbrQpmi2zkYJ8LQw5Z
leshikus pushed a commit that referenced this pull request Oct 8, 2026
parallel_full_sorting_merge_join #1 (full_sorting_merge on one UInt64 key)
and window_function_with_order #3 got 10-20% slower: per row, the join
called an out-of-line findKeyRangeEndAssumeSorted, and the window code
called out-of-line copies of the SortedKeyRuns overloads and
WindowTransform::findPeerRunEnd, where master inlined the stateless search.

- force-inline findKeyRangeEndAssumeSorted, the SortedKeyRuns overloads in
  SortCursor.h and findPeerRunEnd;
- the SortedKeyRuns overloads take the stateless search for one-column keys;
- the peer-group marking of SlidingIndexes (new in master) uses one
  SortedKeyRuns per block instead of resetting it for every partition, which
  called vector::assign per partition. The partitions are searched in order
  and none starts inside an earlier one, so no stale run can be reused; the
  reset contract is stated precisely.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
leshikus pushed a commit that referenced this pull request Oct 16, 2026
The scaled loop of `convertToDecimalBatch` checked every row twice: the
multiplication against `DecimalScaleBounds` of the wide intermediate type, then
the product against the destination range. A cast from `Int128` paid four
`Int256` comparisons and an `Int256` multiplication per row, which made
`decimal_casts` #3-#6 1.15-1.74x slower than master (Performance Comparison,
arm_release).

The source values whose product with `m` fits the destination are
`[ceil(min / m), floor(max / m)]`. Compute that range once per block, clamped to
the source type, compare each row in the source type and multiply in the
destination type. A `UInt256` above the `Int256` maximum is above that range, so
it needs no separate check in this loop.

The results are the same as before for every integer source type, decimal width
and scale (boundary values around both limits checked against an independent
oracle). On an x86-64-v3 RelWithDebInfo build the casts take 0.39-1.03x of
master's time.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
leshikus pushed a commit that referenced this pull request Oct 30, 2026
…ee stack placements

Since ClickHouse#126977 both perf servers start with ASLR disabled, so every start of a
binary puts its thread stacks at the same place. A change that only moves the
query threads' frames within their stack pages (on ClickHouse#112928, `ThreadPool` worker
frames 32 bytes larger) then reproduces at every restart: `set_in_clustered_keys`
#2/#3 were 28-32% slower on arm with an instruction-identical `keys256` probe
and equal static TLS, and the confirmation rerun reproduced them (+27.1%,
+29.8%), so the shard stayed red.

`confirm_changes` now reruns the flagged queries at three placements: the main
run's own, and with `glibc.rtld.optional_static_tls` = 512 + 21*64 and
512 + 43*64 for both servers (glibc puts the static TLS block at the top of
every thread stack, so all thread stacks move 1344 and 2752 bytes lower).
`restart` takes the surplus as an optional argument; without it nothing changes.
`eqmed.sql` runs separately per placement, step 5's rule is evaluated per
placement, and `query-metric-stats.tsv` gets, per query, an actual placement
row on the side of the two-of-three majority (the one farthest from the
thresholds), so step 5 and the dashboard check in `performance_tests.py`, which
are unchanged, reach the majority verdict. With fewer than three placements
measured (a failed restart or rerun, the time budget), the placement 0 row is
used, which is the previous behaviour; without it the original verdict stands.
The per-placement verdicts go to `placement-verdicts.tsv` and the job log.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
leshikus pushed a commit that referenced this pull request Nov 13, 2026
…up window

`NegativeLimitBySortedStreamTransform::consume` sent every group, even one
that starts and ends inside the current chunk, through the sliding window:
`append_run` pushed a `ChunkSlice` into the empty window deque (allocating the
deque map and a block, and copying the chunk `shared_ptr`), `finalizeWindow`
copied it into `pending` (a second `shared_ptr` copy) and then `window = {}`
(libc++: `clear(); shrink_to_fit();`) freed the block and the map. So each
one-row group cost two memory-tracked allocations, two frees and two atomic
increment/decrement pairs, plus one `pending` entry.

The window is only needed for a group that touches a chunk boundary. A group
that ends inside the chunk while the window is empty also started inside this
chunk, so its output is known when its end is found: the last
`min(L, length + offset)` rows of the run without the trailing `offset` rows,
the same rows `append_run` + `dropExcessRows` + `dropOffsetRows` keep for a
one-slice window. Such groups are now staged into `pending` directly, and
`appendToPending` extends the last pending slice when the new rows continue
it in the same chunk, so the one-row groups of a chunk become one slice.
`generate()` produces the same chunk for a merged slice (same rows, first
start and last end). Groups touching a chunk boundary still use the window.

Evidence that this path is what moves the `negative_limit_by_in_order`
queries #0, #1 and ClickHouse#8 (millions of groups): ClickHouse#125000, which changed only the
allocator of these deques, moved them by -19/-16/-17% on master d3ee313 while
#2-ClickHouse#7 stayed flat; and the ClickHouse#125013 perf job's prewarm counters for #0 show
equal instructions on both sides (10301M vs 10333M, ~1030 per group) and +15%
cycles on one build.

Local A/B (release build, `CMAKE_BUILD_TYPE=None`, no ThinLTO, the perf
test's tables and queries, 12 rotating rounds, geomean of per-round ratios
new/base with bootstrap 95% CI):

  #0 10M one-row groups      0.764 s -> 0.096 s  0.123 [0.113, 0.135]
  #1 1M groups of 10         0.098 s -> 0.049 s  0.457 [0.413, 0.510]
  #2 100k groups of 100      0.025 s -> 0.019 s  0.707 [0.642, 0.785]
  #3-ClickHouse#7 100 groups           0.86-1.03, no CI lower bound above 1.0 (4-15 ms)
  ClickHouse#8 5M two-key groups       0.447 s -> 0.116 s  0.250 [0.236, 0.265]

User-space instructions of 5 runs of #0: 60.3G -> 10.2G (~1190 -> ~190 per
group after subtracting 5 runs of #3), cycles 16.2G -> 3.1G; ClickHouse#8: 31.4G ->
6.4G instructions. In the base profile of #0 about half of the samples are
in the deque allocation, `shrink_to_fit`, `CurrentMemoryTracker` and
jemalloc; none of them is in the top 15 after the change.

Replacing only `window = {}` by `clear()` (keeps the deque blocks) gives
0.526 / 0.594 / 0.583 on #0 / #1 / ClickHouse#8, so the direct staging is 4.3x and
2.3x faster than that on #0 and ClickHouse#8.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants