5 ms·
Wait, isn't that trick basically about avoiding optimization (inlining the function to avoid the context switch) to reduce code size? The C compiler would do s
by ascar 6y ago
Wait, isn't that trick basically about avoiding optimization (inlining the function to avoid the context switch) to reduce code size?
The C compiler would do something similar here and also increase code size for performance unless you explicitly use `-Os`
- monocasa 6y agoThe better C compilers use better heuristics in these cases, knowing that binary size can mean I$ pressure and therefore be a detriment to performance.
- a_e_k 6y agoThey also tend to have ways to override those heuristics (e.g., `__attribute__((noinline))` in GCC).
- singron 6y agogo has //go:noinline for the same effect. I don't think you need these weird trampoline calls and they are probably somewhat fragile since a future compiler might figure out how to inline through them.
- jeffbee 6y agoNobody needs to bounce through trampoline calls like this, but for people willing to chase a modest code size decrease like the 6% in the article, it's worth knowing that how your code is arranged may have a larger effect on program size than you're used to from other compiled languages.
- millstone 6y agoCache effects mean this is not a pure tradeoff. Any inlining routine needs a cost model. From the article it seems like Go compiler's cost model is not yet well tuned.