3 ms·
The cost in applications really does add up. "Profiling a warehouse-scale computer" (by S. Kanev, et. al.) showed several % of CPU usage allocating and dealloc
by ckennelly 6y ago
The cost in applications really does add up.
"Profiling a warehouse-scale computer" (by S. Kanev, et. al.) showed several % of CPU usage allocating and deallocating memory. While a malloc and free does have some data dependencies, the indirect jump (by dynamically linking) is an avoidable cost on the critical path by statically linking.
- wahern 6y agoSince Haswell indirect jumps have negligible additional cost. See, e.g., "Branch Prediction and the Performance of Interpreters - Don't Trust Folklore", https://hal.inria.fr/hal-01100647 https://hal.inria.fr/hal-01100647 Perhaps Spectre mitigations have changed things, but we're still talking about a fraction of a fraction. As others have said, the best way to improve malloc performance is to not use malloc. Second best would be avoid allocations in critical sections so the allocator doesn't trash your CPU's prediction buffers.