-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Using chunking in predicate add
- Loading branch information
Showing
8 changed files
with
136 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
pub mod allocator; | ||
pub mod client; | ||
pub mod parallel; | ||
pub mod persistence; | ||
pub mod protocol; | ||
pub mod server; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use rayon::ThreadPoolBuilder; | ||
use std::sync::Once; | ||
|
||
static INIT_THREADPOOL_ONCE: Once = Once::new(); | ||
|
||
// Initialize global rayon threadpool | ||
pub(crate) fn init_threadpool(num_threads: usize) { | ||
INIT_THREADPOOL_ONCE.call_once(|| { | ||
ThreadPoolBuilder::new() | ||
.num_threads(num_threads) | ||
.build_global() | ||
.expect("Cannot build server threadpool"); | ||
}); | ||
} | ||
|
||
// Calculates chunk size to use for an iterable input in order for it to be able to fit into all | ||
// possible rayon threads | ||
pub fn chunk_size(input_length: usize) -> usize { | ||
let num_threads = rayon::current_num_threads(); | ||
let minimum_factor = std::cmp::min(input_length, num_threads); | ||
(input_length + minimum_factor - 1) / minimum_factor | ||
} |
Oops, something went wrong.