Single-thread per-core (STPC) runtime for persistence layer #1947
Labels
enhancement
New feature or request
improvement
Improvement to existing functionality
rust
Relating to the Rust core
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 -
session.rs
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
https://blog.yoshuawuyts.com/tree-structured-concurrency/ ↩
https://emschwartz.me/async-rust-can-be-a-pleasure-to-work-with-without-send-sync-static/ ↩
The text was updated successfully, but these errors were encountered: