google / google/grain

SharedMemoryArray is too slow

Open
#851 3 comments 2 reactions 0 assignees View on GitHub
type:performance
Dominant language
Python
Stars
779
Forks
86
Avg merge
2d 6h
Merged PRs (30d)
6

Description

I've extensively tested the MP implementation in grain and it's very slow.

![Image](https://github.com/user-attachments/assets/cf75646a-774c-4b26-b775-24c7a44830a1)

The $batch in the middle (violet) is the stacking function that takes 21ms to stack batch of 128. So I expect it should be like 25-40ms as a whole but the 'next' call takes whooping 224 ms. On this profile trace above you can see the awaiting, and then deleting the SharedMemoryArrays, dominates the 'next' call.

I can see how awaiting can struggle because workers are not fast enough (and this is not the case) but I can't see why simple deleting operation could take 1+ms for each array. I believe it just kills the purpose of the shared memory array and naive push through 'multiprocessing.Queue' would be much faster.

Any plans on improving the MP implementation?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.