Why not use memmap2? #1
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
mikedilger/mmap-append#1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
memmap2 is the defacto cross platform mmap library. I noticed a lot of the code in the crate is duplicating work that it already does, down to the mutable deref [u8]. It seems like it would save a lot of complexity/code.
It would also potentially have caught another issue we have where although this crate says it's for
unix, macos doesn't havemremap, as that is linux only.Emulating mremap here isn't difficult since we pass maymove, so we could try to remap at the old address and create a new mapping otherwise, or we could skip the old address part if it's not that important.
That information is useful, about mremap.
I don't think I could use and extend memmap2, I had to cut open it's innards to do what this crate does: let multiple threads Deref while a writer is appending. If I'm wrong about that, I'd appreciate being corrected in code.
All the commits happened over 5 days quite a while ago now, so I don't remember too many specifics.
I see... I think that makes sense since in append only mode, we don't need
&mut self, so that does makes sense. Could probably save some overlap by doing that on top ofhttps://docs.rs/memmap2/latest/memmap2/struct.MmapRaw.htmlthough, with theas_ptrandas_mut_ptr, but I do see how it is less of a boon now.I never got around to using this crate myself. When I do get back around to what it was for, I'll definitely take some time to see if I can't leverage memmap2 better.
Sounds good. I might take a stab at making an MR for it since I'm actually using it in production if you're interested.
At the very least, I'd want to provide an mremap workaround
Yeah, I'd like that