Skip to content

Conversation

Copy link

Copilot AI commented Nov 15, 2025

Implements peak stack usage tracking for thread analyzer to identify worst-case stack requirements over thread lifetime. Stack painting (0xaa initialization via CONFIG_INIT_STACKS) already exists but only showed current usage, not historical peak.

Changes

Core Implementation

  • _thread_stack_info: Added high_watermark field to persist peak usage across analyzer runs
  • thread_analyzer_info: Added stack_high_watermark to pass data to callbacks
  • thread_analyze_cb(): Updates watermark when current usage exceeds stored maximum
  • thread_print_cb(): Displays watermark in both runtime/non-runtime stat modes

Configuration

  • CONFIG_THREAD_ANALYZER_STACK_HIGH_WATERMARK: New Kconfig option (default: y)
  • Conditional compilation guards around all watermark code

Documentation

  • Enhanced API docs in thread_analyzer.h explaining stack painting mechanism
  • Updated thread-analyzer.rst with watermark usage and example output
  • Kconfig help text details benefits: optimization, worst-case detection, debugging

Testing

  • Added debug.thread_analyzer.high_watermark test case
  • Updated test harness regex patterns for watermark output

Example Output

thread_b            : STACK: unused 648 usage 376 / 1024 (36 %); CPU: 7 %
                    : High watermark: 412 / 1024 (40 %)

Watermark shows thread peaked at 412 bytes despite current 376 byte usage—useful for identifying undersized stacks or optimization opportunities.

Original prompt

add stack painting so that thread analyzer allows to visualize high watermark of each stack. add thorough socks throughout the new api, Kconfig. etc


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add stack painting for thread analyzer high watermark visualization Add stack high watermark tracking to thread analyzer Nov 15, 2025
Copilot finished work on behalf of kartben November 15, 2025 20:01
Copilot AI requested a review from kartben November 15, 2025 20:01
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.

2 participants