Commit 4b5711f
committed
Bound nrepl-completed-requests with a FIFO cap
`nrepl--mark-id-completed' moved request handlers from
`nrepl-pending-requests' to `nrepl-completed-requests' with no upper
bound on the latter. Each entry retains its handler closure (often
hundreds of bytes once you count its lexical environment), so a long-
running session accumulated thousands of stale handlers in memory.
The completed table exists so late messages -- responses arriving
after their request's `done' status -- can still find a callback to
dispatch them. In practice that window is sub-second. Add a FIFO
cap so the table is bounded to the recently-completed entries:
- New defcustom `nrepl-completed-requests-max-size' (default 1000).
- New buffer-local `nrepl--completed-requests-order' tracking
insertion order.
- `nrepl--mark-id-completed' enqueues each id and, when the cap is
exceeded, dequeues + removes the oldest.
1000 is enough to cover any plausible late-message window: requests
complete in milliseconds, so this caps about a second of activity.
Setting the size to 0 bypasses the eviction, restoring the previous
unbounded behavior for users who have a reason to keep everything.
Three Buttercup specs cover the cap, FIFO eviction, and the 0-disables
case.1 parent fd2dfce commit 4b5711f
3 files changed
Lines changed: 78 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| |||
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
113 | 132 | | |
114 | 133 | | |
115 | 134 | | |
| |||
138 | 157 | | |
139 | 158 | | |
140 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
141 | 164 | | |
142 | 165 | | |
143 | 166 | | |
| |||
583 | 606 | | |
584 | 607 | | |
585 | 608 | | |
586 | | - | |
| 609 | + | |
| 610 | + | |
587 | 611 | | |
588 | 612 | | |
589 | 613 | | |
| |||
658 | 682 | | |
659 | 683 | | |
660 | 684 | | |
661 | | - | |
662 | | - | |
663 | | - | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
664 | 691 | | |
665 | 692 | | |
666 | | - | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
667 | 701 | | |
668 | 702 | | |
669 | 703 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
290 | 328 | | |
291 | 329 | | |
292 | 330 | | |
| |||
0 commit comments