perf: skip internal frames in determine_callsite

Summary

Optimize caller_locations call in determine_callsite to skip the first 4 internal frames by starting at frame 5 instead of frame 1. Also reduces the frame limit from 30 to 15 since most callsites are within this range.

Changes

  • Skip internal frames (format_data, format_message, add, info) by using caller_locations(5, 15) instead of caller_locations(1, 30)
  • Add documented constants INTERNAL_FRAMES_TO_SKIP and MAX_FRAMES_TO_INSPECT
  • Add spec to validate internal frame structure to catch any future changes to the call stack

Expected Performance Improvement

Based on the profiling in #60 (closed), this is the primary bottleneck. By skipping 4 frames and reducing the frame limit by half:

  • ~20-30% reduction in stack frame processing overhead
  • Fewer frames to iterate over when filtering by IGNORE_PATHS patterns
  • Reduced memory allocation from processing unnecessary frames

Relates-to: #60 (closed)

Merge request reports

Loading
Loading