Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benches/fetch_sweep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export XDG_STATE_HOME="$WORK/state"

emit() { # label -> reads $WORK/t.txt
awk -v l="$1" '/^real/{r=$2}/^user/{u=$2}/^sys/{s=$2}
END{c=u+s; printf "%-18s real=%7.2fs cpu=%6.2fs io_wait=%7.2fs (%2.0f%% wait)\n", l, r, c, r-c, r>0?100*(r-c)/r:0}' "$WORK/t.txt"
END{c=u+s; w=0; if(r>0) w=100*(r-c)/r; printf "%-18s real=%7.2fs cpu=%6.2fs io_wait=%7.2fs (%2.0f%% wait)\n", l, r, c, r-c, w}' "$WORK/t.txt"
}
sync_timed() { # jobs cold|warm -> exit nonzero on phora failure
local jobs="$1" mode="$2"
Expand Down
27 changes: 19 additions & 8 deletions src/sync/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,12 @@ fn resolve_unit(
}))
}

/// Default rayon pool size when `--jobs` is unset: one thread per unit, capped at
/// twice the core count so network-bound fetch overlaps I/O waits without unbounded
/// oversubscription of the CPU resolve/digest phase.
/// Default rayon pool size when `--jobs` is unset. The floor of 50 is measured,
/// not derived from cores: fetch is network-wait-bound and parked threads cost
/// memory, not CPU, so many small fetches stall on the pool ceiling long before
/// the box is busy (`benches/fetch_sweep.sh`).
Comment thread
srnnkls marked this conversation as resolved.
Outdated
fn default_thread_count(units: usize, cores: usize) -> usize {
units.min(2 * cores)
units.min((2 * cores).max(50))
}
Comment thread
srnnkls marked this conversation as resolved.

#[expect(
Expand Down Expand Up @@ -346,8 +347,18 @@ mod tests {
}

#[test]
fn default_thread_count_caps_at_twice_cores() {
assert_eq!(default_thread_count(20, 8), 16);
fn default_thread_count_uses_one_thread_per_unit_up_to_floor() {
assert_eq!(default_thread_count(50, 8), 50);
}

#[test]
fn default_thread_count_caps_at_floor_when_twice_cores_is_below_it() {
assert_eq!(default_thread_count(60, 8), 50);
}

#[test]
fn default_thread_count_caps_at_twice_cores_when_above_floor() {
assert_eq!(default_thread_count(200, 32), 64);
}

#[test]
Expand All @@ -356,8 +367,8 @@ mod tests {
}

#[test]
fn default_thread_count_single_core_caps_at_two() {
assert_eq!(default_thread_count(5, 1), 2);
fn default_thread_count_single_core_uses_floor_not_cores() {
assert_eq!(default_thread_count(60, 1), 50);
}

#[test]
Expand Down
Loading