From owner-freebsd-hackers@FreeBSD.ORG Thu Feb 10 13:46:19 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B7D6A16A4CE for ; Thu, 10 Feb 2005 13:46:19 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.192]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2201C43D48 for ; Thu, 10 Feb 2005 13:46:19 +0000 (GMT) (envelope-from zombyfork@gmail.com) Received: by rproxy.gmail.com with SMTP id a41so119518rng for ; Thu, 10 Feb 2005 05:46:18 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=qagjtgPNjyWQjHtN/whnCi/HYVZIkNSRo8OlWGgs1YRyXBqMrNVkB1Qz7oyz+vmu6RuzciK2vatmhsciyeqKrHfqgLGhg8wcK9+AMCGJcjl7WxvV/IItz8vB0va6KQw5Vx3EWSOoV4eiTl3kxAauxP5+FAJJTwZBkk6wOze3JyU= Received: by 10.38.98.2 with SMTP id v2mr424553rnb; Thu, 10 Feb 2005 05:46:18 -0800 (PST) Received: by 10.38.22.22 with HTTP; Thu, 10 Feb 2005 05:46:17 -0800 (PST) Message-ID: <346a8022050210054670390298@mail.gmail.com> Date: Thu, 10 Feb 2005 08:46:17 -0500 From: Coleman Kane To: Andriy Tkachuk In-Reply-To: <200502101055.04949.ant@emict.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <200502101055.04949.ant@emict.com> cc: freebsd-hackers@freebsd.org Subject: Re: pthreads & dynamic memory in fbsd vs. the same in linux X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: cokane@cokane.org List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Feb 2005 13:46:19 -0000 Could you post the code too, perchance? On Thu, 10 Feb 2005 10:55:04 +0200, Andriy Tkachuk wrote: > Hi folks. > > I noticed the strange stick of pthreads (amount ~ 500) > when allocating dynamic memory by malloc or new > in my system: > > > uname -a > FreeBSD ant.emict.com 5.3-STABLE FreeBSD 5.3-STABLE #0: Wed Feb 9 17:30:11 EET 2005 ant@ant:/lin/fbsd_obj/usr/src/sys/ANT i386 > > It's interesting that the same program behaves differently > when it is compiled in linux and run on my fbsd machine in > linux_base-7.1_7 . > > > ldd test2-linux > test2-linux: > libpthread.so.0 => /lib/libpthread.so.0 (0x28065000) > libstdc++-libc6.2-2.so.3 => /usr/lib/libstdc++-libc6.2-2.so.3 (0x2807c000) > libm.so.6 => /lib/libm.so.6 (0x280bf000) > libc.so.6 => /lib/libc.so.6 (0x280e1000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x2804c000) > > ldd a.out > a.out: > libpthread.so.1 => /usr/lib/libpthread.so.1 (0x28075000) > libstdc++.so.4 => /usr/lib/libstdc++.so.4 (0x28099000) > libm.so.3 => /lib/libm.so.3 (0x2816b000) > libc.so.5 => /lib/libc.so.5 (0x28184000) > > Each thread allocates the amount of memory by 10 bytes in loop. > The number of iterations is specified in cmdline arg. The program > prints the time each thread is spent allocating memory in loop. > Let's look on results. > > > ./a.out n 1000 # 1000 iterations of new operator. Every new allocates 10bytes. > thread 0 created > thread 1 created > thread 2 created > thread 3 created > thread 4 created > ... > thread 497 created > thread 498 created > thread 499 created > 0.001114 > 0.001022 > 0.001021 > 0.001011 > 0.001014 > 0.001010 > 0.001013 > 0.001050 > 0.001035 > 0.001011 > 0.001013 > 0.001010 > 0.001013 > 0.001010 > 0.001029 > 0.001075 > 0.001053 > 0.001011 > 0.001014 > 0.001011 > 0.001030 > 0.001010 > 0.001015 > 0.001042 > 0.001019 > 0.001011 > 0.001014 > 0.001012 > 0.001013 > 0.001010 > 0.001014 > 0.361604 > 3.225090 > 3.225458 > 3.225696 > 3.225925 > 3.226152 > 3.226380 > 3.226608 > 3.226833 > 3.227062 > 3.227290 > 3.227517 > 3.227744 > 3.227972 > 3.228202 > 3.228451 > 3.228681 > 3.228912 > 3.229140 > 3.229367 > > The same, but in linux_base-7.1_7 : > > > ./test2-linux n 1000 > thread 0 created > thread 1 created > ... > thread 498 created > thread 499 created > 0.000467 > 0.000403 > 0.000402 > ... > 0.000391 > 0.000391 > 0.000395 > ... > 0.000395 > 0.010564 > 0.000398 > 0.000394 > > The program source is attached. > > In linux program is compiled by > $ gcc -v > Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs > gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98) > > in fbsd: > > gcc -v > Using built-in specs. > Configured with: FreeBSD/i386 system compiler > Thread model: posix > gcc version 3.4.2 [FreeBSD] 20040728 > > > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" > > >