From dev-return-123249-apmail-commons-dev-archive=commons.apache.org@commons.apache.org Sun Jan 09 19:06:49 2011 Return-Path: Delivered-To: apmail-commons-dev-archive@www.apache.org Received: (qmail 6700 invoked from network); 9 Jan 2011 19:06:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 9 Jan 2011 19:06:49 -0000 Received: (qmail 86598 invoked by uid 500); 9 Jan 2011 19:06:48 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 86499 invoked by uid 500); 9 Jan 2011 19:06:48 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 86490 invoked by uid 99); 9 Jan 2011 19:06:48 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Jan 2011 19:06:48 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of sebbaz@gmail.com designates 209.85.216.43 as permitted sender) Received: from [209.85.216.43] (HELO mail-qw0-f43.google.com) (209.85.216.43) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Jan 2011 19:06:41 +0000 Received: by qwk3 with SMTP id 3so18585498qwk.30 for ; Sun, 09 Jan 2011 11:06:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=8Kf1Xs2NoXq1iTvP8lrq4W5AO4knsHhv/gje4QzjhEE=; b=fTtfkYzirFP7o9ri+ivDL34y7TUX6AjBVulnaSo0mF6vspf39AZGj0faC6mO4VXMyX Q1AKdcDfnR2vhCjUFrC1GuV0d5q6LX0t/ZWZO3DOGIZtA8LIkbIl+lCpkE3g6sCMq+fN HWy/0ggGnEEkBClnV4dh2EUuMXPVTHMjjloMY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=QH4LSQKj8AUJabnR2hN6r8x7CCnx3iXJ9nT0X2ZYZOUkeU60OCycPk+0+UtxeokfaO Sdm3nHHA62nbnUduI4FCfjUHyPVvN7/Lz767YWlb2fk7+eV6bYQcjOhqOjLbqLwD0oeY G5LXQpjFJB9G5EBCNAjFw5s2EZyt3r1tHvm8M= MIME-Version: 1.0 Received: by 10.229.215.135 with SMTP id he7mr5938521qcb.104.1294599980713; Sun, 09 Jan 2011 11:06:20 -0800 (PST) Received: by 10.229.95.208 with HTTP; Sun, 9 Jan 2011 11:06:20 -0800 (PST) In-Reply-To: <69263CAD-62D1-4279-AF87-E59BD02C14BF@dslextreme.com> References: <69263CAD-62D1-4279-AF87-E59BD02C14BF@dslextreme.com> Date: Sun, 9 Jan 2011 19:06:20 +0000 Message-ID: Subject: Re: HttpClient - use ConcurrentHashMap instead of HashMap? From: sebb To: Commons Developers List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org On 9 January 2011 16:20, Ralph Goers wrote: > Why did you post this to the commons dev list instead of http-components = dev? Oops, sorry! However, the timings might still be interesting for Commons components... > Ralph > > On Jan 9, 2011, at 7:32 AM, sebb wrote: > >> AbstractCookieSpec uses an unsynchronised =A0HashMap, so is not thread-s= afe. >> >> AIUI, ConcurrentHashMap has much better performance than a >> synchronised HashMap - but of course we are not using synch here. >> >> A quick test using the code at [1] (1 thread, 1 VM) appears to show >> that the performance of CHM and HM is fairly similar: >> >> Map type: =A0 =A0 =A0 =A0 =A0 HashMap >> Runtime: =A0 =A0 =A0 =A0 =A0 =A03000 >> Number of threads: =A01 >> Write probability: =A00.6 >> Remove probability: 0.02 >> Ops per second: =A0 =A0 1260837.0 >> >> Map type: =A0 =A0 =A0 =A0 =A0 ConcurrentHashMap >> Runtime: =A0 =A0 =A0 =A0 =A0 =A03000 >> Number of threads: =A01 >> Write probability: =A00.6 >> Remove probability: 0.02 >> Ops per second: =A0 =A0 1313171.0 >> >> So I wonder if we should consider replacing HashMap with >> ConcurrentHashMap in Cookies and elsewhere in HttpClient? >> >> [1] http://unserializableone.blogspot.com/2007/04/performance-comparisio= n-between.html >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org >> For additional commands, e-mail: dev-help@commons.apache.org >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org > For additional commands, e-mail: dev-help@commons.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org