martindurant / shm-distributed

Benchmark and run scripts for shared memory on dask
MIT License
0 stars 1 forks source link

Using `multiprocessing.managers.SharedMemoryManager` #4

Open jakirkham opened 1 year ago

jakirkham commented 1 year ago

Python has a builtin shared memory manager (added in Python 3.8), which could also be spun up in a separate process and used. It doesn't do its own serialization like some of the others here do, but it could reuse Distributed's own serialization methods. The benefit here being that if this worked reasonable well one could use it without additional dependencies. Even if other options performed better, this could still be a reasonable default.

martindurant commented 1 year ago

I don't believe it does reference counting for you; could try it, though.

jakirkham commented 1 year ago

The docs suggest one needs to call close on each SharedMemory instance.

That said, it looks like this happens in SharedMemory.__del__ already.

So maybe one can just rely on that?

martindurant commented 1 year ago

I'll try to give it a go maybe later this week.