You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf: cache backtrace line parsing and Line object creation
⚠️ Needs closer review — introduces class-level mutable caches.
Add two layers of caching to Backtrace::Line.parse to avoid redundant
work when the same backtrace lines appear across multiple exceptions
(which is the common case in production):
1. Parse data cache: Caches the extracted (file, number, method,
module_name) tuple by the raw unparsed line string. Avoids re-running
the regex match and string extraction on cache hit.
2. Line object cache: Caches complete Line objects by (unparsed_line,
in_app_pattern) pair. Avoids creating new Line objects entirely when
the same line has been seen with the same pattern.
Both caches are bounded to 2048 entries and clear entirely when the
limit is reached (simple, no LRU overhead).
Also cache the compiled in_app_pattern Regexp in Backtrace.parse to
avoid Regexp.new on every exception capture.
Safety: Line objects are effectively immutable after creation (all
attributes are set in initialize and only read afterwards). The parse
inputs are deterministic — same unparsed_line always produces the same
parsed data.
0 commit comments