Commit 911e8cc
committed
perf(local): eliminate per-entry allocations in stat scheduler worker path
Reduce heap allocation churn in the hot stat-worker path by introducing
per-worker reusable state and removing unnecessary os.File wrappers.
Per-worker scratch buffers:
- Result slice: workers reuse a goroutine-local []statFileInfo scratch
instead of allocating per-microbatch. Publish still copies under mutex
with lease validation, preserving stale-completion safety.
- Name buffer: custom fstatat using unix.Syscall6(SYS_NEWFSTATAT) with a
per-worker [256]byte buffer replaces unix.Fstatat's per-call
ByteSliceFromString allocation. Uses Syscall6 (not RawSyscall6) for
CephFS scheduler awareness.
- ownedEntries: scratch-recycled on listController following the existing
resultsScratch/partsScratch pattern.
Raw fd lifecycle:
- openDirAtReadFD returns raw int fd instead of *os.File, eliminating
per-batch File struct, finalizer registration, and poll init overhead.
- closeStatDirFD uses syscall.Close for cross-platform compatibility.
- All close/drain/error paths updated with idempotent guard.
Scratch capture timing:
- Moved resultsScratch/partsScratch captures to after Wait() returns,
matching ownedEntriesScratch and eliminating a latent aliasing window
during the Schedule-to-Wait period.
Estimated savings: ~500-1000 MB cumulative allocation reduction and
~3-8M fewer heap objects per listing run on CephFS workloads.
Signed-off-by: Anagh Kumar Baranwal <6824881+darthShadow@users.noreply.github.com>1 parent db185b1 commit 911e8cc
File tree
12 files changed
+307
-166
lines changed- backend/local
12 files changed
+307
-166
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| 35 | + | |
| 36 | + | |
34 | 37 | | |
35 | 38 | | |
36 | 39 | | |
37 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
38 | 53 | | |
39 | 54 | | |
40 | 55 | | |
41 | 56 | | |
42 | 57 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
| 58 | + | |
47 | 59 | | |
48 | 60 | | |
49 | 61 | | |
| |||
186 | 198 | | |
187 | 199 | | |
188 | 200 | | |
189 | | - | |
190 | | - | |
| 201 | + | |
| 202 | + | |
191 | 203 | | |
192 | 204 | | |
193 | 205 | | |
| |||
207 | 219 | | |
208 | 220 | | |
209 | 221 | | |
210 | | - | |
| 222 | + | |
211 | 223 | | |
212 | 224 | | |
213 | 225 | | |
| |||
301 | 313 | | |
302 | 314 | | |
303 | 315 | | |
304 | | - | |
| 316 | + | |
305 | 317 | | |
306 | 318 | | |
307 | 319 | | |
| |||
429 | 441 | | |
430 | 442 | | |
431 | 443 | | |
432 | | - | |
| 444 | + | |
433 | 445 | | |
434 | 446 | | |
435 | 447 | | |
436 | 448 | | |
437 | 449 | | |
438 | 450 | | |
439 | 451 | | |
440 | | - | |
| 452 | + | |
441 | 453 | | |
442 | 454 | | |
443 | | - | |
| 455 | + | |
444 | 456 | | |
445 | | - | |
| 457 | + | |
446 | 458 | | |
447 | 459 | | |
448 | 460 | | |
449 | | - | |
| 461 | + | |
450 | 462 | | |
451 | 463 | | |
452 | 464 | | |
453 | 465 | | |
454 | 466 | | |
455 | | - | |
| 467 | + | |
456 | 468 | | |
457 | 469 | | |
458 | 470 | | |
| |||
461 | 473 | | |
462 | 474 | | |
463 | 475 | | |
464 | | - | |
| 476 | + | |
465 | 477 | | |
466 | 478 | | |
467 | 479 | | |
468 | 480 | | |
469 | | - | |
| 481 | + | |
470 | 482 | | |
471 | 483 | | |
472 | 484 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
| 5 | + | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
| 18 | + | |
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
| |||
89 | 92 | | |
90 | 93 | | |
91 | 94 | | |
92 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
93 | 109 | | |
94 | 110 | | |
95 | | - | |
96 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
97 | 123 | | |
98 | 124 | | |
99 | | - | |
100 | | - | |
| 125 | + | |
| 126 | + | |
101 | 127 | | |
102 | 128 | | |
103 | 129 | | |
| |||
110 | 136 | | |
111 | 137 | | |
112 | 138 | | |
113 | | - | |
| 139 | + | |
114 | 140 | | |
115 | 141 | | |
116 | 142 | | |
117 | 143 | | |
118 | | - | |
| 144 | + | |
119 | 145 | | |
120 | | - | |
| 146 | + | |
121 | 147 | | |
122 | 148 | | |
123 | 149 | | |
124 | 150 | | |
125 | | - | |
| 151 | + | |
126 | 152 | | |
127 | 153 | | |
128 | 154 | | |
| |||
131 | 157 | | |
132 | 158 | | |
133 | 159 | | |
134 | | - | |
| 160 | + | |
135 | 161 | | |
136 | | - | |
| 162 | + | |
137 | 163 | | |
138 | 164 | | |
139 | 165 | | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
149 | 171 | | |
150 | | - | |
| 172 | + | |
151 | 173 | | |
152 | 174 | | |
153 | 175 | | |
154 | 176 | | |
155 | | - | |
| 177 | + | |
156 | 178 | | |
157 | | - | |
| 179 | + | |
158 | 180 | | |
159 | | - | |
| 181 | + | |
| 182 | + | |
160 | 183 | | |
0 commit comments