Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 0A4F8200CDF for ; Wed, 26 Jul 2017 00:26:05 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 0892C167A46; Tue, 25 Jul 2017 22:26:05 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4DA11167A45 for ; Wed, 26 Jul 2017 00:26:04 +0200 (CEST) Received: (qmail 61216 invoked by uid 500); 25 Jul 2017 22:26:03 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 61205 invoked by uid 99); 25 Jul 2017 22:26:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Jul 2017 22:26:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id D485A1A08BE for ; Tue, 25 Jul 2017 22:26:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id rAAoMvZuOimY for ; Tue, 25 Jul 2017 22:26:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 615185FE43 for ; Tue, 25 Jul 2017 22:26:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 90660E0D67 for ; Tue, 25 Jul 2017 22:26:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 36C9123F15 for ; Tue, 25 Jul 2017 22:26:00 +0000 (UTC) Date: Tue, 25 Jul 2017 22:26:00 +0000 (UTC) From: "ASF subversion and git services (JIRA)" To: dev@hc.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HTTPCLIENT-1858) Alleviate GC pressure due to wire logging MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 25 Jul 2017 22:26:05 -0000 [ https://issues.apache.org/jira/browse/HTTPCLIENT-1858?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16100874#comment-16100874 ] ASF subversion and git services commented on HTTPCLIENT-1858: ------------------------------------------------------------- Commit 888cefb7cd39cff379321096e1c2519d6adbe93c in httpcomponents-client's branch refs/heads/master from [~garydgregory] [ https://git-wip-us.apache.org/repos/asf?p=httpcomponents-client.git;h=888cefb ] [HTTPCLIENT-1858] Clone some code from Log4j 2 to cache a StringBuilder in a ThreadLocal. Update to use the StringBuilder's capacity instead of its length to measure upper bound. > 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-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org