-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Forceinline improves performance significantly with MSVC #168
Comments
Can you list those 6 Boost-internal functions you inlined? |
Sure, here's what I had to change to get it fully inlined, I changed it one by one until none of the functions individually showed up in the VS profiler any more and the disassembly of my hot path no longer contained any FORCEINLINE is a globally defined macro I have that's just doing |
Force-inlining the destructor and the copy assignment is a bit odd. The rest seem sensible. |
While testing
boost::unordered_flat_set
, I noticed my code is reliably running over 10% faster if I__forceinline
all the function calls that theboost::unordered_flat_set
makes in my hot path. My hot path is only doing.contains()
, so anything called by.contains()
, including the.contains
itself, is where I added__forceinline
. So that in my own code where I call.contains()
, looking at the disassembly there is nocall
anywhere any more, it's fully inlined. I think I had to add__forceinline
to 6 functions inside boost code.It is a bit inconvenient to manually add
__forceinline
to all those functions though - it's definitely worth the 10% performance gain, but I am quite sure that the next time I update boost in a few years, I'll forget to apply these changes again, and then my performance will be worse.Assuming you don't want to add
__forceinline
to those functions by default, could there maybe some define likeBOOST_FORCEINLINE_UNORDERED_SET
that automatically enables forceinlining all the important functions?I am already compiling with maximum optimization level of MSVC, so by default it doesn't want to inline it, MSVC often needs to be forced to inline stuff.
The text was updated successfully, but these errors were encountered: