Commit f51ba22
committed
perf: give
This PR stops the recursion-depth guard from rebuilding `Core.Context` on every recursive step. Roughly 96% of `Core.Context` reconstructions exist only to bump the depth counter, and each one paid a reference count increment per pointer field.
`withReader` can never reuse the `Context` record, so keeping `currRecDepth` there made every `withIncRecDepth` rebuild it. As its own reader layer the depth is just an extra argument, so a recursion step neither allocates nor touches a reference count. The layer sits inside the `Context` reader so that a bare `read` still resolves to `Context`, and `CoreM.run` gains an initial-depth parameter so nested command elaboration keeps inheriting its caller's depth.
Note this changes `CoreM`'s arity, which is externally observable in LCNF output.currRecDepth its own ReaderT layer in CoreM
1 parent df1b1f0 commit f51ba22
2 files changed
Lines changed: 15 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
223 | | - | |
224 | 223 | | |
225 | 224 | | |
226 | 225 | | |
| |||
252 | 251 | | |
253 | 252 | | |
254 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
255 | 258 | | |
256 | | - | |
| 259 | + | |
257 | 260 | | |
258 | 261 | | |
259 | 262 | | |
| |||
306 | 309 | | |
307 | 310 | | |
308 | 311 | | |
309 | | - | |
310 | | - | |
| 312 | + | |
| 313 | + | |
311 | 314 | | |
312 | 315 | | |
313 | 316 | | |
| |||
427 | 430 | | |
428 | 431 | | |
429 | 432 | | |
430 | | - | |
431 | | - | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
432 | 436 | | |
433 | | - | |
434 | | - | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
435 | 440 | | |
436 | 441 | | |
437 | 442 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
270 | | - | |
271 | 270 | | |
272 | 271 | | |
273 | 272 | | |
| |||
288 | 287 | | |
289 | 288 | | |
290 | 289 | | |
291 | | - | |
| 290 | + | |
292 | 291 | | |
293 | 292 | | |
294 | 293 | | |
| |||
1096 | 1095 | | |
1097 | 1096 | | |
1098 | 1097 | | |
1099 | | - | |
| 1098 | + | |
1100 | 1099 | | |
1101 | 1100 | | |
1102 | 1101 | | |
| |||
0 commit comments