Commit a83d56a
Avoid initialization of every calloc'd int in fd_map
libkqueue allocates the the number of available file descriptors for the fd_map
array in linux/platform.c to. That limit is vast in Docker, for complicated
reasons:
1073741816
The library allocates arrays of that size in several places, but in only one
does it then also _initialize_ every member of the array (to -1). Since
calloc/mmap are optimized to allocate lazily, this means that only that instance
winds up immediately actually using ~4GB in memory.
The initialization of the int array uses -1 to indicate that a field isn't in
use. The patch changes this to use 0 as unused, simply bumping the stored fds by
one upon insert and decrementing by one on access, via helpers.1 parent fbe0c77 commit a83d56a
1 file changed
Lines changed: 25 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
76 | 98 | | |
77 | 99 | | |
78 | 100 | | |
| |||
178 | 200 | | |
179 | 201 | | |
180 | 202 | | |
181 | | - | |
| 203 | + | |
182 | 204 | | |
183 | 205 | | |
184 | 206 | | |
| |||
235 | 257 | | |
236 | 258 | | |
237 | 259 | | |
238 | | - | |
239 | | - | |
240 | 260 | | |
241 | 261 | | |
242 | 262 | | |
| |||
263 | 283 | | |
264 | 284 | | |
265 | 285 | | |
266 | | - | |
267 | | - | |
268 | 286 | | |
269 | 287 | | |
270 | 288 | | |
| |||
298 | 316 | | |
299 | 317 | | |
300 | 318 | | |
301 | | - | |
| 319 | + | |
302 | 320 | | |
303 | 321 | | |
304 | 322 | | |
| |||
535 | 553 | | |
536 | 554 | | |
537 | 555 | | |
538 | | - | |
| 556 | + | |
539 | 557 | | |
540 | 558 | | |
541 | 559 | | |
| |||
0 commit comments