-
Notifications
You must be signed in to change notification settings - Fork 0
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 O_DIRECT
#51
Comments
I think the problem is that the buffer needs to be aligned to 512-byte boundaries. And possibly the length also needs to be a multiple of 512 bytes. My SSD uses 512-byte logical block sizes: jack@jack-NUC:~/dev/rust/light-speed-io$ sudo blockdev --getss /dev/nvme0n1
512 See the O_DIRECT notes near the bottom of the manual for open. I should try using statx to find the O_DIRECT support and alignment restrictions for the files. |
Huh!
UPDATE: These results are invalid. See comments below I've run a flamegraph for the second scenario. It's in the associated pull request. |
Because this is so much slower (on my NUC), I'm not going to merge this PR. But I should re-visit this when I get my new workstation with a PCIe gen5 SSD. And maybe I should try some other ways to create a vector which is aligned to 512-bytes: |
Slow! Only about 560 MiB/s. See #51. Pausing work on this PR for now because it's so slow. I'll re-visit when I get my workstation with a PCIe gen 5 SSD!
Hopefully DIRECT will come into its own when we're loading huge numbers of small chunks (DIRECT avoids read ahead) and when we recycle buffers (because allocating aligned buffers seems to take a while!) |
I think the high numbers of page-faults might actually be due to copying data from the OS's page cache into the program's memory space. So O_DIRECT should help. And I need to re-run benchmarking now I've fixed the benchmarks! #71 |
I recently figured out that my benchmarks weren't correctly clearing the cache before every run. That invalidates my findings above that O_DIRECT is slow. So I should have another go with O_DIRECT! |
How to create an aligned buffer?In summary: I think I should create a new Alternatives:
|
On second thoughts, let's use |
See |
Hmm, so, I've implemented |
Still TODO: EDIT: Moved to top of this thread |
todo
<open><read><close>
#1aligned_buffer
into aBytes
struct. Instead, return anAlignedBuffer
. Benchmark again.get
andget_range
#90read
operation reads the correct number of bytes #97AlignedBuffer
to check behaviour when usingstart_offset
. #98The text was updated successfully, but these errors were encountered: