Return-Path: Delivered-To: apmail-commons-dev-archive@www.apache.org Received: (qmail 27458 invoked from network); 9 Jan 2011 15:32:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 9 Jan 2011 15:32:55 -0000 Received: (qmail 55452 invoked by uid 500); 9 Jan 2011 15:32:54 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 55327 invoked by uid 500); 9 Jan 2011 15:32:52 -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 55289 invoked by uid 99); 9 Jan 2011 15:32:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Jan 2011 15:32:51 +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 (athena.apache.org: domain of sebbaz@gmail.com designates 209.85.216.178 as permitted sender) Received: from [209.85.216.178] (HELO mail-qy0-f178.google.com) (209.85.216.178) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Jan 2011 15:32:46 +0000 Received: by qyk33 with SMTP id 33so18704024qyk.9 for ; Sun, 09 Jan 2011 07:32:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=xW/s/GL4Xrtifi1wBASkL7Kms5w9aMCRas1YV8k07ao=; b=mRGmIZUyn8gfIBaLm29nLPOdNuJqQZ00pfNjfggZDZoWQM4GOcGRVqTbme8zqRr8fX YTrsuttcwty8+uLxt/uxFCcYtFaB0f9sTU0O3ec5N7XQ7AB8IgMgNLGnEfta215pQioL w6ZqLOyGoZacpwTLKk8o07dHKljJ+v2IyibDY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=ZYIZT7Gyp9zM3yMDAcnSKfAGgUpIVRLz1+ljhzcbDct2EVpPYwBcESpBGIQ8rP+BLZ q7tMJzlgFIpHHZtmUi10I2xBKads19sp2wivSujIKdEjOiz0i7aB0FqROMkiQ6H0Pxiv 9NCaCIEVZI7tR+r8Bu+QFhC0leDI7iK1Lc9p4= MIME-Version: 1.0 Received: by 10.229.95.11 with SMTP id b11mr1676027qcn.28.1294587145298; Sun, 09 Jan 2011 07:32:25 -0800 (PST) Received: by 10.229.95.208 with HTTP; Sun, 9 Jan 2011 07:32:25 -0800 (PST) Date: Sun, 9 Jan 2011 15:32:25 +0000 Message-ID: Subject: HttpClient - use ConcurrentHashMap instead of HashMap? From: sebb To: Commons Developers List Content-Type: text/plain; charset=ISO-8859-1 AbstractCookieSpec uses an unsynchronised HashMap, so is not thread-safe. 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: HashMap Runtime: 3000 Number of threads: 1 Write probability: 0.6 Remove probability: 0.02 Ops per second: 1260837.0 Map type: ConcurrentHashMap Runtime: 3000 Number of threads: 1 Write probability: 0.6 Remove probability: 0.02 Ops per second: 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-comparision-between.html --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org