Repository navigation
Conversation
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]>
|
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 ( Two functional notes, both on the edges:
|
|
Workflow [PR], commit [2f5e9d7] Summary: ❌
AI Review
|
|
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. |
|
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. |
…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]>
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. |
|
We can do this:
|
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]>
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]>
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
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes116 object files changed (+447.63 KiB total), 1 added.
719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units1874 translation units recompiled, 11866 s compile time in total, 1873 of them have a recent master baseline. |
The setting is not in any release yet, and the style check requires a record under the current version. Report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117830&sha=672541fced127a0f42fa5c73f6bd1bfc89b17098&name_0=PR&name_1=Style%20check PR: ClickHouse#117830 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
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]>
|
🕵 Merged |
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]>
|
🕵 Fixed the |
Master made `SymbolIndex::Symbol` store a name reference instead of a `name` field, so the build failed with "no member named 'name' in 'DB::SymbolIndex::Symbol'". https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117830&sha=latest&name_0=PR&name_1=Fast%20test ClickHouse#117830 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged |
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]>
# Conflicts: # programs/server/play.html # src/Client/Connection.cpp
…Settings` Co-Authored-By: Claude Opus 5.5 <[email protected]>
…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]>
…e_decode` `SYSTEM FLUSH LOGS trace_log` exceeded the 30 s limit of the profiled queries in the flaky check. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117830&sha=latest&name_0=PR&name_1=Stateless%20tests%20(amd_debug%2C%20flaky%20check) 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; |
There was a problem hiding this comment.
[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.

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 supportsCPU,Real, and positiveMemorySampleallocation 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_logorSYSTEM FLUSH LOGS. Because samples disclose symbol names and executable offsets, delivery requires the same access asaddressToSymbol(theINTROSPECTIONgrant andallow_introspection_functions), and only offsets in the server executable are sent; other frame addresses are0.Includes the transport changes from the related PR so both pull requests target
masterand receive CI checks.Related: #118415
Changelog category (leave one):
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]