-
Notifications
You must be signed in to change notification settings - Fork 358
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
Feature: Implement MMap for In Memory IO #972
base: main
Are you sure you want to change the base?
Conversation
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.
Looks sensible, @PThorpe92 did you have the opportunity to review this already?
Hey @pedrocarlo for Linux we are importing rustix in io, which has mmap, munmap, mremap, etc. In case you want to use that instead of importing a new dependency. The main difference is that rustix doesn't give you a clean safe API, it exposes unsafe functions, closer to the syscalls/libc but returning Result and such. If you want help, feel free to ping me. |
Hey @LtdJorge! I agree. For the project, it would be better to use an already existing dependency instead of introducing a new one like |
Hey @pedrocarlo! I think dropping the new dependency is a pre-requisite for merging this, but otherwise looks sensible to me. |
84fb931
to
e9f00ba
Compare
Hey @penberg! Unfortunately, I just noticed that |
@pedrocarlo I think it might make more sense to feature flag mmap for unix, then the others can use the original impl and we add no new dependencies |
@PThorpe92 that seems the best path. Sad that persisting to database will only be available to unix for now. I will fix it either today or tomorrow. |
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.
Don't want to hold this up for too much longer, but just a few minor comments. Overall looks good, glad we were able to keep the dependencies down 👍
Indeed. Fortunately after #960 is merged it will be much easier to extend the IO layer :) It's possible that functionality will end up being baked into a vfs extension anyway, where we are much limited by the stricter package requirements of |
@PThorpe92 I think everything should be good to go now! |
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.
Looks good to me 👍
@penberg is there anything more you think I should change here? |
@penberg I just noticed that there is some conflicts in memory.rs as its trying to implement Send and Sync. How would this change impact the changes I am trying to do here? EDIT: @PThorpe92 gave me a hand on the rebase so everything should be fine now. |
17c2f02
to
dfa78ff
Compare
dfa78ff
to
792fd27
Compare
This PR implements MMap to support, in the future, persistence of an in-memory database to a file, as is tracked by this issue: #859. I wanted to thank @PThorpe92 a lot for letting me try implementing this feature.
Changes/Additions
BTreeMap<usize, MemPage>
forMMapMut
INITIAL_PAGES
, that defines the initial number of pages that the MMap will be initialized with. The default is 16, that amounts to 16 * 4096 bytes = 64kb of memory allocated on startup.CI
enviroment value has been added in the testing github workflow to set theINITIAL_PAGES
env var to 5, so that resizing happens more often in testing.TODO's and Improvements
PRAGMA
statement that takes a file path or DB name to persistence the file on disk. This value would then be saved in theMemoryFile
struct. This could happen by extending theFile
trait with a method e.gfn persist(db_path:&str)
.MemoryFile
is dropped.DELETE
statements.I would appreciate some feedback on my implementation and any other point I may have overlooked.