Skip to content

Commit 88f85ed

Browse files
OneZero-Yrootfs
authored andcommitted
fix:Improve rust unit test and optimize concurrent tests with rayon (vllm-project#471)
- Add 6 new unit test files - Replace std::thread::spawn with rayon::par_iter Signed-off-by: OneZero-Y <[email protected]> Signed-off-by: Huamin Chen <[email protected]>
1 parent c48f51e commit 88f85ed

File tree

10 files changed

+2513
-18
lines changed

10 files changed

+2513
-18
lines changed

candle-binding/src/classifiers/lora/parallel_engine_test.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Tests for Parallel LoRA Engine with performance benchmarks
22
33
use crate::test_fixtures::fixtures::*;
4+
use rayon::prelude::*;
45
use rstest::*;
56
use serial_test::serial;
67
use std::sync::Arc;
@@ -207,19 +208,14 @@ fn test_performance_concurrent_requests(
207208
println!("\n🔢 Testing with {} concurrent requests", num_threads);
208209

209210
let start = Instant::now();
210-
let handles: Vec<_> = (0..*num_threads)
211-
.map(|_| {
212-
let classifier = Arc::clone(classifier);
213-
std::thread::spawn(move || classifier.classify_intent(test_text))
214-
})
211+
212+
// Use rayon for parallel execution - simpler and more efficient
213+
let results: Vec<_> = (0..*num_threads)
214+
.into_par_iter()
215+
.map(|_| classifier.classify_intent(test_text))
215216
.collect();
216217

217-
let mut success_count = 0;
218-
for handle in handles {
219-
if handle.join().is_ok() {
220-
success_count += 1;
221-
}
222-
}
218+
let success_count = results.iter().filter(|r| r.is_ok()).count();
223219

224220
let duration = start.elapsed();
225221
println!(

candle-binding/src/core/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,8 @@ pub use tokenization::{
3535
#[cfg(test)]
3636
pub mod config_loader_test;
3737
#[cfg(test)]
38+
pub mod similarity_test;
39+
#[cfg(test)]
40+
pub mod tokenization_test;
41+
#[cfg(test)]
3842
pub mod unified_error_test;

0 commit comments

Comments
 (0)