Add Python stack trace analysis tool with contextual filtering for debugging #142
+658
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a new Python script
tools/analyze_stacks.pythat helps developers analyze stack traces to identify interesting ones and filter out mundane (idle) stacks during debugging sessions.Problem
When debugging multi-threaded applications, developers often encounter many stack traces where most threads are idle - waiting on synchronization primitives, thread pools, or other blocking operations. These idle stacks create noise that makes it difficult to identify the truly interesting stacks that show active work or potential issues.
For example, the following stack traces are all mundane (showing futex waits in thread pools):
Solution
The new
analyze_stacks.pyscript uses a sophisticated two-tier filtering approach:Parses stack traces from various debugging tools (gdb, eu-stack, etc.)
Contextual filtering to avoid false positives - requires BOTH:
mutex_lock,futex_wait,pthread_cond_wait, etc.CPooledThreadWrapper::run,RoxieQueue::wait, etc.Simple patterns for always-idle functions:
start_thread,epoll_wait,PerfTracerProvides flexible output to show either interesting stacks (default) or filtered mundane stacks
Key Improvement: Avoids False Positives
The contextual filtering prevents marking interesting stacks as mundane just because they use synchronization primitives:
mutex_lock -> Waiter::wait -> CPooledThreadWrapper::run(thread pool waiting)mutex_lock -> acquireLock -> processImportantData(active work)Usage
Integration
This tool complements existing HPCC Platform debugging infrastructure:
doperfperformance tooleu-stackoutput formatThe script successfully identifies the problem case (futex waits in thread pools) as 100% mundane, while preserving important stacks that happen to use synchronization primitives for productive work.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.