From owner-freebsd-threads@FreeBSD.ORG Thu Mar 3 07:30:19 2005 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8073C16A4CE for ; Thu, 3 Mar 2005 07:30:19 +0000 (GMT) Received: from mail.emict.com (brig.emict.com [212.90.172.42]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8194A43D1F for ; Thu, 3 Mar 2005 07:30:18 +0000 (GMT) (envelope-from andrit@ukr.net) Received: from BORJA (unknown [203.199.120.221]) by mail.emict.com (Postfix) with ESMTP id 73D9333649 for ; Thu, 3 Mar 2005 09:30:15 +0200 (EET) Message-ID: <005201c51fc2$d8676b60$090210ac@BORJA> From: "Andriy Tkachuk" To: References: <000b01c51fbb$4189ea30$090210ac@BORJA> Date: Thu, 3 Mar 2005 13:00:12 +0530 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_004F_01C51FF0.EF8D15A0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 x-mimeole: Produced By Microsoft MimeOLE V6.00.2800.1165 Subject: Re: patch for threads/76690 - critical - fork hang in child for-lc_r X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Mar 2005 07:30:19 -0000 This is a multi-part message in MIME format. ------=_NextPart_000_004F_01C51FF0.EF8D15A0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit But if one wants to use pure user threads on his UP system, what he will chose if not libc_r ? And i have some test program with shows the better results for libc_r than for libpthreads. Take a look. The program is the 500 threads, each of them allocate memory in loop and then free it in another loop. Program outputs the time consumed for this two loops. See the results. > ./a.out m 1000 10 # 1000 iterations, malloc by 10 bytes memory chanks thread 0 created thread 1 created thread 2 created thread 3 created ... thread 499 created 0.000870 0.000544 0.000695 0.000594 0.000913 ... (after some time, say 10-20 seconds, there is stable picture: ) 0.001056 0.000756 0.000485 0.000476 0.000528 0.000479 0.000550 0.000481 0.000561 0.000541 0.000483 0.000558 0.000482 0.000561 0.000532 0.000479 0.000551 0.000484 0.000923 0.001180 0.000981 0.000492 0.000996 0.000536 0.000975 0.000534 this is for libc_r. Let's see what about lpthreads. > c++ -lpthread test2.cc > ./a.out m 1000 10 thread 0 created thread 1 created ... thread 498 created thread 499 created 0.001704 0.001707 0.001671 0.001683 0.001691 0.001664 0.001661 0.001683 0.001709 ... 0.001643 0.002018 0.001668 0.001672 0.001744 0.001689 0.001672 0.001682 0.001643 0.001687 0.001670 0.001692 0.001677 0.001732 0.001650 0.001685 0.001678 0.001685 1.303800 5.266314 5.268821 5.268158 5.268539 5.268644 5.268515 5.268963 5.269147 5.268968 5.268928 ... 5.341573 5.341051 5.341417 5.341327 5.341084 5.340510 5.340974 5.340914 5.341118 ... So what? The test2.cc is attached. (of course all was done on current: > uname -a FreeBSD fbsd 6.0-CURRENT FreeBSD 6.0-CURRENT #0: Tue Mar 1 16:03:09 IST 2005 ant@fbsd:/usr/obj/usr/src/sys/FBSD i386 ) > > Is there a reason you are still using libc_r? > > I don't use it at all, but there was critical bug > i threads-pr - so i just decided to fix it since i > have had some time ) > > If this library is needless, why is it still there > and this pr in criticals? ------=_NextPart_000_004F_01C51FF0.EF8D15A0 Content-Type: application/octet-stream; name="test2.cc" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="test2.cc" #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= =0A= using std::string;=0A= =0A= #define COUNT_THREADS 500=0A= =0A= pthread_t thread[COUNT_THREADS];=0A= =0A= char mode;=0A= int iters;=0A= int chanksz;=0A= =0A= void f()=0A= {=0A= struct timeval t1,t2;=0A= void* p[iters];=0A= string s;=0A= =0A= sleep(2);=0A= =0A= while (1)=0A= {=0A= =0A= gettimeofday(&t1, NULL);=0A= =0A= if (mode =3D=3D 's') {=0A= s =3D "";=0A= for (int i=3D0; i