Hi all,
Whenever I see build instructions for nginx, including those for ngx_pagespeed, a vanilla make command is used and compiler optimization flags are not discussed. Has anyone tested different compiler optimizations to see if, and to what extent, it impacts runtime performance of the server and pagespeed's performance?
I'm thinking of things like -march='westmere' to set the assumed instruction set to the Westmere generation of CPUs and above. I think this is necessary to use Cloudflare's optimized gzip fork, for example (because of the carry-less multiplication instruction set, which can also be directly specified with -mpclmul) See the GCC doc
here.
Then there are the platform-agnostic optimizations
here, like -fpeephole2, -fprefetch-loop-arrays and many more. Since an HTTP server has some simple and extremely repetitive workloads, I'm guessing peephole optimizations would help. Same drill for pagespeed in particular. I don't know what's in the default make.config on common platforms, but it's probably what the vanilla nginx makes are using.
The h2o web server is making profitable use of the SSE 4.2 string instructions (well, it's the
picohttpparser specifically). I don't think nginx or pagespeed can benefit from those instructions automatically – compilers aren't that good yet. But there are other potential SIMD wins to be had from compiler flags.
Finally, anyone try the Intel Compiler on nginx + pagespeed? It generally beats other compilers for various applications, but I haven't found much on the web re: nginx builds, or pagespeed. Microsoft just rolled out a way to compile C++ (and presumably C?) apps on or for Linux using Visual Studio but I haven't dug into it yet.
My hunch is that if we're not using compiler optimizations or telling the compiler that the target is post-2009 silicon, we're leaving some nginx and pagespeed performance on the table. Pagespeed is a very active module, so there might be some headroom here for optimization (or, Google engineers already wrung out a lot of optimization).
If you've tried different compiler settings, I'd love to hear about the results. (I also read somewhere that default nginx builds we're using all the security / hardening options that they should, but I can't find it. Every post or gist on hardening nginx I've ever seen skips the compiler entirely, and goes straight to config options...)
Cheers,
Joe