Skip to content

Live flame graphs from streamed profiler samples in the Web UI - #117830

Open
ei-grad wants to merge 171 commits into
ClickHouse:masterfrom
ei-grad:play-flamegraph
Open

ei-grad wants to merge 171 commits into
ClickHouse:masterfrom
ei-grad:play-flamegraph

Conversation

@ei-grad

@ei-grad ei-grad commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Add an opt-in live flame graph to the Web UI (/play). Enabling Flame graph streams the running query's profiler samples over its existing HTTP response. The graph updates while the query runs, preserves zoom, and supports CPU, Real, and positive MemorySample allocation samples. A per-tab profiler period controls subsequent opted-in runs.

Distributed profiles can be viewed for all nodes together or for one producing node, with independent zoom. Reported server queue losses and collector timeouts are visible separately from browser omissions. The browser applies shared limits to all retained host trees, symbol text, and rendered frames. Profiling is disabled by default and is not persisted across page reloads. The view requires no access to system.trace_log or SYSTEM FLUSH LOGS. Because samples disclose symbol names and executable offsets, delivery requires the same access as addressToSymbol (the INTROSPECTION grant and allow_introspection_functions), and only offsets in the server executable are sent; other frame addresses are 0.

Includes the transport changes from the related PR so both pull requests target master and receive CI checks.

Related: #118415

Changelog category (leave one):

  • Improvement

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

The Web UI (/play) can display an interactive flame graph while a query runs. Enable Flame graph to view streamed CPU, wall-clock, or sampled allocation stacks, select all nodes or one node, zoom into frames, and select the profiler period for subsequent runs. The graph reports server queue losses and incomplete collection.


Workflow [PR]
Sync PR [sync-upstream/pr/117830]

Add a `Flame` toggle next to `Logs` and `Metrics` in the progress line of
`/play`. Every run now carries a page-chosen `query_id`, so the view can
fetch the query's sampling-profiler stacks from `system.trace_log`
(collapsed by the `flameGraph` aggregate function, after
`SYSTEM FLUSH LOGS trace_log`) and render them as an interactive flame
graph: `CPU`, `Real` or `MemorySample` traces, click to zoom into a
subtree, the ancestors dimmed, hover for the sample count and share.

The view also offers the profiler period for the next runs (applied as
`query_profiler_real_time_period_ns` / `query_profiler_cpu_time_period_ns`
on the request, kept in localStorage), since the server default of one
second leaves a short query without samples; an empty result explains
which setting to change.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@ei-grad

ei-grad commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author
image

@zlareb1

zlareb1 commented Sep 3, 2026

Copy link
Copy Markdown
Member

I went through the new code paths with an eye on injection and on interactions with the existing run path, and the core is clean: every server-returned string lands in inert sinks (textContent, the title property, replaceChildren + element/style construction), so demangled symbols containing <, >, & or quotes render as text; the follow-up system.trace_log query quotes query_id and trace_type through the existing quoteStringLiteral, and the id itself is page-minted from crypto.getRandomValues, so nothing user- or server-influenced is interpolated raw. The generalized toggle code is behavior-preserving (single call site updated), and a fresh 128-bit id per statement per run cannot collide across tabs or reruns.

Two functional notes, both on the edges:

  1. The stacks lookup has no time bound: WHERE query_id = ... AND trace_type = ... scans all of system.trace_log, whose order key starts with event_date/event_time. On a long-lived busy server with profiling enabled that is a full-table scan per Flame render. The page knows when the run started, so adding event_date >= today() - 1 AND event_time >= <run start - slack> (or just the date bound) would keep it cheap.

  2. The "Profiler period for the next runs" choice is persisted in localStorage and appended to every subsequent query in every tab, indefinitely. If the server constrains query_profiler_real_time_period_ns/query_profiler_cpu_time_period_ns as readonly (common in managed deployments), every future run then fails with a settings-constraint exception, and nothing in the error points back to the Flame period selector — the user's /play looks broken until they think to reset it. Catching that rejection (or detecting the constraint once and downgrading to "server default" with a visible hint) would avoid the trap.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Sep 3, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2f5e9d7]

Summary: ❌

job_name test_name status info comment
Build (arm_tidy, 1/4) FAIL
Build ClickHouse FAIL cidb
Build (arm_tidy, 2/4) FAIL
Build ClickHouse FAIL cidb
Build (arm_tidy, 3/4) FAIL
Build ClickHouse FAIL cidb
Build (arm_tidy, 4/4) FAIL
Build ClickHouse FAIL cidb
Fast test (arm_darwin) DROPPED
Build (amd_debug) DROPPED
Build (amd_asan_ubsan) DROPPED
Build (amd_tsan) DROPPED
Build (amd_msan) DROPPED
Build (amd_binary) DROPPED

AI Review

⚠️ Review sessions stopped as a cybersecurity risk

The model provider stopped these review sessions as a possible cybersecurity risk:

  • attempt 1: gpt-6.1-sol

This summary comes from a session with gpt-5.4. A session is typically stopped when it reaches a memory-safety finding, and the finding is lost with it, so this review can miss a real defect. Please review the change in detail, and run the review internally with a model that has cyber access.

Summary

This PR adds live ProfileTraces delivery to the native and framed HTTP protocols and exposes it in /play as a real-time Flame view. The overall design is in good shape and the previously open macOS-subscription and long-query-id issues are fixed, but one memory-accounting hole remains in the local symbolization path, so I cannot approve it yet.

Findings
  • ⚠️ Majors
    • [src/Interpreters/ProfileTraces.cpp:280] InternalProfileTracesQueue::getBlock bounds a local batch before symbolization, so row_bytes excludes the demangled sample.symbols strings appended later for unsymbolized rows. A batch of deep stacks with long symbols can therefore still materialize several MiB of untracked memory before materialized_bytes is reserved, bypassing the shared queue-budget invariant this code is meant to restore.
    • Suggested fix: account local rows with a size that includes symbol text, or re-check / split the batch after symbolization and before cloneWithColumns.
Tests
  • ⚠️ Add a focused regression that forces long or dense local symbols and verifies the per-batch size cap still holds after symbolization, not only before it.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions: close the remaining local-symbol expansion hole in src/Interpreters/ProfileTraces.cpp:280 and add a focused regression proving the batch cap still holds after symbolization.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Sep 3, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

One discrepancy is that the existing Logs and Metrics views are using the data that is sent during the query run, in the same HTTP stream, and updated in real time. The introduction of the "framing formats" feature made it possible, and only the elegance of the implementation motivated adding these views to the Web UI.

We can't say that for the new Flame view. It isn't updated in real time, it does a separate query (which is complicated, as the data might not be immediately available, or the request can land in a different node of the cluster). This makes it at least different enough, so we need to find a different place for this view.

If we find a different place, there are plenty of other views we can implement, e.g., EXPLAIN visualization.

@alexey-milovidov

Copy link
Copy Markdown
Member

I'm also concerned about the width of these switches. However, the implementation is small enough, maybe it makes sense. Just need to find a good place for these tools.

ei-grad and others added 3 commits September 3, 2026 13:03
…eriod

The `system.trace_log` lookup is now restricted by `event_date` and
`event_time` to the run's start (with slack for clock skew), so it is no
longer a full scan of a table that grows quickly with profiling enabled.

A non-default profiler period selected in the Flame view is first probed
with `SELECT 1` on the connection and is not stored if the server rejects
it (e.g. a read-only settings constraint), since the remembered period is
applied to every later run. An error mentioning `query_profiler_` while a
period is selected now points back to the selector.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Pass the age of the run (a difference of two browser timestamps) instead
of an absolute browser timestamp, and let the server subtract it from
`now()`: the bound no longer depends on the browser and server clocks
agreeing, so the slack shrinks from an hour to a few minutes.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
The run start is stamped before its request leaves the browser, so the
computed age already errs on the safe side; the slack only has to cover
the lookup's own latency and small server clock adjustments.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@ei-grad

ei-grad commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor Author

It isn't updated in real time, it does a separate query (which is complicated, as the data might not be immediately available, or the request can land in a different node of the cluster).

From this perspective, it sounds like it would be nice to first add data visualizations to the Web UI, and then add a "show flame graph" button that explicitly runs the corresponding query in a new query tab with the flame graph visualization preconfigured.

@clickhouse-gh clickhouse-gh Bot added the comp-local clickhouse-local / embedded modes (incl. local file processing). label Sep 4, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

We can do this:

  • Introduce a setting send_profile_traces similar to send_profile_events and send_logs_level, add the corresponding packets to the server protocol;
  • Make the Web UI display a real-time flame graph.

@alexey-milovidov alexey-milovidov added the st-discussion When the implementation aspects are not clear or when the PR is on hold due to questions. label Sep 4, 2026
Add opt-in `send_profile_traces` delivery through bounded per-query
subscriptions. Route samples using signal-safe numeric identifiers so
truncated or reused query IDs cannot mix subscriptions, and order the final
drain after samples already written to the collector pipe.

Expose revision-gated `ProfileTraces` packets and matching HTTP framing
packets, retaining remote host/query identities and symbolizing samples
outside the collector. Suppress allocation sampling while queueing and
serializing traces to avoid resampling those allocations. Handle
trace packets in normal, cancellation, and INSERT error receive paths.

Document the schemas and add functional coverage for streaming, settings
overrides, restricted users, connection reuse, compression, remote queries,
and failures before an INSERT schema is sent.

Related: ClickHouse#117830
Requested in: ClickHouse#117830 (comment)

Co-Authored-By: Codex CLI <[email protected]>
ei-grad and others added 3 commits September 6, 2026 16:56
Consume `profile_traces` events from each query response and aggregate CPU,
real-time, and allocation samples incrementally. Keep zoom references stable
while samples arrive, bound retained stacks and rendered frames, and render
symbol names as text so incoming samples cannot inject markup.

Expose per-tab profiling beside Run and retain the server sampling defaults
unless the user selects a period. Remove the follow-up `system.trace_log`
lookup and log flush, and report unsupported profiling without resubmitting
the query. Keep the toolbar usable on narrow screens.

Add executable aggregation and rendering coverage and update the existing
framing test to recognize flame-graph availability in the tab controls.

Requested in: ClickHouse#117830 (comment)
Related: ClickHouse#117830
Related: ClickHouse#118415

Co-Authored-By: Codex CLI <[email protected]>
Include the published opt-in profiler transport that the live flame graph
consumes, together with its current master base. Preserve the original Web
UI history, including the two local follow-up commits, without rewriting
commits or changing the tested UI files during the merge.

Requested in: ClickHouse#117830 (comment)
Related: ClickHouse#117830
Related: ClickHouse#118415

Co-Authored-By: Codex CLI <[email protected]>
Clearing a result switched back to the result view but left the Flame panel
visible. After profiling a query and disabling profiling for the next run,
the old controls remained beside the new result while the Flame toggle was
hidden.

Hide the panel together with the logs and metrics panels. Extend the Node
regression harness to execute the page's real `clear` method and verify that
only the result view remains visible and profiler samples are discarded.

Requested in: ClickHouse#117830 (comment)
Related: ClickHouse#117830
Related: ClickHouse#118415

Co-Authored-By: Codex CLI <[email protected]>
@ei-grad ei-grad changed the title Flame graph of the query's profiler samples in the Web UI Live flame graphs from streamed profiler samples in the Web UI Sep 6, 2026
Comment thread src/Common/ProfileTracesBlocker.h Resolved
@clickhouse-gh clickhouse-gh Bot added comp-protocols Server wire protocols + request/response handling (native TCP, HTTP, MySQL/PostgreSQL wire protoc... and removed comp-local clickhouse-local / embedded modes (incl. local file processing). labels Sep 6, 2026
ei-grad and others added 4 commits September 7, 2026 09:46
Integrate the updated settings compatibility implementation and hedged
connection cancellation before addressing the profiler transport feedback.
The merge preserves both the transport changes and the current base changes
without conflicts.

Related: ClickHouse#118415
`TCPHandler::updateProfileTracesQueue` modifies the supplied query state,
but only reads connection state. Mark the method const in its declaration
and definition to satisfy `readability-make-member-function-const`, which
is treated as an error in the `arm_tidy` build.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118415&sha=eb2fd93ab7bf6d6b619f92b9d179f79d08807071&name_0=PR&name_1=Build%20%28arm_tidy%29
Related: ClickHouse#118415
Related: ClickHouse#117830

Co-Authored-By: Codex CLI <[email protected]>
Share one deadline between writing the collector marker and waiting for its
acknowledgement. On timeout, close the subscription, discard pending samples,
and log a warning while preserving the query result or original exception.
Disabling delivery cancels the queue immediately, including when native
query analysis throws after applying SQL settings.

Restrict local and forwarded trace batches to the documented CPU, real-time,
and memory sample kinds. Exclude events whose metadata is not represented by
the packet, including jemalloc callbacks from transport allocations, without
changing their collection in `system.trace_log`.

Add native and HTTP regressions for supported types, real jemalloc callback
filtering, collector timeouts, and late SQL opt-out. Document the supported
types and timeout behavior, and complete the auxiliary packet descriptions.

Related: ClickHouse#118415
Related: ClickHouse#117830
Requested in: ClickHouse#117830 (comment)

Co-Authored-By: Codex CLI <[email protected]>
Include the reviewed trace-type filtering and bounded final-flush behavior
so the live flame graph uses the current profiler transport. Preserve both
branch histories and retain the previously tested UI files unchanged.

Related: ClickHouse#118415
Related: ClickHouse#117830
@clickhouse-gh

clickhouse-gh Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 54130b094 with master 213bd8dd0 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 35e918caf; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

116 object files changed (+447.63 KiB total), 1 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Interpreters/ProfileTraces.cpp.o new 177.70 KiB +177.70 KiB
src/CMakeFiles/dbms.dir/Client/InternalTextLogs.cpp.o 47.64 KiB 80.91 KiB +33.28 KiB (+69.86%)
src/CMakeFiles/clickhouse_common_io.dir/Common/TraceSender.cpp.o 59.54 KiB 91.66 KiB +32.12 KiB (+53.95%)
src/CMakeFiles/dbms.dir/Server/WebUIRequestHandler.cpp.o 12.18 MiB 12.21 MiB +30.88 KiB (+0.25%)
src/CMakeFiles/dbms.dir/Client/SecondaryQuerySettings.cpp.o 4.07 KiB 34.32 KiB +30.25 KiB (+742.38%)
src/CMakeFiles/dbms.dir/Server/TCPHandler.cpp.o 935.39 KiB 959.03 KiB +23.64 KiB (+2.53%)
src/CMakeFiles/dbms.dir/Processors/Formats/Framing/IFramingFormat.cpp.o 113.22 KiB 135.63 KiB +22.41 KiB (+19.79%)

719 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

1874 translation units recompiled, 11866 s compile time in total, 1873 of them have a recent master baseline.

Job report

@mintlify

mintlify Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 2f5e9d7.

Approve preview

Comment thread src/Interpreters/ProfileTraces.cpp Resolved
Comment thread src/Interpreters/ProfileTraces.cpp Resolved
Comment thread src/Server/TCPHandler.cpp Resolved
Comment thread programs/server/play.html Resolved
alexey-milovidov and others added 5 commits October 29, 2026 21:10
Master took protocol revision `54495` for `INSERT ... RETURNING`, so
`DBMS_MIN_REVISION_WITH_PROFILE_TRACES` moves to `54496` (and
`DBMS_TCP_PROTOCOL_VERSION` with it); the native protocol spec and the
test helper are updated accordingly. `ClientBase` accepts both
`ProfileTraces` and the `INSERT ... RETURNING` result packets during an
insert. Distributed DDL uses master's `stripInitiatorOnlySettingsFromDDLQuery`
together with the trace-setting strip.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`Connection::receiveProfileTraces` decodes a remote `ProfileTraces` block with
tracked memory, but `RemoteQueryExecutor` destroyed it under the stronger
`ProfileTracesBlocker`, which hid the frees from the memory trackers and left
phantom query usage for every forwarded batch. Use `ProfileTracesStreamBlocker`
there; `pushBlock` already guards its own untracked copies.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ve wire settings

- Delivering samples now requires the same access as `addressToSymbol`: the
  `INTROSPECTION` grant and `allow_introspection_functions`, checked in
  `InternalProfileTracesQueue::create` for both the native protocol and framed HTTP.
- A local sample publishes only offsets in the main executable; any other frame
  (shared libraries, unknown mappings, platforms without the normalization) has
  the address `0`, so runtime addresses are never sent.
- `TCPHandler` writes `ProfileTraces` blocks with `getNativeWireFormatSettings`, like
  its other packets, so a shard with `output_format_native_encode_types_in_binary_format`
  does not send binary types to an initiator that reads textual ones.

Tests: denial without the grant and with `allow_introspection_functions = 0`, a
remote query with binary type encoding, and the integration tests enable the
access they now need.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…introspection

`abandonProfileTraces` cleared the cell's shared `flameAvailable` even when
another statement result of the same multi-query cell still had samples. Keep
it while a sibling result has `_flame_requested`, with a harness regression.

The Web UI also sets `allow_introspection_functions=1` when it requests live
profiling, which the server now requires, and explains an introspection denial.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- `05136_profile_traces_remote_decode` scanned `system.symbols`, which exceeded
  the 30-second time limit in debug builds under the flaky check. Look up the
  mangled names of the query's own `system.trace_log` frames with
  `addressToSymbol` instead.
- `05331_native_profile_traces_async_uploads`: a per-table
  `SYSTEM FLUSH ASYNC INSERT QUEUE` does not wait for a batch a deadline worker
  has already taken, so the rows could still be in flight. Wait for them.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117830&sha=e1e304e2893ddfdd8ed1962062c94aafe46fd421&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20flaky%20check%29
ClickHouse#117830

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Merged master and resolved conflicts: INSERT ... RETURNING took protocol revision 54495 on master, so DBMS_MIN_REVISION_WITH_PROFILE_TRACES (and DBMS_TCP_PROTOCOL_VERSION) moved to 54496, with the protocol spec and test helper updated. Addressed all five review threads (introspection access check, executable-only offsets, Native wire settings for trace packets, tracked frees of forwarded blocks, Flame toggle in multi-query cells) and fixed the flaky-check failures of 05136_profile_traces_remote_decode (slow system.symbols scan in debug) and 05331_native_profile_traces_async_uploads (per-table async insert flush does not wait for batches already taken by a deadline worker). Note the behaviour change: send_profile_traces now requires the INTROSPECTION grant and allow_introspection_functions; the Web UI sets the latter when Flame graph is enabled. The two previous performance comparison flags (skip_index_planning_with_patch_parts, json_to_string) are in code paths this PR does not touch while send_profile_traces is off; the new CI run will show whether they reproduce.

The `RESTORE` starter does not read the table data itself: `StorageMemory`
restores its data in tasks that `RestorerFromBackup::schedule` runs on the
restore thread pool, so no large allocation has `RestoreStarter::doRestore`
on its stack and the check failed every time. The samples of those tasks
are delivered to the query, so look for `StorageMemory::restoreDataImpl`
instead.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117830&sha=a72441c7557bdb332e46332e173e627f80460710&name_0=PR&name_1=Fast%20test
ClickHouse#117830

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Fixed the Fast test failure of 05176_profile_traces_sql_settings_lifecycle (it failed every time, not intermittently): the RESTORE starter doesn't read the table data on its own thread. StorageMemory::restoreDataImpl runs in tasks that RestorerFromBackup::schedule puts on the restore thread pool, so no large allocation had RestoreStarter::doRestore on its stack. Those samples do reach the query, so the test now looks for StorageMemory::restoreDataImpl instead. I reproduced the failure on a local build and the fixed test passed 5 runs out of 5.

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Merged master and fixed the Fast test / arm_tidy build failure: master changed SymbolIndex::Symbol to store a name reference instead of a name field, so ProfileTraces.cpp now resolves names via SymbolIndex::getSymbolNameCString. Built locally; 05099, 05100, 05111, 05158 profile-trace tests pass.

Comment thread programs/server/play.html Resolved
alexey-milovidov and others added 7 commits November 8, 2026 08:50
Resolve conflicts with master:
- `DBMS_MIN_PROTOCOL_VERSION_WITH_PROFILE_EVENTS_IN_SECONDARY_INSERT` took revision 54496 on master,
  so `DBMS_MIN_REVISION_WITH_PROFILE_TRACES` moves to 54497 and `DBMS_TCP_PROTOCOL_VERSION` to 54497.
  The protocol docs and the test helper are updated accordingly.
- `TraceSender` now takes the thread origin in `Origin` (master); the profile trace subscription
  ID is carried in `Origin::profile_traces_id`, and `QUERY_ID_MAX_LEN` is 93 to keep the record
  within 512 bytes.
- `executeQuery` takes both `result_details` (master) and `on_query_settings_applied` (this PR).
- `RemoteInserter` and `TCPHandler::sendInsertProfileEvents` combine the final secondary `INSERT`
  `ProfileEvents` report (master) with disabled trace delivery for remote uploads (this PR).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
After ClickHouse@8bffadb8e1d4 on master, `SymbolIndex::findSymbol`
takes an offset inside the main executable, so passing it the runtime address of a locally captured
frame resolved nothing and every `symbols` element of `ProfileTraces` became empty. Frames captured
by the server itself are resolved with `findSymbolByAddress`, as `system.trace_log` does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A trace subscription created with the access granted by the wire or URL settings was kept after
the query's SQL `SETTINGS` revoked it (for example `allow_introspection_functions = 0`), so the
stream still delivered symbols and executable offsets. When the settings are reconciled after SQL
`SETTINGS` (`TCPHandler::updateProfileTracesQueue` and `syncFramingProfileTracesWithSettings`),
an existing subscription is now discarded with its queued samples unless `addressToSymbol` is
still granted, and `InternalProfileTracesQueue::create` then fails the query with the same error
as `addressToSymbol`.

`05176` and `05177` cover the revocation on HTTP and Native. Both tests also retry a `BACKUP` or
`RESTORE` whose background allocation samples were all lost in the shared, bounded profiler pipe,
which made them fail in the flaky check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`appendProfileTraces` skips painting while the tab of the result is hidden, but activation
repainted only the cell owning the shared chrome. A Flame view of another cell that received
samples in the background, and whose query then finished, stayed stale. The result now records
unpainted samples, and `applyDeferredLayout`, which activation calls for every result of the tab,
repaints such Flame views via `paintDeferredFlameGraph`. The flame graph harness covers the
two-cell sequence.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Concurrent copies of a test in the flaky check fill the shared, bounded profiler pipe, which drops
samples silently, so `05139_native_profile_traces_utf8` and `05331_native_profile_traces_async_uploads`
sometimes observed no samples at all. Retry the query in that case, as `05100_native_profile_traces`
already does.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117830&sha=bb8f33926e860990bb7dee49610311761a62300f&name_0=PR
PR: ClickHouse#117830

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`05111_profile_traces_supported_types` and `05113_profile_traces_flush_timeout` are
`no-parallel` and run longer than 7.5 s, which the Fast test rejects for new tests.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117830&sha=9486bad23d2f9590c32444b2c6f644597a6cb458&name_0=PR&name_1=Fast%20test
ClickHouse#117830

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread src/Common/TraceSender.h Resolved
Comment thread src/Interpreters/ProfileTraces.cpp Resolved
alexey-milovidov and others added 6 commits November 18, 2026 00:37
# Conflicts:
#	programs/server/play.html
#	src/Client/Connection.cpp
…macOS sampler

`ProfilerSampler::sample` passes an explicit `TraceSender::Origin`, which left
`profile_traces_id` at 0, so live flame graphs received no `CPU` or `Real`
samples on macOS. Read the sampled thread's subscription and its
`ProfileTracesStreamBlocker` flag while the thread is suspended, like the
calling-thread `TraceSender::send` does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every row of a batch repeats the query ID, which a local sample does not store,
so a long query ID expanded a 1024-row batch far beyond the queue's byte budget.
Bound a batch by its expanded size (about 1 MiB) as well as by rows, and keep
the bytes of the returned block reserved in the shared 256 MiB budget until the
transport requests the next block, or the subscription is cancelled or destroyed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he whole test

The test failed in CI only for the first mode (`async_socket_for_remote=0`,
`use_hedged_requests=0`): every attempt received hundreds of remote samples,
but no low-probability decoder allocation sample reached `system.trace_log`.
Keep the per-mode checks of remote samples and of absent decoder feedback,
and require decoder coverage over all queries of the test.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117830&sha=latest&name_0=PR&name_1=Stateless%20tests%20(arm_binary%2C%20AsyncInsert%2C%20s3%20storage%2C%20sequential)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
{
const auto & sample = samples.front();
const size_t sample_bytes = sample.byteSize();
size_t row_bytes = sample_bytes;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[Major] This byte cap is still computed before local samples are symbolized. For unsymbolized rows row_bytes accounts for the repeated host_name / query_id, but not for the sample.symbols strings appended later in the local path below. A batch of deep stacks with long demangled names can therefore still materialize several MiB of untracked symbol text before materialized_bytes is reserved, bypassing the queue / registry byte bounds this fix is meant to restore.

Please either budget local rows using a size that includes symbol text, or trim/re-split the batch after symbolization before cloning the block.

This branch has not been deployed

No deployments
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 comp-protocols Server wire protocols + request/response handling (native TCP, HTTP, MySQL/PostgreSQL wire protoc... external Author is not a member of the ClickHouse organization pr-improvement Pull request with some product improvements st-discussion When the implementation aspects are not clear or when the PR is on hold due to questions.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants