java-web-servlet-filter icon indicating copy to clipboard operation
java-web-servlet-filter copied to clipboard

Performance issue with Tomcat

Open lujiajing1126 opened this issue 5 years ago • 2 comments

As is documented in the comments of MimeHeaders, each call of nextElement() has a complexity of O(n) with a comparison done with all previous elements to ensure the uniqueness.

Jetty has better performance since it uses HashSet to get a set of header keys.

I wonder if we could treat org.apache.catalina.connector.Request as a special case. A simple index-based iteration does improve the performance.

lujiajing1126 avatar Oct 23 '20 12:10 lujiajing1126

Could you please point us to the code in this repo that uses this API? Is it in the extractor?

pavolloffay avatar Oct 23 '20 12:10 pavolloffay

Could you please point us to the code in this repo that uses this API? Is it in the extractor?

In the TextMap implementation,

https://github.com/opentracing-contrib/java-web-servlet-filter/blob/558145f517b37f2d066c7679a02324679d049e1b/opentracing-web-servlet-filter/src/main/java/io/opentracing/contrib/web/servlet/filter/HttpServletRequestExtractAdapter.java#L55-L57

lujiajing1126 avatar Oct 23 '20 13:10 lujiajing1126