Welcome! Log In Create A New Profile

Advanced

Re: inlining

Maxim Dounin
February 17, 2014 09:04AM
Hello!

On Fri, Feb 14, 2014 at 04:59:26PM -0500, atarob wrote:

> Looking through the codebase, I see a lot of very short helper like
> functions that are defined in .c files with prototypes in .h files. This
> means that the compiler cannot inline them outside of that .c file. Am I
> wrong? How is that not a performance hit?

In no particular order:

- As already pointed out, smart enough compilers can inline
whatever they want.

- Adding all functions to .h files results in unmanagable code, so
there should be a bar somewhere.

- In many cases inlining may actually be a bad idea even from
performance point of view, see, e.g., [1].

- If inlining is considired to be beneficial, in most
cases nginx uses macros rather than inline functions, see, e.g.,
src/core/ngx_queue.h.

If you think there are functions which needs be be made
inlineable - feel free to suggest.

[1] http://stackoverflow.com/questions/1932311/when-to-use-inline-function-and-when-not-to-use-it

--
Maxim Dounin
http://nginx.org/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

inlining

atarob February 14, 2014 04:59PM

Re: inlining

Styopa Semenukha February 14, 2014 05:52PM

Re: inlining

atarob February 14, 2014 06:24PM

Re: inlining

Pankaj Mehta February 14, 2014 07:02PM

Re: inlining

atarob February 18, 2014 02:51PM

Re: inlining

Jeffrey Walton February 18, 2014 04:36PM

Re: inlining

Maxim Dounin February 17, 2014 09:04AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 302
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready