the number of file descriptors when using POSIX semaphore

Started by flyusa2010 flyabout 15 years ago3 messages
#1flyusa2010 fly
flyusa2010@gmail.com

Hi, folks,

in src/template/darwin:

# Select appropriate semaphore support. Darwin 6.0 (Mac OS X 10.2) and up
# support System V semaphores; before that we have to use POSIX semaphores,
# which are less good for our purposes because they eat a file descriptor
# per backend per max_connection slot.

To my understanding, the number of descriptors created by POSIX semaphores
would be # of actual clients times max_connection.
However, I monitor the number of open files using sysctl, and I find that
kern.num_files doesn't match the result calculated by the formula that is
inferred by me...

So, what would the number of file descriptors be, when using POSIX
semaphore?

Thanks!

#2Bruce Momjian
bruce@momjian.us
In reply to: flyusa2010 fly (#1)
Re: the number of file descriptors when using POSIX semaphore

flyusa2010 fly wrote:

Hi, folks,

in src/template/darwin:

# Select appropriate semaphore support. Darwin 6.0 (Mac OS X 10.2) and up
# support System V semaphores; before that we have to use POSIX semaphores,
# which are less good for our purposes because they eat a file descriptor
# per backend per max_connection slot.

To my understanding, the number of descriptors created by POSIX semaphores
would be # of actual clients times max_connection.
However, I monitor the number of open files using sysctl, and I find that
kern.num_files doesn't match the result calculated by the formula that is
inferred by me...

So, what would the number of file descriptors be, when using POSIX
semaphore?

I thought the text was wrong, but this commit reinforces that text:

commit 93407d3998cc8717993dbc102f854a478985bc19
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: Wed Sep 26 00:32:46 2007 +0000

Use SYSV semaphores rather than POSIX on Darwin >= 6.0
(i.e., OS X 10.2 and up), per Chris Marcellino. This
avoids consuming O(N^2) file descriptors to support N
backends. Tests suggest it's about a wash for small
installations, but large ones would have a problem.

What numbers are you seeing?

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#2)
Re: the number of file descriptors when using POSIX semaphore

Bruce Momjian <bruce@momjian.us> writes:

flyusa2010 fly wrote:

in src/template/darwin:

# Select appropriate semaphore support. Darwin 6.0 (Mac OS X 10.2) and up
# support System V semaphores; before that we have to use POSIX semaphores,
# which are less good for our purposes because they eat a file descriptor
# per backend per max_connection slot.

So, what would the number of file descriptors be, when using POSIX
semaphore?

I thought the text was wrong, but this commit reinforces that text:

The text is correct, or at least as correct as it's possible to get
without expending three times the verbiage. If you look in
InitProcGlobal you will find that the postmaster creates MaxConnections
plus autovacuum_max_workers + 1 plus NUM_AUXILIARY_PROCS semaphores.
In a POSIX-semaphores implementation, each of these eats a file
descriptor in the postmaster, plus another file descriptor in each child
process of the postmaster.

The OP claims the text is wrong, but since he failed to state what he
observed, it's pretty hard to comment further.

regards, tom lane