Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiprocessing: use SysV semaphores on FreeBSD #54557

Closed
vstinner opened this issue Nov 8, 2010 · 15 comments
Closed

multiprocessing: use SysV semaphores on FreeBSD #54557

vstinner opened this issue Nov 8, 2010 · 15 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@vstinner
Copy link
Member

vstinner commented Nov 8, 2010

BPO 10348
Nosy @db3l, @pitrou, @vstinner

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2011-10-04.23:26:38.654>
created_at = <Date 2010-11-08.01:57:23.709>
labels = ['type-feature', 'library']
title = 'multiprocessing: use SysV semaphores on FreeBSD'
updated_at = <Date 2011-10-04.23:26:38.652>
user = 'https://github.com/vstinner'

bugs.python.org fields:

activity = <Date 2011-10-04.23:26:38.652>
actor = 'jnoller'
assignee = 'none'
closed = True
closed_date = <Date 2011-10-04.23:26:38.654>
closer = 'jnoller'
components = ['Library (Lib)']
creation = <Date 2010-11-08.01:57:23.709>
creator = 'vstinner'
dependencies = []
files = []
hgrepos = []
issue_num = 10348
keywords = ['buildbot']
message_count = 15.0
messages = ['120705', '120709', '124795', '124796', '124831', '124838', '124862', '125042', '125043', '125045', '125046', '125160', '144908', '144909', '144931']
nosy_count = 6.0
nosy_names = ['db3l', 'pitrou', 'vstinner', 'jnoller', 'asksol', 'neologix']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = None
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue10348'
versions = ['Python 3.3']

@vstinner
Copy link
Member Author

vstinner commented Nov 8, 2010

Support POSIX semaphore on FreeBSD is recent, optional (eg. disabled by default in FreeBSD 7) and limited (30 semaphores). SYSV should be used instead because they are less limited or more adjustable (at runtime: POSIX semaphore requires to recompile the kernel!).

This issue should fix test_concurrent_futures on FreeBSD 7.2 and 8.0: many tests use more than 30 semaphores. The maximum is test_all_completed_some_already_completed: 52 semaphores.

@vstinner vstinner added the stdlib Python modules in the Lib dir label Nov 8, 2010
@vstinner
Copy link
Member Author

vstinner commented Nov 8, 2010

It looks like SysV semaphores are also preferred on Darwin. So I suppose that Mac OS X would also benefit of this issue. Maybe also other OSes (Solaris?).

See also issue bpo-7272.

@vstinner vstinner changed the title multiprocessing: use SYSV semaphores on FreeBSD multiprocessing: use SysV semaphores on FreeBSD Nov 8, 2010
@vstinner
Copy link
Member Author

Informations about SysV semaphores:

@vstinner
Copy link
Member Author

@vstinner
Copy link
Member Author

See also bpo-5725.

@vstinner
Copy link
Member Author

See also http://semanchuk.com/philip/sysv_ipc/: "System V IPC for Python - Semaphores, Shared Memory and Message Queues"

@jnoller
Copy link
Mannequin

jnoller mannequin commented Dec 29, 2010

Adding, or moving, to SYSV semaphores is very low on the list of things to do. If someone were to provide a patch, I'm sure we could consider it.

@vstinner
Copy link
Member Author

vstinner commented Jan 2, 2011

More info about FreeBSD.

"sysctl p1003_1b.sem_nsems_max" gives the maximum number of POSIX semaphores (per process? system wide?).

Since FreeBSD 8.1, "sudo sysctl -w p1003_1b.sem_nsems_max=256" can be used to change this limit at runtime.

Before FreeBSD 8.1, SEM_MAX constant should be changed in the kernel source code, and the kernel have to be recompiled. (p1003_1b.sem_nsems_max is not configurable in /etc/sysctl.conf, it is an hardcoded limit).

Before FreeBSD 8.0, the POSIX semaphores are disabled by default: the kernel have to be compiled using P1003_1B_SEMAPHORES option. Extract of sys/conf/NOTES:

#####################################################################
# POSIX P1003.1B

# Real time extensions added in the 1993 POSIX
# _KPOSIX_PRIORITY_SCHEDULING: Build in _POSIX_PRIORITY_SCHEDULING

options _KPOSIX_PRIORITY_SCHEDULING
# p1003_1b_semaphores are very experimental,
# user should be ready to assist in debugging if problems arise.
options P1003_1B_SEMAPHORES

# POSIX message queue
options P1003_1B_MQUEUE

#####################################################################

@vstinner
Copy link
Member Author

vstinner commented Jan 2, 2011

NetBSD.

Extract of the sem_close() manpage
http://www.daemon-systems.org/man/sem_close.3.html
---
STANDARDS
The sem_open(), sem_close(), and sem_unlink() functions conform to
ISO/IEC 9945-1:1996 (``POSIX.1'').

HISTORY
Support for named semaphores first appeared in NetBSD 2.0.
---

Martin wrote on the mailing list:
---
According to

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/uipc_sem.c?rev=1.22&content-type=text/x-cvsweb-markup&only_with_tag=MAIN

SEM_MAX is 128 since 2007, and dynamically adjustable (no reboot).
---

It looks like the sysctl (read/write) option is kern.posix.semmax.

@vstinner
Copy link
Member Author

vstinner commented Jan 2, 2011

Darwin (Mac OS X).

According to the following email (July 2010), Darwin supports POSIX semaphores and the default limit is 10,000 semaphores.
http://osdir.com/ml/darwin-dev/2010-07/msg00012.html

The limit is configurable via sysctl as kern.posix.sem.max.

@vstinner
Copy link
Member Author

vstinner commented Jan 2, 2011

OpenBSD.

According to Martin, OpenBSD doesn't implement POSIX semaphores.
---
I don't have an installation of OpenBSD, but...

In FreeBSD, POSIX semaphores are implemented in sys/kern/uipc_sem.c.
In

http://www.openbsd.org/cgi-bin/cvsweb/src/sys/kern/

that file doesn't exist. Also, in FreeBSD's limits.h,
_POSIX_SEM_NSEMS_MAX is defined (surprisingly to 256);
in

http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/include/limits.h?rev=1.15;content-type=text/plain

this constant doesn't appear. So ISTM that OpenBSD doesn't implement
POSIX semaphores. IIUC, this means that the multiprocessing module
won't be fully functional, and its tests (and the concurrent.futures
tests) will be skipped.
---

@vstinner
Copy link
Member Author

vstinner commented Jan 3, 2011

Martin fixed test_concurrent_futures (bpo-10798), this issue can be implemented later.

@vstinner vstinner added the type-feature A feature request or enhancement label Jan 3, 2011
@neologix
Copy link
Mannequin

neologix mannequin commented Oct 4, 2011

-1
IMHO, implementing SysV semaphores would be a step backwards, plus the API is a real pain.
I think there's no reason to complicate the code to accomodate such corner cases, especially since the systems that don't support POSIX semaphores will eventually die out...

@pitrou
Copy link
Member

pitrou commented Oct 4, 2011

Agreed with Charles-François.

@jnoller
Copy link
Mannequin

jnoller mannequin commented Oct 4, 2011

Charles and Antoine's votes match my own, therefore closing the bug wont fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants