Commit 398da01
perf: cache longest_load_path and compute_filename results
Add class-level caches to StacktraceInterface for two expensive per-frame
operations that repeat with identical inputs:
longest_load_path: Previously iterated $LOAD_PATH for every frame,
creating many intermediate strings. Now cached by abs_path with automatic
invalidation when $LOAD_PATH.size changes (e.g. after Bundler.require).
compute_filename: Many frames share identical abs_paths (same gem files
appear in every exception). Results are cached in separate in_app/
not_in_app hashes keyed by abs_path only, avoiding composite array keys.
Cache invalidates on project_root or $LOAD_PATH changes.
Both caches are deterministic — same inputs always produce the same
filename. The caches grow proportionally to the number of unique source
files seen, which is naturally bounded in any application.1 parent 688bd62 commit 398da01
1 file changed
+75
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
26 | 97 | | |
27 | 98 | | |
28 | 99 | | |
| |||
33 | 104 | | |
34 | 105 | | |
35 | 106 | | |
36 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
37 | 110 | | |
38 | 111 | | |
39 | 112 | | |
| |||
86 | 159 | | |
87 | 160 | | |
88 | 161 | | |
89 | | - | |
| 162 | + | |
90 | 163 | | |
91 | 164 | | |
92 | 165 | | |
| |||
0 commit comments