jetty.project icon indicating copy to clipboard operation
jetty.project copied to clipboard

Improve Jetty HTTP client's garbage churn

Open lorban opened this issue 5 years ago • 4 comments

Jetty version 9.4.28

Java version 11.0.7

OS type/version Ubuntu 20.04

Description The Jetty HTTP client generates a relatively large amount of garbage during normal operations, some of which could easily be avoided.

Here are the top offenders I found:

byte[] java.util.Arrays.copyOfRange(byte[], int, int)
   String java.lang.StringLatin1.newString(byte[], int, int)
      String java.lang.String.substring(int, int)
         int java.net.URI$Parser.parseAuthority(int, int)
         int java.net.URI$Parser.parseHostname(int, int)
         void java.net.URI$Parser.parse(boolean)
         int java.net.URI$Parser.parseHierarchical(int, int)
      String java.lang.StringBuilder.toString()
         String org.eclipse.jetty.client.Origin.asString()
         URI org.eclipse.jetty.client.HttpRequest.buildURI(boolean)
         String java.net.URI.toString(String, String, String, String, String, int, String, String, String)
         String org.eclipse.jetty.http.HttpURI.getAuthority()

String java.lang.StringLatin1.newString(byte[], int, int)
   String java.lang.String.substring(int, int)
      void java.net.URI$Parser.parse(boolean)
      int java.net.URI$Parser.parseHostname(int, int)
      int java.net.URI$Parser.parseAuthority(int, int)
      int java.net.URI$Parser.parseHierarchical(int, int)
   String java.lang.StringBuilder.toString()
      URI org.eclipse.jetty.client.HttpRequest.buildURI(boolean)
      String java.net.URI.toString(String, String, String, String, String, int, String, String, String)
      String org.eclipse.jetty.client.Origin.asString()
      String org.eclipse.jetty.http.HttpURI.getAuthority()

URI java.net.URI.create(String)
   ContentResponse org.eclipse.jetty.client.HttpClient.GET(String)
   String org.eclipse.jetty.http2.client.http.HttpSenderOverHTTP2.relativize(String)
   URI org.eclipse.jetty.client.HttpRequest.buildURI(boolean)

Object[] java.util.Arrays.copyOf(Object[], int)
   Object[] java.util.ArrayList.grow(int)
      Object[] java.util.ArrayList.grow()
         void java.util.ArrayList.add(Object, Object[], int)
         boolean java.util.ArrayList.add(Object)
         void java.util.stream.Collectors$$Lambda$77.2073640037.accept(Object, Object)
         void org.eclipse.jetty.client.HttpRequest.send(HttpRequest, Response$CompleteListener)
      boolean java.util.ArrayList.addAll(Collection)
         void org.eclipse.jetty.client.HttpConversation.updateResponseListeners(Response$ResponseListener)
         void org.eclipse.jetty.client.HttpExchange.<init>(HttpDestination, HttpRequest, List)
         boolean org.eclipse.jetty.client.HttpReceiver.responseBegin(HttpExchange)
   Object[] java.util.ArrayList.toArray()
      boolean java.util.ArrayList.addAll(Collection)
      void org.eclipse.jetty.client.HttpConversation.updateResponseListeners(Response$ResponseListener)
      boolean org.eclipse.jetty.client.HttpReceiver.responseBegin(HttpExchange)
      void org.eclipse.jetty.client.HttpExchange.<init>(HttpDestination, HttpRequest, List)

void java.util.regex.Pattern.compile()
   void java.util.regex.Pattern.<init>(String, int)	
   Pattern java.util.regex.Pattern.compile(String)
   boolean java.util.regex.Pattern.matches(String, CharSequence)
   boolean java.lang.String.matches(String)
   String org.eclipse.jetty.client.HttpClient.normalizeHost(String)
   void org.eclipse.jetty.client.HttpRequest.<init>(HttpClient, HttpConversation, URI)

I've used the Flight Recorder to profile heap allocation; and here's the benchmark I wrote for this purpose: https://github.com/lorban/jetty.benchmarks/blob/master/src/test/java/org/eclipse/jetty/benchmark/HttpChannelRecycling.java

lorban avatar Apr 27 '20 15:04 lorban

This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 02 '21 17:06 stale[bot]

This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jun 04 '22 00:06 github-actions[bot]

This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jun 06 '23 00:06 github-actions[bot]

This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jun 06 '24 00:06 github-actions[bot]

This issue has been closed due to it having no activity.

github-actions[bot] avatar Jul 06 '24 00:07 github-actions[bot]