-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
file:position wipes read_ahead buffer unconditionally #4706
Comments
We'd like to have this but don't feel we have the time to finish it before OTP 24, so a PR would be welcome. |
What's the timeline for OTP-24? How much time do I have to do this? I am close to the point where I can work on this but I would like to be sure I can make it on time. |
The final release candidate will be frozen on Friday so we'll need to have it by Wednesday evening, but there's no need to rush. We can always add it in OTP 24.1 instead. |
I've written lhoguin@7d95212 but I am not happy with it. It would be possible to get an even better result by attaching the position of the start of the buffer to the fd. That way we do not need to do a seek call to return the new position, and we could avoid wipe/seek calls in more scenarios than just I think it would be possible to use an What do you think? |
Also allowing The one about |
Yes, though that requires a
I fear it might make things a bit too complicated. Do you think something along the lines of a memory-mapped file would work well for you? (Leaving |
One of the goals is to allow using as little memory as possible so mmap sounds inadequate. Anyway I have to first implement a write buffer so that there aren't so many read/write calls, allowing reading from that write buffer directly, and then see what would make sense to do with the read/write that remain. I'll revisit this when that time comes. Cheers! |
Happy to open a PR for lhoguin@7d95212 if you think it's worth it. On my end I have a lot of |
Is your feature request related to a problem? Please describe.
When using
file:position
on a handle that hasread_ahead
enabled, and moving to a position that would land inside theread_ahead
buffer (for example,{cur, 128}
likely would), the buffer is wiped and a system seek is done instead.otp/erts/preloaded/src/prim_file.erl
Lines 289 to 311 in 4092279
(Click the link for the full context.)
Describe the solution you'd like
The buffer should not be wiped. Only the beginning of the buffer should be skipped via
prim_buffer:skip
.Describe alternatives you've considered
Reimplementing much of the same functionality in my project.
Additional context
Something curious I've noticed while looking if
read_ahead
would be benefitial to my use case. I may send a PR if I am moving forward with this solution for my implementation.The text was updated successfully, but these errors were encountered: