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

Switch to using the Rayon threadpool instead of spawning threads for each work item #61

Merged
merged 2 commits into from
Apr 8, 2024

Conversation

mcroomp
Copy link
Collaborator

@mcroomp mcroomp commented Apr 6, 2024

This is a result of the investigation on high CPU usage, which appears to be caused by large numbers of threads starting/stopping.

This will result in less obnoxious CPU usage since Rayon is a highly optimized threadpool that is able of grow/shrink as work items become available.

There is a minor change in behavior where we don't try to merge work items on read anymore, since the threadpool already is responsible for making sure that we don't fan out too broadly.

Copy link
Contributor

@gbrovman gbrovman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Consider to bump the nuget package version as part of the same change.

@@ -311,7 +309,7 @@ fn run_lepton_decoder_threads<R: Read + Seek, P: Send>(
lh: &LeptonHeader,
reader: &mut R,
last_data_position: u64,
max_threads_to_use: usize,
_max_threads_to_use: usize,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why it's not used anymore? I'd expect it to be used similar C# ThreadPool MaxParallelization, if it is supported in Rayon.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kind of a global thing so its hard to set as part of the api

@mcroomp mcroomp merged commit 2e34f1d into main Apr 8, 2024
3 checks passed
@mcroomp mcroomp deleted the threadpool branch April 8, 2024 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants