-
Notifications
You must be signed in to change notification settings - Fork 160
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
Add async read interface #30
Comments
It seems like Here are IO uring benchmarks: #61 |
👋 Thanks for sharing your code! So async support is one of the first things I look for when new persistent trees pop up in the Rust ecosystem and I'm a bit saddened by finding this issue as wontfix. Now I/O uring as an I/O interface is rarely going to be "as fast" as using mmap and letting the kernel synchronize memory regions directly with no buffer management and little to no syscall overhead. But async support would be valuable in itself in that it would allow redb to cleanly integrate with the rest of the async ecosystem. As it stands when integrating redb into a larger async application you'd run the hazard of spurious I/O blocking due to page faults, forcing you to utilize coping mechanisms like a blocking thread pool which comes with its own overhead. Integrating async I/O uring support comes with its own challenges that I'm sympathetic towards. But I'm at least curious if you could be convinced to reconsider the status of this issue? |
For sure, hope you or someone else finds it useful! Ya, I think that's a good argument for reconsidering an async read interface. I'll take another look into this. |
We're also interested in this. Not necessarily for the async nature of things, but for the promise of io_uring. Given mmap is now optional (and not the default) in Coincidently, I've stumbled on an interesting article regarding io_uring and its performance: https://itnext.io/modern-storage-is-plenty-fast-it-is-the-apis-that-are-bad-6a68319fbc1a That article makes me think the only way to saturate I/O on modern NVMe drives is likely to do multi-threaded reads. I know next to nothing about these things, just thought I'd ping this issue to see what's the current state of affairs. |
notes to self:
|
Hey @cberner,
|
The problem with seek and read_seek is that they take |
Also, they use |
In my opinion, the https://gist.github.com/SunDoge/2d361a289b75b7c06607c04e2230add9
When reading multiple files concurrently, iouring can be even faster. I've implemented tfrecord reader with iouring and it performs really good, with 1.1 GiB/s throughput (1 thread) vs 500 MiB/s sync read (4 threads). |
I wanted to add some color here. ordinals.com performance has been horrible, and we finally figured out why. The issue is that we're using an async web framework, so all of our endpoint functions are async. However, those functions then call into redb, which is not async. When those calls are slow, tokio kind of melts, since you have a bunch of async tasks which aren't yielding. If redb supported an async interface, then we could do everything in async, and it wouldn't be a problem. However, the fix was very simple. We just used |
@casey sounds about right! Have you tried |
@jeromegn Good suggestion! I didn't know about block_in_place, I'll give that a try. Could this cause issues if there are a bunch of concurrent tasks using |
@casey the runtime will spawn more threads if the current thread blocks for too long (for some measure of long). For things that block only for up to 1ms, it's probably not worth it to use block_in_place or spawn_blocking. I assume your use case has longer execution times. The main benefit of block_in_place is not having to clone or use only Send + Sync + 'static types. You can pass references since it executes closure on the current thread. |
Perhaps redb could offer an async-friendly api that wraps the sync api in |
Is there anything redb would do that a separate crate couldn't? |
I don't know. Probably not. For a second you got me excited thinking there might be a redb-tokio crate already, but anyway such a crate seems like a good way to do it. |
Blocked on:
The text was updated successfully, but these errors were encountered: