gh-83765: indicate the maximum amount of memory on macOS#138552
gh-83765: indicate the maximum amount of memory on macOS#138552nilleb wants to merge 3 commits intopython:mainfrom
Conversation
Fixed following the suggestion python#83765 (comment)
| memory block may be larger or equal to the size requested. | ||
| When attaching to an existing shared memory block, | ||
| the *size* parameter is ignored. | ||
| On macOS, the maximum size of a shared memory block is 140256418463744 bytes. |
There was a problem hiding this comment.
At the very least please add some commas, but it might be more helpful to use a saner and more human readable unit:
| On macOS, the maximum size of a shared memory block is 140256418463744 bytes. | |
| On macOS, the maximum size of a shared memory block is 127 TiB (140,256,418,463,744 bytes). |
There was a problem hiding this comment.
Also, it would be useful to add a reference to where this number comes from. I can't see anything on the linked issue mentioning it.
There was a problem hiding this comment.
Hi! Thank you for your comment! This number has been computed this way: https://gist.github.com/nilleb/e60e7adbfe2afaf9d727231c59b01100
I have tested it on macOS Sequoia 15.6.1.
That is the best I can afford for the moment, I don't have access to older operating systems.
There was a problem hiding this comment.
Ok, if this is an experimentally found number we should remove it, there are no guarantees.
Instead, say something like 'the maximum size is around 120 TiB'.
However, I'm now less sure about including this warning in the documentation, given the limit doesn't come from a documented or well-known property of macOS, and could change without warning. cc @python/macos-team for thoughts.
There was a problem hiding this comment.
Searching further, I have found this SO post https://stackoverflow.com/a/77078609
Where they mention 0x00007ffffe000000 that corresponds to 140737454800896 (so a bit more that the size I get).
This would be compatible with the fact that the memory for a python process is limited to 128TiB on a 64bits macOS OS (and hence the maximum allowed value depends on the memory already allocated by python itself).
I would propose to add a link to https://github.com/apple-oss-distributions/xnu/blob/xnu-8796.141.3/osfmk/mach/arm/vm_param.h#L137
And a paraphrase of the explanation above.
WDYT?
There was a problem hiding this comment.
Maybe I'm wrong here but AFAICT, 127 TiB is not 140,256,418,463,744 bytes. Indeed 1 TiB is
Instead, I would rather say that the maximum amount of memory on a 64-bit architecture is upperbounded by mathjax enabled, we can use the math role, otherwise, you can write it down in full numbers.
There was a problem hiding this comment.
OK, here is a further commit for your review! (the math role seems to be available, thank you!)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
gpshead
left a comment
There was a problem hiding this comment.
Why do we need to document this at all? It is platform specific and Apple will never ship hardware with anything approaching that much memory.
I don't think this is useful information for Python multiprocessing users to have.
FWIW other architectures have similar limits. The details of each aren't relevant here though.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
left a comment on the issue. a more generic "btw your platform has limits" at most could make sense, otherwise this is too specific for cpython docs. (probably do a another PR for that if you want it at all) |
|
@gpshead may I just suggest to close the mentioned issue? That might be misleading for other wannabe fixers. Thank you! |
Fixed following the suggestion #83765 (comment)
📚 Documentation preview 📚: https://cpython-previews--138552.org.readthedocs.build/