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 2453F200CAE for ; Wed, 21 Jun 2017 09:49:44 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 2318E160BF3; Wed, 21 Jun 2017 07:49:44 +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 69DA3160BE2 for ; Wed, 21 Jun 2017 09:49:43 +0200 (CEST) Received: (qmail 86654 invoked by uid 500); 21 Jun 2017 07:49:42 -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 86641 invoked by uid 99); 21 Jun 2017 07:49:42 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Jun 2017 07:49:42 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 6BFDA1925A5 for ; Wed, 21 Jun 2017 07:49:41 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.002 X-Spam-Level: X-Spam-Status: No, score=-100.002 tagged_above=-999 required=6.31 tests=[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 (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id SqtjSKq8uX4g for ; Wed, 21 Jun 2017 07:49:40 +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 28FEA6245C for ; Wed, 21 Jun 2017 07:45: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 71C30E0BCB for ; Wed, 21 Jun 2017 07:45: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 291B921943 for ; Wed, 21 Jun 2017 07:45:00 +0000 (UTC) Date: Wed, 21 Jun 2017 07:45:00 +0000 (UTC) From: "Arya Ketan (JIRA)" To: dev@hc.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (HTTPCLIENT-1858) Very high 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: Wed, 21 Jun 2017 07:49:44 -0000 [ https://issues.apache.org/jira/browse/HTTPCLIENT-1858?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Arya Ketan updated HTTPCLIENT-1858: ----------------------------------- Attachment: Screen Shot 2017-06-21 at 1.11.46 pm.png > 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