opentracing-contrib / java-web-servlet-filter

OpenTracing Java Web Servlet Filter Instrumentation
Apache License 2.0
24 stars 31 forks source link

Performance issue with Tomcat #66

Open lujiajing1126 opened 4 years ago

lujiajing1126 commented 4 years ago

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.

pavolloffay commented 4 years ago

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

lujiajing1126 commented 4 years ago

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