5 ms·
If you need to optimize the allocator you are doing it wrong.
by carlos256 6mo ago
If you need to optimize the allocator you are doing it wrong.
- saagarjha 6mo agoGlad we have super slow allocators then
- cbarrick 6mo agoExactly. No need to engineer an allocator. You only live once! void* malloc(size_t size) { void *ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); return (ptr == MAP_FAILED) ? NULL : ptr; } void free(void *ptr) { /* YOLO */ } /s
- ot 6mo agoThat's a false dichotomy: you optimize both the application and the allocator. A 0.5% improvement may not be a lot to you, but at hyperscaler scale it's well worth staffing a team to work on it, with the added benefit of having people on hand that can investigate subtle bugs and pathological perf behaviors.
- sumtechguy 6mo agoexactly. I can think of at least 5 different projects I have been on where a better allocator would made a world of difference. I can also think of another 5 where it probably would have been a waste of time to even fiddle with. but as usual there is an xkcd for that. https://xkcd.com/1205/ https://xkcd.com/1205/ One project I spent a bunch of time optimizing the write path of I/O. It was just using standard fwrite. But by staging items correctly it was an easy 10x speed win. Those optimizations sometimes stack up and count big. But it also had a few edges on it, so use with care.