From owner-freebsd-threads@FreeBSD.ORG Mon Nov 22 08:30:39 2004 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 2164F16A4CE; Mon, 22 Nov 2004 08:30:39 +0000 (GMT) Received: from smtp4.jp.viruscheck.net (smtp4.jp.viruscheck.net [154.33.69.55]) by mx1.FreeBSD.org (Postfix) with ESMTP id B225643D60; Mon, 22 Nov 2004 08:30:38 +0000 (GMT) (envelope-from bland@FreeBSD.org) Received: from scan4.jp.viruscheck.net ([154.33.69.39] helo=mail1.jp.viruscheck.net) by smtp4.jp.viruscheck.net with esmtp (Exim 3.36 #1) id 1CW9am-0001WQ-00; Mon, 22 Nov 2004 17:30:36 +0900 Received: from [220.108.149.115] (helo=noc.orchid) by mail1.jp.viruscheck.net with esmtp (Exim 3.36 #3) id 1CW9am-0002IO-00; Mon, 22 Nov 2004 17:30:36 +0900 Received: from [89.60.10.11] (horse.orchid [89.60.10.11]) by noc.orchid (8.12.11/8.12.11) with ESMTP id iAM8UZS5002335; Mon, 22 Nov 2004 17:30:35 +0900 (JST) (envelope-from bland@FreeBSD.org) Message-ID: <41A1A3A5.20601@FreeBSD.org> Date: Mon, 22 Nov 2004 17:30:29 +0900 From: Alexander Nedotsukov User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8a4) Gecko/20040927 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Daniel Eischen References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit cc: Joe Marcus Clarke cc: Joe Marcus Clarke cc: freebsd-threads@FreeBSD.org Subject: Re: Question about our default pthread stack size 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: Mon, 22 Nov 2004 08:30:39 -0000 Daniel Eischen wrote: >On Mon, 22 Nov 2004, Alexander Nedotsukov wrote: > > > >>Daniel Eischen wrote: >> >> Heavy stack usage is not so evil like it may look like. That "pig" >>will have to allocate big memory chunk anyway and the usual options here >>are to grab phys memory page on the heap through the malloc() or do it >>on the stack. In both of the cases this memory will not be immediately >>allocated. But malloc() way will be slower and this is why multimedia >>processing code may prefer on stack allocation. Another malloc/free() >>disadvantage for C program is potential memory leakage. People may feel >>safer when they don't have to check all return paths but get automatic >>memory disposal. >>One more thing about "Do they know their own stack space requirements". >>No they don't. And the whole idea here I believe was to let them don't >>care at all. I doubt very much if such research for something like >>OpenOffice will worth the efforts. So it is more practical to follow >>Bill's like "no one can beat xxx barrier". Where xxx is 1MB in our 32bit >>case :-) >> >> > >You're missing my point. There is a perfectly good POSIX standard for >setting thread stack size -- you don't even need to allocate it yourself. >Using pthread_attr_setstacksize() is more portable than relying on >the OS to guess at what an application's stack size requirements are. > > Daniel, this is what I said in my very first letter under the topic. I know how portable code must look like. API is good and complete. Let's clear thing up yet more to understand each other completely. My points are: - there is an omision in standard (or better to say something that is hard to standardize) Therefore there is a term like default stack size which can be understood as the amount enough for regular code. Otherwise it will be more logical to make thread stack size argument mandatory for pthread_create(). - main stream follows the stack usage rules I described above and chosen 1MB/2MB for their default stacks size. - we have limit which most likely triggers SIGSEGV. At this point I believe we both agreed that there is a sence to break 64K limit. Right? Than the only open question how much we will grow it up. My point is that if we going to use lower numbers we must give a good reason for that. Some technical issues I guess like performance penalty whatever... My main question I'd like to hear the answer is: If we can not prove being as safe as main stream and do not win anything in technical aspect than why we must do extra work? I can understand if there is some true technical issue which prevents us form be inline with others. But I do not if we just pushing people to use APIs speculating on standard omisions. >We may increase it to 1MB now, but what happens when that is not enough? >And you _know_ one day, perhaps sooner than you realize, that it won't >be enough. > > This will be a problem for everyone not just for FreeBSD users. Perhaps that day will be a good time to prove Solaris/Linux/Windows OS engineers who was right. But now I think we lost the race. All the best, Alexander.