Commit 79ac920
committed
Reuse decls in resolve_type_names when no type names change
`resolve_type_names` previously rebuilt every declaration, member, and
type even when type name resolution did not change anything. The first
resolve must produce absolutized type names, so its cost is
unavoidable; but the second and later resolves were re-allocating
identical structures for no benefit, pressuring GC heavily.
This change makes every `map_type_name` / `map_type` / `resolve_*`
helper return its receiver when each child maps back to a value
`equal?` to the original. Combined with the existing flyweight
behavior of `TypeName` and `Namespace`, declarations whose type names
were already absolute are now reused verbatim across resolves.
The first resolve is therefore unchanged in both wall time and
allocations. The numbers below compare the second-and-later resolves
only, measured on conference-app (kaigionrails/conference-app):
- allocated per resolve: 20.60 MB / 387,664 objects
-> 3.52 MB / 64,293 objects (-83%)
- retained over 10 resolves: 18.36 MB / 346,343 objects
-> 1.25 MB / 22,973 objects (-93%)
- resolve wall time, p99: 112.7 ms -> 98.3 ms (-12.8%)
- GC major / 50 resolves: 4 -> 1 (-75%)
Single-shot CLI usage (`rbs list` etc.) calls resolve_type_names only
once, so it sees no change. Long-running clients such as Steep that
re-resolve repeatedly are the primary beneficiaries.1 parent fcc1685 commit 79ac920
7 files changed
Lines changed: 358 additions & 225 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
105 | 151 | | |
106 | 152 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
77 | 73 | | |
78 | | - | |
79 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
80 | 78 | | |
81 | 79 | | |
82 | 80 | | |
83 | 81 | | |
84 | 82 | | |
85 | | - | |
86 | | - | |
| 83 | + | |
| 84 | + | |
87 | 85 | | |
88 | | - | |
| 86 | + | |
89 | 87 | | |
90 | 88 | | |
91 | 89 | | |
| |||
0 commit comments