News for hackers. Stuff that matters.
Re:Four lines of code it was four lines of code by spc476 on Monday July 01, 2024 @03:24PM (#40849550)
Turns out that mmap() is the memory allocator, nothing to do with files.
Re:Four lines of code it was four lines of code by o11c on Monday July 01, 2024 @04:05PM (#40850040)
I did suspect that, but now the implication is that the memory allocator is not reusing memory even though it easily could.

GLIBC used to have a fixed 128 KiB threshold, but since 2.25 (2017) it defaults to dynamically adjusting the threshold to prevent exactly this pattern of excess syscalls. A manual threshold disables this though!

(This may be a microoptimization depending on how much real work you're doing between the syscalls, but there's also a good chance that it's easy to fix.)

Re:Four lines of code it was four lines of code by throwway120385 on Monday July 01, 2024 @03:40PM (#40849750)
I was going to point out that you can mmap() anonymous pages and use them directly as heap so this tracks.