Commit 25bfecf
committed
perf(measurement): line-metrics cache stops adding when full, not clear-on-overflow
The process-wide line-metrics cache clear()-ed every entry once it passed 50,000
distinct styles — a non-atomic check-then-clear that is a thundering-herd recompute
under concurrent rendering. Stop inserting at the cap and keep the existing entries
instead; this runs only on a cache miss, never on the per-measurement get() path.
Measured line metrics are unchanged. Distinct styles are few in real use, so this
only guards a pathological style explosion.
Finding 13 (cache). (The width-cache LRU, Finding 9, was dropped: it added a
per-get reorder cost to the hot path for a rare-overflow benefit.)1 parent 031db67 commit 25bfecf
2 files changed
Lines changed: 18 additions & 3 deletions
File tree
- src/main/java/com/demcha/compose/engine/measurement
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
83 | 92 | | |
84 | 93 | | |
85 | 94 | | |
| |||
Lines changed: 9 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
104 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
105 | 112 | | |
106 | | - | |
107 | 113 | | |
108 | 114 | | |
109 | 115 | | |
| |||
0 commit comments