Skip to content
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

Use mremap on Linux instead of munmap+mmap #221

Merged
merged 3 commits into from
Nov 10, 2020
Merged

Conversation

ajeetdsouza
Copy link
Contributor

@ajeetdsouza ajeetdsouza commented Nov 10, 2020

Linux exposes an mremap function that is not available on other OSes, that allows us to remap an address space, providing a more efficient way to increase the size of an mmap file. This PR allows Linux systems to use the mremap call, while other OSes continue to use munmap followed by mmap.

sys does not provide an mremap function, so this had to handwritten using a system call. Unfortunately, the functions provided by sys for Mmap/Munmap maintain a list of active mappings, and do not allow us to Munmap anything that is not present in the list. Since our handwritten mremap call cannot update that internal list, we must reimplement the munmap system call as well.


This change is Reviewable

Copy link
Contributor

@jarifibrahim jarifibrahim left a comment

Choose a reason for hiding this comment

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

Clean it up and it's good to merge

z/file_linux.go Show resolved Hide resolved
z/file_default.go Show resolved Hide resolved
z/mmap_linux.go Show resolved Hide resolved
z/mmap_linux.go Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants