libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libmicrohttpd] Improving response header build performance


From: Ariel Cohen
Subject: Re: [libmicrohttpd] Improving response header build performance
Date: Mon, 12 Oct 2020 18:28:55 -0700 (PDT)

Thanks for the response, Christian. I'll try doing some performance studies 
using an HTTP benchmark. So far, I've only looked at instruction counts for 
response processing, and noticed a significant reduction with qrintf. I'll take 
a look at whether there's a meaningful impact on overall performance.

Ariel 

----- Original Message -----
From: grothoff@gnunet.org
To: libmicrohttpd@gnu.org, ariel.x.cohen@oracle.com
Sent: Wednesday, October 7, 2020 2:58:04 AM GMT -08:00 US/Canada Pacific
Subject: Re: [libmicrohttpd] Improving response header build performance

Hi Ariel,

That's an interesting proposal, but I think it goes a bit into the wrong
direction:
- given that applications using MHD are likely to use printf()
elsewhere, it'll almost certainly increase code size. I generally think
for MHD code size is more important than speed.
- given that the main application logic is virtually always going to be
the bottleneck, I doubt this hyper-optimization will matter much in
practice; so unless someone has a real-world application where they can
show this matters, I think this is premature.
- this change would increase code/build-system complexity, and likely
hinder portability -- even if conditionally compiled.

So without strong (performance) data on real (!) applications (not
inet_ntop()) I would not seriously consider this.  As the author of
qrintf writes: this should be done by the compiler --- given the right
compiler flags and iff the optimization is actually worth it.

Happy hacking!

Christian

On 10/6/20 11:56 PM, Ariel Cohen wrote:
> Hi,
> 
> I noticed that adding response headers is expensive. One reason is that many 
> instructions are executed for the snprintf() calls which are invoked when 
> building response headers (build_header_response()).
> 
> There is an sprintf accelerator called qrintf which rewrites invocations of 
> sprinf/snprintf to optimized forms. This is done by preprocessing the source 
> files using a filter program. See:
> 
> https://github.com/h2o/qrintf
> 
> This is provided under the MIT license, and I believe it is used in the H2O 
> HTTP server/library.
> 
> Using this preprocessor on libmicrohttpd results in a significant reduction 
> in the instruction count for adding response headers during runtime.
> 
> My question is whether this is something that could be considered for use by 
> libmicrohttpd in a future release. It would be helpful to improve the 
> performance of adding response headers.
> 
> Thanks,
> 
> Ariel
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]