3 ms·
The original statement isn't a non-sequitur. If the compiler is spending a lot of time in malloc, it makes sense to replace those heap allocations with stack a
by elihu 10y ago
The original statement isn't a non-sequitur. If the compiler is spending a lot of time in malloc, it makes sense to replace those heap allocations with stack allocations where possible.
You are also correct that removing mallocs might not be much of a low-hanging fruit, since it might entail changing a lot of malloc calls rather than just a few, but that doesn't mean the original statement was wrong.
- eridius 10y agoFair enough, but it's a good bet that most of those mallocs cannot be replaced with stack allocations.
- MaulingMonkey 10y agoSo grab an fixed-size pool allocator. Malloc is very generic, and faster alternatives aren't limited to stack allocators. EDIT: Or do what the article does, eliminate allocations that were straight up unnecessary (because they were unused, or over-eager deep copies)
- nnethercote 10y agoMy post indicates that I've already removed a large chunk of the existing mallocs. The remaining ones are harder, but I expect I'll be able to still remove a decent fraction.