From owner-freebsd-arch Mon Nov 12 18:30:23 2001 Delivered-To: freebsd-arch@freebsd.org Received: from gull.prod.itd.earthlink.net (gull.mail.pas.earthlink.net [207.217.120.84]) by hub.freebsd.org (Postfix) with ESMTP id 7720B37B416; Mon, 12 Nov 2001 18:30:20 -0800 (PST) Received: from dialup-209.247.141.234.dial1.sanjose1.level3.net ([209.247.141.234] helo=mindspring.com) by gull.prod.itd.earthlink.net with esmtp (Exim 3.33 #1) id 163TL9-0007BQ-00; Mon, 12 Nov 2001 18:30:19 -0800 Message-ID: <3BF085EC.AEE7DE9C@mindspring.com> Date: Mon, 12 Nov 2001 18:31:08 -0800 From: Terry Lambert Reply-To: tlambert2@mindspring.com X-Mailer: Mozilla 4.7 [en]C-CCK-MCD {Sony} (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: John Baldwin Cc: Julian Elischer , freebsd-arch@FreeBSD.org, Robert Watson , Matthew Dillon Subject: Re: cur{thread/proc}, or not. References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG John Baldwin wrote: > > ANyhow can you explain the idea of a pool mutex more clearly? > > Heh, think of it as a pool of mutexes, not a different type of > mutex. Instead of having 1 mutex for each object, you use a hash > table of mutexes for a set of objects. Thus, if you have 50 objects > vs. 500 objects, if you embed 1 mutex for each object, you bloat > each object and have 500 locks instead of 50 locks. Using pool > mutexes, you only have N number of mutexes regardless of the number > of mutexes. Note that if pool mutexes are non-recursive, they can't > be safely used when you might have more than one object of a given > set locked at a time. For example, process locks are the only object > we do this with currently. Pool mutexes are evil, if not implemented exactly right, and "exactly right" will vary over time. We need only look at the allocation unit optimization for things like struct socket allocations, which weren't updated when kevent came in and changed the size of the structure and therefore made the previous optimal cluster allocation block pessimal instead. Pool mutexes have the same problem that the fixed hash size for TCP connections has, in that you end up with relatively large collision domains when you get to a relatively large number of objects being hashed. Increasing the hash is not an answer, since it means that the default tuned case tries to handle the max for everything and ends up taking up so much memory you get the max for nothing. You might be able to keep a "pool ratio"; e.g. "for every N objects, there will be 1 mutex bucket", but then you get into the problem of refactoring the existing buckets. There is also the issue of collision domain; we tend to see this with an incredible number of client connections to HTTP servers with the in_pcbhash code (to keep the same example), because the hash values for port 80 on a particular IP tend to be pretty limited. In other words, I think that you will run into locality issues which will give you a hash that results in a particular bucket being inordinately busy, while another one is idle. Unless you address the locality balancing issue up front, it is a bad idea to use this for mutexes for objects, even if each object type gets its own mutex pool to avoid collision multiplication when multiple object types are referenced from the same pool. -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message