Commit a1266f4
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 0ff2841 commit a1266f4
3 files changed
Lines changed: 78 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
| 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 | | |
| |||
562 | 585 | | |
563 | 586 | | |
564 | 587 | | |
565 | | - | |
| 588 | + | |
| 589 | + | |
566 | 590 | | |
567 | 591 | | |
568 | 592 | | |
| |||
637 | 661 | | |
638 | 662 | | |
639 | 663 | | |
640 | | - | |
641 | | - | |
642 | | - | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
643 | 670 | | |
644 | 671 | | |
645 | | - | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
646 | 680 | | |
647 | 681 | | |
648 | 682 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
270 | 308 | | |
271 | 309 | | |
272 | 310 | | |
| |||
0 commit comments