Inlining – The Ultimate Optimisation

xania.org

24 points by PaulHoule 4 days ago


jayd16 - 2 hours ago

Is there a name for duplicating function calls such that different optimizations for the same function can be compiled, but they are not fully duplicated at every call site?

hinkley - an hour ago

There was a weird period in JavaScript’s history where the threshold for inlining was rather fixed and counted comments as part of the function weight. So there was code that would go faster if you deleted the comments.

I believe it was counting AST nodes rather than bytes, otherwise that would have also created problems for descriptive function names as well and that would have been what we heard about instead of comments.

mgaunard - 22 minutes ago

force inline and related attributes are critical to get the right decision made consistently.

There's also flatten; unfortunately no equivalent with MSVC.

on_the_train - an hour ago

That's the reason why polymorphism is sometimes described as slow. It's not really slow... But it prevents inlining and therefore always is a function call as opposed to sometimes no function call. It's not the polymorphism is slow. It's that alternatives can sometimes compile to zero