Skip to content

Conversation

@kakkoyun
Copy link
Member

What does this PR do?

Motivation

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • New code is free of linting errors. You can check this by running ./scripts/lint.sh locally.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild.

Unsure? Have a question? Request a review!

Copy link
Member Author

kakkoyun commented Nov 20, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@pr-commenter
Copy link

pr-commenter bot commented Nov 20, 2025

Benchmarks

Benchmark execution time: 2025-11-20 13:44:51

Comparing candidate commit d0b2ea6 in PR branch kakkoyun/11-20-stacktrace-keep_skipandcapturewithinternalframes_name_visible_in with baseline commit f3a0f84 in branch kakkoyun/11-20-stacktrace-remove_unused_prefixtrie_implementation.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 9 metrics, 0 unstable metrics.

…ation

Replace regex-based symbol parsing with string operations to eliminate
per-frame allocations in stack capture.

Performance improvements:
- parseSymbol: 0 allocs/op (was ~2 allocs/op)
- BenchmarkCaptureWithRedaction/depth_10: 38→6 allocs/op (84% reduction)
- BenchmarkCaptureWithRedaction/depth_50: 118→6 allocs/op (95% reduction)
- Speed: 19.2µs→4.1µs @ depth=10 (79% faster)
- Memory: 8966B→5296B @ depth=10 (41% reduction)

Allocations are now constant regardless of stack depth.
The segmentPrefixTrie follows a write-once-read-many pattern where all
writes occur during package initialization before any concurrent access.

After initialization, the trie is effectively immutable and can be safely
read by multiple goroutines without synchronization overhead.
Deleted character-based prefixTrie implementation (~130 lines) as
segmentPrefixTrie is the only trie used in production code.

segmentPrefixTrie provides better performance for path-based prefix
matching and is the sole implementation used by the stacktrace filtering
system.
Introduced captureStack() as the single source of truth for stack
capture implementation, eliminating code duplication across capture
functions.

This consolidates the iterator(skip, maxDepth, opts).capture() pattern
into a single helper, reducing duplicate code by ~20 lines.
Add *.prof to .gitignore to exclude profiling output files.
@kakkoyun kakkoyun changed the base branch from kakkoyun/11-20-stacktrace-add_capturestack_helper_for_dry_capture_logic to graphite-base/4153 November 20, 2025 12:59
@kakkoyun kakkoyun changed the base branch from graphite-base/4153 to kakkoyun/11-20-stacktrace-add_capturestack_helper_for_dry_capture_logic November 20, 2025 13:00
@kakkoyun kakkoyun changed the base branch from kakkoyun/11-20-stacktrace-add_capturestack_helper_for_dry_capture_logic to graphite-base/4153 November 20, 2025 13:00
@kakkoyun kakkoyun force-pushed the kakkoyun/11-20-stacktrace-keep_skipandcapturewithinternalframes_name_visible_in branch from 216c654 to d0b2ea6 Compare November 20, 2025 13:01
@kakkoyun kakkoyun changed the base branch from graphite-base/4153 to kakkoyun/11-20-stacktrace-remove_unused_prefixtrie_implementation November 20, 2025 13:01
@kakkoyun kakkoyun force-pushed the kakkoyun/11-20-stacktrace-remove_unused_prefixtrie_implementation branch from f3a0f84 to 173e13b Compare November 20, 2025 13:45
@kakkoyun kakkoyun changed the base branch from kakkoyun/11-20-stacktrace-remove_unused_prefixtrie_implementation to kakkoyun/11-20-stacktrace-remove_unnecessary_locking_from_segmentprefixtrie November 20, 2025 13:52
@kakkoyun kakkoyun closed this Nov 20, 2025
@kakkoyun kakkoyun deleted the kakkoyun/11-20-stacktrace-keep_skipandcapturewithinternalframes_name_visible_in branch November 20, 2025 13:56
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