From owner-freebsd-hackers@FreeBSD.ORG Thu Aug 18 18:52:49 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org 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 0EDEE16A41F for ; Thu, 18 Aug 2005 18:52:49 +0000 (GMT) (envelope-from gpt@tirloni.org) Received: from srv-03.bs2.com.br (srv-03.bs2.com.br [200.203.183.32]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9B95C43D48 for ; Thu, 18 Aug 2005 18:52:48 +0000 (GMT) (envelope-from gpt@tirloni.org) Received: from localhost (localhost.bs2.com.br [127.0.0.1]) by srv-03.bs2.com.br (Postfix) with ESMTP id 7C97C4AE85 for ; Thu, 18 Aug 2005 15:53:31 -0300 (BRT) Received: from [172.16.12.102] (unknown [201.14.55.139]) by srv-03.bs2.com.br (Postfix) with ESMTP id 22C604AE83 for ; Thu, 18 Aug 2005 15:53:31 -0300 (BRT) Message-ID: <4304D8F9.5060608@tirloni.org> Date: Thu, 18 Aug 2005 15:52:41 -0300 From: "Giovanni P. Tirloni" User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050808) X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Fwd: pthread_create: cannot allocate memory] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Aug 2005 18:52:49 -0000 Perhaps this is more apropriate here.. To clarify it a bit, both server and client are being run from the same machine connecting to localhost. If the source code is needed I can send it here but it's a simple "while(1) { accept() pthread_create() }" on the server side and "for() connect()" on the client. What I'm trying to simulate is the behavior of a IRC server that has thousands of persistent connections, but with threads. -------- Original Message -------- Subject: pthread_create: cannot allocate memory Date: Thu, 18 Aug 2005 13:29:33 -0300 From: Giovanni P. Tirloni To: freebsd-threads@freebsd.org Hi, I coded a small echo server that creates a thread for every connection it accepts. It works fine and then I decided to test how many threads it could handle so I coded a stress.c client program that'd just create as many connections as I asked without exchanging any data. First I discovered the kern.threads.max_thread_per_proc limit that was limiting it to 1500 threads. So I raised it and the max_group_per_proc to 10k. I also increased the NMBCLUSTERS limit to 65535 just in case. What I've seen is that the server stops at 2400-2410 threads when I ask strees.c to create 8k connections. top shows I still have 150MB of free memory. Where should I look to raise this limit ? This is a CeleronM 1.3GHz and 512MB of RAM. Another behavior was that it creates 130 threads at once, waits, then another 130 more. It varies 1-10 threads sometimes but usually this inverval is constant. I think it might have something to do with the TCP code doing some normal limitation but I've look at it. Thanks, -- Giovanni P. Tirloni / gpt@tirloni.org