New submission from Pierre Glaser <pierregla...@msn.com>:

Hi,
Following https://bugs.python.org/issue26836, I started thinking about using 
memfd_create instead of shm_open for creating shared-memory segments in 
multiprocessing.shared_memory.

The main advantage of memfd_create over shm_open is that the generated 
resources management is easier: a segment created using using memfd_create is 
released once all references to the segment are dropped. This is not the case 
for segments created using shm_open, for which additional resource tracking is 
needed (using the new multiprocessing.resource_tracker)

The main difference between those two calls is that segments created using 
memfd_create are anonymous and can only be accessed using file descriptors. The 
name argument in the signature serves only for debugging purposes. On the 
contrary, shm_open generates segments that map to a file in /dev/shm: 
therefore, segments each have unique names.

Would we decide to switch from shm_open to memfd_create, the name behavior will 
also change. How big of a deal would that be?

----------
messages: 344881
nosy: davin, pierreglaser, pitrou
priority: normal
severity: normal
status: open
title: use  os.memfd_create in multiprocessing.shared_memory?
type: resource usage
versions: Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37185>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to