Skip to content

Commit e34761e

Browse files
committed
test multithreaded dict builder
1 parent a33f04d commit e34761e

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

lib/dictBuilder/cover.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,7 @@ pub unsafe extern "C" fn ZDICT_optimizeTrainFromBuffer_cover(
12941294
core::slice::from_raw_parts(samplesBuffer.cast::<u8>(), totalSamplesSize)
12951295
};
12961296

1297-
let mut best = COVER_best_t::new();
1297+
let best = COVER_best_t::new();
12981298

12991299
for d in (kMinD..=kMaxD).step_by(2) {
13001300
let mut ctx = COVER_ctx_t::default();

test-libzstd-rs-sys/src/dict_builder.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,17 @@ fn test_train_from_buffer_fastcover() {
196196

197197
#[test]
198198
#[cfg(not(target_family = "wasm"))]
199-
fn test_optimize_train_from_buffer_cover_pool() {
199+
fn test_optimize_train_from_buffer_cover_single_threaded() {
200+
test_optimize_train_from_buffer_cover_pool(1);
201+
}
202+
203+
#[test]
204+
#[cfg(not(target_family = "wasm"))]
205+
fn test_optimize_train_from_buffer_cover_multi_threaded() {
206+
test_optimize_train_from_buffer_cover_pool(4);
207+
}
208+
209+
fn test_optimize_train_from_buffer_cover_pool(thread_count: u32) {
200210
let input_data = "The quick brown fox jumps high";
201211

202212
assert_eq_rs_c!({
@@ -218,8 +228,7 @@ fn test_optimize_train_from_buffer_cover_pool() {
218228
k: 200,
219229
d: 8,
220230
steps: 4,
221-
// NOTE: a nbThreads value above 1 uses the pool
222-
nbThreads: 1,
231+
nbThreads: thread_count,
223232
splitPoint: 0.5,
224233
shrinkDict: 0,
225234
shrinkDictMaxRegression: 1,

0 commit comments

Comments
 (0)