-
Notifications
You must be signed in to change notification settings - Fork 89
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
Restructure multithreading #230
Conversation
2878c3a
to
5d4e953
Compare
Redefine the Worker trait, which allows the chosen worker to create a new scope. This is relevant for a newly created (and installed) rayon worker. The rayon thread pool is now local to the decoding step. This fixes an issue where improper task scheduling would deadlock decoding. It's not clear how the intended task scheduling can be reliably achieved without the guarantee of having at least a second, free, worker thread.
5d4e953
to
9e9ac1a
Compare
Okay, scratch that. This is why it was a draft. How about this: In this Now the critical part: We modify |
Moves it to a seperate module. Rayon now spawn in-place closures with no explicit communication instead for workers. This can parallelize by spawning multiple rows of data at the same time.
Sharing of the structure is, at the moment, purely incidental. This has a small performance hit on the implementation of append_row (singular) because it now also goes through the mutex phases.
I've given |
match prefer { | ||
#[cfg(not(any(target_arch = "asmjs", target_arch = "wasm32")))] | ||
#[cfg(feature = "rayon")] | ||
PreferWorkerKind::Multithreaded => self::rayon::with_rayon(f), | ||
#[cfg(not(any(target_arch = "asmjs", target_arch = "wasm32")))] | ||
PreferWorkerKind::Multithreaded => self::multithreaded::with_multithreading(f), | ||
_ => self::immediate::with_immediate(f), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this is not final, but setup to always choose rayon over multithreading over immediate. Note that we may choose any available one at runtime with this style.
Through very careful use of borrows, where we take the right operations in the right sequence, we can use the borrow checker to assert that all tasks write to disjunct result slices. This avoids the need of runtime borrow checking—which required synchronization.
Restructure multithreading
Redefine the Worker trait, which allows the chosen worker to create a
new scope. This is relevant for a newly created (and installed) rayon
worker.
The rayon thread pool is now local to the decoding step. This fixes an
issue where improper task scheduling would deadlock decoding. It's not
clear how the intended task scheduling can be reliably achieved without
the guarantee of having at least a second, free, worker thread.
Closes: #227