com.sun.net.httpserver.Headers issues & optimizations

Jaikiran Pai jai.forums2013 at gmail.com
Wed Jan 8 06:30:15 UTC 2025


Hello Robert,

On 07/01/25 12:05 am, robert engels wrote:
> ...
> With a high performance http server, often the most expensive element 
> is the encoding/decoding/processing of the “headers” when accessing 
> cached resources, etc. Garbage generation can be a real problem for 
> low-latency high volume servers. Since the headers survive for the 
> duration of the request, the are subject to not being quickly cleaned 
> in the new generation.
>
> A couple of proposals:
>
> 1. The first is to change the implementation of ’normalize’ in 
> Headers. Currently, the cost is paid on every put and every get - even 
> if the developer is aware of the ’normalized’ format and uses that, 
> e.g. getFirst(“Content-length”)
> ...

The normalize() is an internal implementation detail of the Header class 
and I think the proposal to improve the performance of that method seems 
reasonable. I haven't looked closely at your proposed implementation 
change, but looking at the current implementation in mainline, I think 
there's scope for improvement. I've created 
https://bugs.openjdk.org/browse/JDK-8347167 to track this. If you have 
already spent time improving this method and would like to propose that 
change to the JDK, then after signing the OCA, you can open a PR linking 
against this JDK issue 
(https://openjdk.org/guide/#working-with-pull-requests).

-Jaikiran



More information about the net-dev mailing list