Add Python stack trace analysis tool with contextual filtering for debugging#142
Add Python stack trace analysis tool with contextual filtering for debugging#142Copilot wants to merge 3 commits intocandidate-9.14.xfrom
Conversation
Co-authored-by: jakesmith <902700+jakesmith@users.noreply.github.com>
jakesmith
left a comment
There was a problem hiding this comment.
@copilot - this isn't a sufficient solution. There may be interesting stacks waiting on locks/mutexes/wait conditions.
What makes them non-interesting is a combination of the top of the stack and some intermediate stack call higher up, that shows it's benign and truly idle.
So the scheme needs to represent this info in the ignore list
Co-authored-by: jakesmith <902700+jakesmith@users.noreply.github.com>
I've redesigned the filtering logic to use contextual patterns that require BOTH low-level wait primitives AND high-level idle context. This prevents false positives where interesting stacks waiting on locks/mutexes get incorrectly filtered out. The new approach uses two pattern types:
For example, a stack with Commit d9f94ed implements this improvement. |
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.