Skip to content
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

Single-thread per-core (STPC) runtime for persistence layer #1947

Open
twitu opened this issue Sep 19, 2024 · 0 comments
Open

Single-thread per-core (STPC) runtime for persistence layer #1947

twitu opened this issue Sep 19, 2024 · 0 comments
Labels
enhancement New feature or request improvement Improvement to existing functionality rust Relating to the Rust core

Comments

@twitu
Copy link
Collaborator

twitu commented Sep 19, 2024

The persistence module streams data from parquet file(s) converts them into internal structures and passes them to the engine. This task has a mix of CPU (decoding and deserializing) and IO (reading from disk) and is well suited to being run on an async runtime. For more details check #705.

Currently, it is configured to use a multi-threaded fully featured tokio runtime. However, recent discussions around structured concurrency in Rust12 mention that a single-thread per-core (STPC) runtime is simpler and can sometimes be more performant. The persistence layer is one place where a STPC runtime might be a better choice.

We want to experiment with a few options to find a runtime that improves performance and possibly makes types/logic simpler and easier to understand (for e.g. removes the 'static lifetime requirement). Some STPC runtime options to consider are -

  • Single threaded configuration for the tokio runtime used in session.rs
  • tokio-uring
  • glommio
  • monoio

We never want the engine thread to be blocked by IO. So the logic will have to be changed to spawn the STPC runtime and the task of reading the parquet files in a separate thread and will send data to the "main" thread through a channel.

Note: A point to consider is that not all STPC runtimes support all operating systems. For e.g. only monoio has windows support that too experimental. So switching to an STPC runtime will probably require some conditional code that chooses runtime based on the is activated based on the operating system.

If STPC runtimes don't work well or cannot be implemented for all operating systems, we can still simplify the code by using the common runtime already used in other parts of the code base through the get_runtime function.

Footnotes

  1. https://blog.yoshuawuyts.com/tree-structured-concurrency/

  2. https://emschwartz.me/async-rust-can-be-a-pleasure-to-work-with-without-send-sync-static/

@twitu twitu added enhancement New feature or request rust Relating to the Rust core improvement Improvement to existing functionality labels Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request improvement Improvement to existing functionality rust Relating to the Rust core
Projects
None yet
Development

No branches or pull requests

1 participant