hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Gregory (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HTTPCLIENT-1858) Very high GC pressure due to wire logging
Date Sat, 01 Jul 2017 19:06:01 GMT

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1858?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16071373#comment-16071373
] 

Gary Gregory commented on HTTPCLIENT-1858:
------------------------------------------

Sure. I am getting on the road. I will revisit tonight or tomorrow. 

> Very high GC pressure due to wire logging
> -----------------------------------------
>
>                 Key: HTTPCLIENT-1858
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1858
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient (classic)
>    Affects Versions: 4.5.2
>            Reporter: Arya Ketan
>            Priority: Minor
>              Labels: performance
>         Attachments: Screen Shot 2017-06-21 at 1.11.46 pm.png
>
>
> While running performance tests, I am seeing very high GC pressure due to the following
code
> in Wire.java 
> {code:java}
> private void wire(final String header, final InputStream instream)
>       throws IOException {
>         final StringBuilder buffer = new StringBuilder();
>         int ch;
>         while ((ch = instream.read()) != -1) {
>             if (ch == 13) {
>                 buffer.append("[\\r]");
>             } else if (ch == 10) {
>                     buffer.append("[\\n]\"");
>                     buffer.insert(0, "\"");
>                     buffer.insert(0, header);
>                     log.debug(id + " " + buffer.toString());
>                     buffer.setLength(0);
>             } else if ((ch < 32) || (ch > 127)) {
>                 buffer.append("[0x");
>                 buffer.append(Integer.toHexString(ch));
>                 buffer.append("]");
>             } else {
>                 buffer.append((char) ch);
>             }
>         }
>         if (buffer.length() > 0) {
>             buffer.append('\"');
>             buffer.insert(0, '\"');
>             buffer.insert(0, header);
>             log.debug(id + " " + buffer.toString());
>         }
>     }
> {code}
> This is because, we are trying to expand Stringbuffer continously , thus leading to lot
of char[] garbage. 
> 2 suggestions for improvements
> a) we look into whether logging level is enabled and only then construct the message
> b) efficiently construct log message.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message