gh-121313: multiprocessing: change connection buffer size to 64KiB by methane · Pull Request #123559 · python/cpython · GitHub
Skip to content

gh-121313: multiprocessing: change connection buffer size to 64KiB - #123559

Merged
gpshead merged 9 commits into
python:mainfrom
methane:mp-bufsize
Sep 3, 2024
Merged

gh-121313: multiprocessing: change connection buffer size to 64KiB#123559
gpshead merged 9 commits into
python:mainfrom
methane:mp-bufsize

Conversation

@methane

@methane methane commented Sep 1, 2024

Copy link
Copy Markdown
Member

Windows:

Current buffer size is 8KiB since multiprocessing is introduced.
It seems small for recent Python usages.

e711caf#diff-2c54a007d7fe1d9ac5ca008fe2d054394c39a4f521eea2cb580101a284d7b7ecR28

macOS/BSD:

They use 64KiB buffer for pipes. Current 16 pages (256KiB) buffer makes ~10% slowdown compared to 64KiB on M1 mac.

Linux:

I don't have 16k/64k page Linux. But when I change the pipe buffer size via fcntl, 256KiB buffer doesn't make notable performance benefit.

64KiB seems good default buffer size.
If it is not suitable, user can try other size by changing multiprocessing.connection.BUFSIZE.

@methane

methane commented Sep 1, 2024

Copy link
Copy Markdown
Member Author

Comment thread Lib/multiprocessing/connection.py

@picnixz picnixz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really small nitpick. But otherwise LGTM.

Comment thread Lib/multiprocessing/connection.py Outdated
methane and others added 3 commits September 2, 2024 19:28
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Comment thread Misc/NEWS.d/next/Library/2024-07-03-10-11-53.gh-issue-121313.D7gARW.rst Outdated
Comment thread Lib/multiprocessing/connection.py Outdated
Comment thread Lib/multiprocessing/connection.py Outdated
Comment thread Misc/NEWS.d/next/Library/2024-07-03-10-11-53.gh-issue-121313.D7gARW.rst Outdated
methane and others added 2 commits September 2, 2024 20:32
Co-authored-by: Victor Stinner <vstinner@python.org>

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@methane

methane commented Sep 3, 2024

Copy link
Copy Markdown
Member Author

I tested this PR on Windows but no speedup. It is because Windows can read whole remaining data at once via this function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants