-
Notifications
You must be signed in to change notification settings - Fork 43
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
Experimental mmap on Unix #201
Open
gaborcsardi
wants to merge
19
commits into
main
Choose a base branch
from
feature/mmap
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
720b4b6
to
d7334d2
Compare
77d2b18
to
7623fef
Compare
We'll also need some C API for these, i.e. get the string description of an OS handle.
To show how to serialize into shared memory.
[ci skip]
d883bd6
to
43bfd4c
Compare
Codecov Report
@@ Coverage Diff @@
## master #201 +/- ##
==========================================
+ Coverage 70.22% 71.67% +1.45%
==========================================
Files 31 38 +7
Lines 2556 3838 +1282
==========================================
+ Hits 1795 2751 +956
- Misses 761 1087 +326
Continue to review full report at Codecov.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This could be in its own package, potentially, but since we pass the file descriptor to the subprocess as a processx connection, it is here now.
Notes:
conn_create_mmap()
creates a piece of shared memory that contains a bunch of R objects. The objects are copied there, so they can be removed once the function returns. It sets up the copy with leaving space for the SEXP header in front of the objects, so when unpacking we can just put the header there, without copying anything.conn_unpack_mmap()
unpacks shared memory into an R list. It does not copy the memory, it uses a custom allocator andallocVector3()
to create the SEXPs in place.mmap()
that 8 bytes, to get the size, and thenmmap()
again with the correct size.REALSXP
,INTSXP
,LGLSXP
,RAWSXP
.REAL()
,INTEGER()
, etc. on the vectors.MAP_PRIVATE
, so it can modify the objects, without affecting the master or the other children.ftruncate()
andmmap()
, etc.callr::r_session
.shm_open()
, etc. because on macOS the limits for the number of pages that can be shared this way are very very low.