kprotty / zap

An asynchronous runtime with a focus on performance and resource efficiency.
https://github.com/kprotty/zap
MIT License
429 stars 16 forks source link

What's the point of using noinline? #11

Closed Subuday closed 3 months ago

Subuday commented 4 months ago

Hey, I wonder, what's the reason of using noinline? What goal do you want to achive? Just prevent compiler optimisation of inlining function? If yes, why do we prevent?

kprotty commented 4 months ago

Yes, avoids inlining a function. Outlining the slow path keeps code for the hot path close together in memory (or more easily inline-able). This improves perf by not thrashing the instruction cache (I-cache). Similar techniques are used by mutexes (tryLock then block in slow func).