Skip to content

Add UntrackedMemory asynchronous metric - #104690

Merged
mstetsyuk merged 11 commits into
masterfrom
unaccounted-memory-metric
Jun 2, 2026
Merged

mstetsyuk merged 11 commits into
masterfrom
unaccounted-memory-metric

Conversation

@mstetsyuk

@mstetsyuk mstetsyuk commented May 12, 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):

Add an asynchronous metric UntrackedMemory reporting the sum of all threads' untracked memory counters. This value is also included in MEMORY_LIMIT_EXCEEDED exception messages.

Version info

  • Merged into: 26.6.1.339

@clickhouse-gh

clickhouse-gh Bot commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b71055c]

Summary: ❌

job_name test_name status info comment
Stateless tests (arm_asan_ubsan, targeted) FAIL
Server died FAIL cidb
AST fuzzer (amd_debug, targeted, old_compatibility) FAIL
Logical error: 'Unexpected expression in JOIN ON section. Expected boolean (UInt8), got 'Nothing'. expression: (STID: 4699-47e3) FAIL cidb
Stateless tests (amd_tsan, parallel, 1/2) FAIL
00175_obfuscator_schema_inference FAIL cidb
Integration tests (amd_msan, 1/6) FAIL
test_refreshable_mat_view_replicated/test.py::test_circular_dependencies_survive_restart FAIL cidb
Unit tests (asan_ubsan) FAIL

AI Review

Summary

This PR adds the UntrackedMemory asynchronous metric by registering each thread's unflushed untracked_memory counter, and includes the aggregate in MEMORY_LIMIT_EXCEEDED diagnostics. The current version addresses the earlier review issues around fast-path atomic RMW overhead, exception-path restoration, changelog text, regression coverage for the metric, and registry allocations under the mutex. I did not find any remaining blocker or major issue in the current diff.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label May 12, 2026
@mstetsyuk mstetsyuk changed the title add UntrackedMemory async metric Add UntrackedMemory asynchronous metric May 12, 2026
Comment thread src/Common/CurrentMemoryTracker.cpp Resolved
Comment thread src/Common/AsynchronousMetrics.cpp Resolved
Comment thread src/Common/ThreadStatus.h Resolved
@azat azat self-assigned this May 12, 2026
Comment thread src/Common/CurrentMemoryTracker.cpp Resolved
Comment thread src/Common/AsynchronousMetrics.cpp Resolved
Comment thread src/Common/UntrackedMemoryRegistry.cpp Resolved
@mstetsyuk

Copy link
Copy Markdown
Member Author

@mstetsyuk
mstetsyuk marked this pull request as ready for review May 15, 2026 09:48
@mstetsyuk
mstetsyuk requested a review from azat May 15, 2026 13:54

@azat azat left a comment

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.

Looks good (only few minor comments), and the metric will be very useful!

Let's also mark it as "Performacne improvement" to run all perf tests (including amd64 and additional tests in private)

Comment thread src/Common/UntrackedMemoryRegistry.h Resolved
Comment thread src/Common/ThreadStatus.h Resolved
Comment thread src/Common/CurrentMemoryTracker.cpp Resolved
@mstetsyuk mstetsyuk added pr-performance Pull request with some performance improvements and removed pr-improvement Pull request with some product improvements labels May 21, 2026
@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label May 21, 2026
@mstetsyuk
mstetsyuk requested a review from azat May 21, 2026 18:22

@azat azat left a comment

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.

Comment thread src/Common/UntrackedMemoryRegistry.h Resolved
Comment thread src/Common/UntrackedMemoryRegistry.h Resolved
This was referenced Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance pr-improvement Pull request with some product improvements pr-performance Pull request with some performance 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.

4 participants