Skip to content

Commit 0718539

Browse files
Paolo TranquilliCopilot
andcommitted
Rust: Parse CODEQL_THREADS without codeql-extractor
The Rust extractor no longer depends on codeql-extractor on main, so the stacked CI merge failed to resolve parse_codeql_threads. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b98227f5d3a24d73abe15df037acd68e
1 parent 592a6fb commit 0718539

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎rust/extractor/src/parallel.rs‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use codeql_extractor::options::parse_codeql_threads;
21
use std::num::NonZero;
32
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
43
use tracing::warn;
@@ -14,10 +13,15 @@ pub fn extraction_threads() -> usize {
1413

1514
fn threads_from(value: Option<&str>, cores: usize) -> usize {
1615
let Some(value) = value else { return 1 };
17-
parse_codeql_threads(value.trim(), cores).unwrap_or_else(|| {
18-
warn!("ignoring invalid CODEQL_THREADS value '{value}'");
19-
1
20-
})
16+
// As in the extractor spec, zero or negative values are relative to `cores`, with a minimum of 1.
17+
match value.trim().parse::<i32>() {
18+
Ok(n) if n > 0 => n.unsigned_abs() as usize,
19+
Ok(n) => cores.saturating_sub(n.unsigned_abs() as usize).max(1),
20+
Err(_) => {
21+
warn!("ignoring invalid CODEQL_THREADS value '{value}'");
22+
1
23+
}
24+
}
2125
}
2226

2327
/// Extraction recurses deeply on nested code, so workers need more than the default 2 MiB stack.

0 commit comments

Comments
 (0)