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

ASF subversion and git services commented on HTTPCLIENT-1858:
-------------------------------------------------------------

Commit 9da9f2c273248036088b8cfca3d0bc01ae6a8505 in httpcomponents-client's 
branch refs/heads/master from [~garydgregory]
[ https://git-wip-us.apache.org/repos/asf?p=httpcomponents-client.git;h=9da9f2c 
]

Squashed commit of the following:

commit 71271233909bac9ff9aaa677fc15fb0160462647
Author: Gary Gregory <ggreg...@apache.org>
Date:   Wed Jul 12 18:21:11 2017 -0700

        [HTTPCLIENT-1858] Simplify and no longer use a system property to 
override default max size.

commit 375808a3ab125c02dbfcc94add3a9bc1fb126b4a
Author: Gary Gregory <ggreg...@apache.org>
Date:   Fri Jun 30 16:42:50 2017 -0700

        [HTTPCLIENT-1858] Clone some code from Log4j 2 to cache a StringBuilder 
in a ThreadLocal. Some TODO comments to address configuration of the upper 
bound of the StringBuilder which is current done with a System property.


> Alleviate 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
>             Fix For: 5.0 Alpha3
>
>         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-unsubscr...@hc.apache.org
For additional commands, e-mail: dev-h...@hc.apache.org

Reply via email to