Categories
Posts

qrintf

I’ve mentioned the h2o web server from Kazuho Oku previously. One of the major goals for h2o is performance. To the point that Kazuho created a sprintf/snprintf pre-processor called qrintf:

sprintf (snprintf) is a great function for converting data to strings. The downside is that it is slow. Recently the functions have been one of the bottlenecks of H2O, which is a high performance HTTP server / library with support for HTTP/1.x and HTTP/2.

H2O uses sprintf in three parts: building the HTTP status line, building ETag, and building the access log.

By using qrintf-gcc in place of gcc, the performance of H2O jumps up by 20% in a benchmark that sends tiny files and with access logging enabled (from 82,900 reqs/sec. to 99,200 reqs/sec.).

A 20% improvement is not something you run into every day.