-
-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lmdb: Platform-specific default map size #111
base: main
Are you sure you want to change the base?
Conversation
The current code works fine on x86 platforms since x86-64 uses at least 48-bit of virtual address space. On other 64-bit platforms like aarch64 or riscv64, the minimum allowed virtual address is 39-bit [1] [2]. Current 2**40 allocation will fail: ``` zict/tests/test_lmdb.py:53: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <zict.lmdb.LMDB object at 0x40043bfc10> directory = '/tmp/test_lmdb-sfepfnw8' def __init__(self, directory: str): import lmdb # map_size is the maximum database size but shouldn't fill up the # virtual address space map_size = 1 << 40 if sys.maxsize >= 2**32 else 1 << 28 # writemap requires sparse file support otherwise the whole # `map_size` may be reserved up front on disk writemap = sys.platform.startswith("linux") > self.db = lmdb.open( directory, subdir=True, map_size=map_size, sync=False, writemap=writemap, ) E lmdb.Error: /tmp/test_lmdb-sfepfnw8: Operation not supported zict/lmdb.py:43: Error ``` Switching to 2**37 on aarch64 and riscv64 should fix the issue. [1]: https://www.kernel.org/doc/html/v5.8/arm64/memory.html [2]: https://www.kernel.org/doc/html/latest/riscv/vm-layout.html
Backported map size fix from dask/zict#111.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @crusaderky if you have bandwidth to take a look at this
Backported map size fix from dask/zict#111.
elif machine in ["x86_64", "x64"]: | ||
map_size = 2**40 | ||
elif machine in ["i386", "i686", "x86"]: | ||
map_size = 2**30 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elif machine in ["x86_64", "x64"]: | |
map_size = 2**40 | |
elif machine in ["i386", "i686", "x86"]: | |
map_size = 2**30 |
Wasn't this already covered by sys.maxsize // 4
?
map_size = 2**40 | ||
elif machine in ["i386", "i686", "x86"]: | ||
map_size = 2**30 | ||
elif machine.startswith("aarch64") or machine.startswith("armv8") or machine.startswith("riscv64"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elif machine.startswith("aarch64") or machine.startswith("armv8") or machine.startswith("riscv64"): | |
elif ( | |
machine.startswith("aarch64") | |
or machine.startswith("armv8") | |
or machine.startswith("riscv64") | |
): | |
# x86-64 uses at least 48-bit of virtual address space. On other 64-bit platforms like aarch64 | |
# or riscv64, the minimum allowed virtual address is 39-bit so 2**40 allocation will fail. |
map_size = 2**40 | ||
elif machine in ["i386", "i686", "x86"]: | ||
map_size = 2**30 | ||
elif machine.startswith("aarch64") or machine.startswith("armv8") or machine.startswith("riscv64"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about 32-bit armv8?
- Temporarily vendor fix-map-size.patch to fix rotten - Waiting for dask/zict#111
- Temporarily vendor fix-map-size.patch to fix rotten - Waiting for dask/zict#111
The current code works fine on x86 platforms since x86-64 uses at least 48-bit of virtual address space. On other 64-bit platforms like aarch64 or riscv64, the minimum allowed virtual address is 39-bit 1 2. Current 2**40 allocation will fail:
Switching to 2**37 on aarch64 and riscv64 should fix the issue.