Expose per-thread untracked_memory in system.stack_trace by azat · Pull Request #103065 · ClickHouse/ClickHouse · GitHub
Skip to content

Expose per-thread untracked_memory in system.stack_trace#103065

Merged
azat merged 1 commit into
ClickHouse:masterfrom
azat:untracked_memory-introspection
Apr 18, 2026
Merged

Expose per-thread untracked_memory in system.stack_trace#103065
azat merged 1 commit into
ClickHouse:masterfrom
azat:untracked_memory-introspection

Conversation

@azat

@azat azat commented Apr 18, 2026

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Improvement

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

Expose per-thread untracked_memory in system.stack_trace

Adds a new untracked_memory column to system.stack_trace that reports the per-thread atomic-less allocation counter (ThreadStatus::untracked_memory) which has not yet been propagated to the parent MemoryTracker. The value is read in the signal handler running in the target thread's context (signal-safe, plain Int64 load), and the type is Int64 since the counter can go negative between flushes.

Version info

  • Merged into: 26.4.1.1052
  • Backported to: 26.3.10.26, 26.2.17.16, 26.1.12.8

@clickhouse-gh

clickhouse-gh Bot commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Apr 18, 2026
@azat

azat commented Apr 18, 2026

Copy link
Copy Markdown
Member Author

On an empty server

azat.local$  :) select sum(untracked_memory) from system.stack_trace

SELECT sum(untracked_memory)
FROM system.stack_trace

Query id: 6086a2d7-efcc-4de7-8183-55b61eea40bb

   ┌─sum(untracked_memory)─┐
1. │              -5634717 │ -- -5.63 million
   └───────────────────────┘

Adds a new `untracked_memory` column to `system.stack_trace` that
reports the per-thread atomic-less allocation counter
(`ThreadStatus::untracked_memory`) which has not yet been propagated to
the parent `MemoryTracker`. The value is read in the signal handler
running in the target thread's context (signal-safe, plain `Int64`
load), and the type is `Int64` since the counter can go negative
between flushes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@azat azat force-pushed the untracked_memory-introspection branch from 686cc31 to 24205a1 Compare April 18, 2026 11:10
@serxa serxa self-assigned this Apr 18, 2026
@clickhouse-gh

clickhouse-gh Bot commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.00% 84.00% +0.00%
Functions 91.10% 91.10% +0.00%
Branches 76.50% 76.50% +0.00%

Changed lines: 85.71% (24/28) · Uncovered code

Full report · Diff report

@azat

azat commented Apr 18, 2026

Copy link
Copy Markdown
Member Author

@azat azat enabled auto-merge April 18, 2026 22:18
@azat azat added this pull request to the merge queue Apr 18, 2026
Merged via the queue into ClickHouse:master with commit 794c01e Apr 18, 2026
157 of 161 checks passed
@azat azat deleted the untracked_memory-introspection branch April 18, 2026 22:30
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Apr 18, 2026
robot-clickhouse-ci-2 added a commit that referenced this pull request Apr 20, 2026
Cherry pick #103065 to 26.1: Expose per-thread untracked_memory in system.stack_trace
robot-clickhouse added a commit that referenced this pull request Apr 20, 2026
robot-clickhouse-ci-2 added a commit that referenced this pull request Apr 20, 2026
Cherry pick #103065 to 26.2: Expose per-thread untracked_memory in system.stack_trace
robot-clickhouse added a commit that referenced this pull request Apr 20, 2026
robot-clickhouse-ci-2 added a commit that referenced this pull request Apr 20, 2026
Cherry pick #103065 to 26.3: Expose per-thread untracked_memory in system.stack_trace
robot-clickhouse added a commit that referenced this pull request Apr 20, 2026
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Apr 20, 2026
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Apr 20, 2026
clickhouse-gh Bot added a commit that referenced this pull request Apr 20, 2026
Backport #103065 to 26.1: Expose per-thread untracked_memory in system.stack_trace
azat added a commit that referenced this pull request Apr 21, 2026
Backport #103065 to 26.2: Expose per-thread untracked_memory in system.stack_trace
azat added a commit that referenced this pull request Apr 21, 2026
Backport #103065 to 26.3: Expose per-thread untracked_memory in system.stack_trace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-improvement Pull request with some product improvements pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v25.12-must-backport v26.2-must-backport v26.3-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants