Return-Path: Delivered-To: apmail-db-ojb-dev-archive@www.apache.org Received: (qmail 35234 invoked from network); 15 Jun 2004 10:31:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 15 Jun 2004 10:31:46 -0000 Received: (qmail 28551 invoked by uid 500); 15 Jun 2004 10:31:37 -0000 Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 28466 invoked by uid 500); 15 Jun 2004 10:31:34 -0000 Mailing-List: contact ojb-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "OJB Developers List" Reply-To: "OJB Developers List" Delivered-To: mailing list ojb-dev@db.apache.org Received: (qmail 28440 invoked by uid 99); 15 Jun 2004 10:31:33 -0000 Received: from [194.95.168.2] (HELO prosun.first.fraunhofer.de) (194.95.168.2) by apache.org (qpsmtpd/0.27.1) with ESMTP; Tue, 15 Jun 2004 03:31:33 -0700 Received: from [194.95.170.251] (barney [194.95.170.251]) by prosun.first.fraunhofer.de (8.12.10/8.12.10) with ESMTP id i5FAVUw9010340 for ; Tue, 15 Jun 2004 12:31:31 +0200 (MEST) Message-ID: <40CECFDC.3080408@first.fhg.de> Date: Tue, 15 Jun 2004 12:30:52 +0200 From: Thomas Dudziak User-Agent: Mozilla Thunderbird 0.6 (Windows/20040502) X-Accept-Language: en-us, en MIME-Version: 1.0 To: OJB Developers List Subject: Re: Vector use References: <9218F1F6-BE2E-11D8-86DC-000D93ADF212@codepuccino.com> <40CDF1AF.604@first.fhg.de> <40CEB9A9.10307@surfeu.fi> In-Reply-To: <40CEB9A9.10307@surfeu.fi> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Ilkka Priha wrote: > Synchronization overhead is surprisingly low, at least with the newest > Java VMs, in non-concurrent situations, but can cause bottlenecks in > concurrent ones, which really slows down performance. On the other > hand, if concurrency is expected, collections can't be substituted > with non-synchronized classes without resolving the normal issues of > thread-safety. > > As this topic has come up in almost all of our Java projects, we've > made some simple benchmarks with ordered Integer objects to test > (only) synchronization of collections. All collections have been > constructed with enough space to hold the test objects (150% with > maps) to avoid reallocation and rehashing. GC is called just before > each test case. > > With integer based over-simplified hashcodes Hashtable and Vector > perform actually better than the corresponding HashMap and ArrayList > because their put, get and remove methods are somewhat simpler and > call less internal methods. Synchronization of HashMap with > Collections.syncronizedMap cause an overhead between 2-7 % depending > on the operation. Synchronization of ArrayList with > Collections.syncronizedList cause quite high relative overhead but > it's only about 10 ns per call. Other benchmarks have shown that in > more realistic hashing situations HashMap should perform better then > Hashtable but probably because of better rehashing than missing > synchronization. > > Sun JRE 1.4.2_004, Windows XP Pro, AMD Athlon XP 2400+, 1024 MB > --------------------------------------------------------------- > INFO [15/Jun/2004:08:03:20 +0000] Hashtable put 5000000 times: > 1324 > INFO [15/Jun/2004:08:03:20 +0000] Hashtable get 5000000 times: > 468 > INFO [15/Jun/2004:08:03:21 +0000] Hashtable remove 5000000 times: 452 > INFO [15/Jun/2004:08:03:27 +0000] HashMap put 5000000 times: 3849 > INFO [15/Jun/2004:08:03:29 +0000] HashMap get 5000000 times: 2508 > INFO [15/Jun/2004:08:03:33 +0000] HashMap remove 5000000 times: 3397 > INFO [15/Jun/2004:08:03:39 +0000] Synced HashMap put 5000000 > times: 3942 > INFO [15/Jun/2004:08:03:42 +0000] Synced HashMap get 5000000 > times: 2680 > INFO [15/Jun/2004:08:03:45 +0000] Synced HashMap remove 5000000 > times: 3459 > INFO [15/Jun/2004:08:03:47 +0000] Vector add 5000000 times: 203 > INFO [15/Jun/2004:08:03:47 +0000] Vector get 5000000 times: 171 > INFO [15/Jun/2004:08:03:47 +0000] Vector remove 5000000 times: > 156 > INFO [15/Jun/2004:08:03:49 +0000] ArrayList add 5000000 times: > 172 > INFO [15/Jun/2004:08:03:49 +0000] ArrayList get 5000000 times: > 187 > INFO [15/Jun/2004:08:03:49 +0000] ArrayList remove 5000000 times: 171 > INFO [15/Jun/2004:08:03:50 +0000] Synced ArrayList add 5000000 > times: 218 > INFO [15/Jun/2004:08:03:51 +0000] Synced ArrayList get 5000000 > times: 234 > INFO [15/Jun/2004:08:03:51 +0000] Synced ArrayList remove 5000000 > times: 530 > > With multi-processor hardware the synchronization takes more time > because the underlying mechanism is much more complicated. We've run > benchmarks only in a two processor machine. Even there Hashtable > performs better than HashMap, but Vector is now clearly slower than > ArrayList (but still faster than synchronized ArrayList). > > Windows 2000 Server, 2 x Intel PIII 1266 MHz, 512 MB > --------------------------------------------------------------------- > INFO [15/Jun/2004:08:15:12 +0000] Hashtable put 5000000 times: 3172 > INFO [15/Jun/2004:08:15:13 +0000] Hashtable get 5000000 times: 953 > INFO [15/Jun/2004:08:15:14 +0000] Hashtable remove 5000000 times: 969 > INFO [15/Jun/2004:08:15:22 +0000] HashMap put 5000000 times: 5813 > INFO [15/Jun/2004:08:15:25 +0000] HashMap get 5000000 times: 2437 > INFO [15/Jun/2004:08:15:28 +0000] HashMap remove 5000000 times: 3594 > INFO [15/Jun/2004:08:15:37 +0000] Synced HashMap put 5000000 times: 6485 > INFO [15/Jun/2004:08:15:40 +0000] Synced HashMap get 5000000 times: 2922 > INFO [15/Jun/2004:08:15:44 +0000] Synced HashMap remove 5000000 times: > 4234 > INFO [15/Jun/2004:08:15:47 +0000] Vector add 5000000 times: 688 > INFO [15/Jun/2004:08:15:47 +0000] Vector get 5000000 times: 593 > INFO [15/Jun/2004:08:15:48 +0000] Vector remove 5000000 times: 579 > INFO [15/Jun/2004:08:15:51 +0000] ArrayList add 5000000 times: 313 > INFO [15/Jun/2004:08:15:51 +0000] ArrayList get 5000000 times: 296 > INFO [15/Jun/2004:08:15:51 +0000] ArrayList remove 5000000 times: 344 > INFO [15/Jun/2004:08:15:54 +0000] Synced ArrayList add 5000000 times: 735 > INFO [15/Jun/2004:08:15:54 +0000] Synced ArrayList get 5000000 times: 703 > INFO [15/Jun/2004:08:15:55 +0000] Synced ArrayList remove 5000000 > times: 719 > > -- Ilkka Pretty interesting stuff. I guess, some profiling is in order after the 1.0 ;-) Tom --------------------------------------------------------------------- To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org For additional commands, e-mail: ojb-dev-help@db.apache.org