perf: raise transfer defaults and stop uploads sleeping on their slot

The slot cap merged from master defaults to 2 uploads, and the CLI capped
downloads at 5. Those are the numbers you pick when your own bandwidth is the
scarce resource, but a Soulseek transfer is paced by the peer on the other end
— usually a few hundred KiB/s — so what fills a modern link is many transfers
at once, not faster ones. Upload slots go to 10, downloads to 20. The queue
itself stays: privileged users being able to jump it is a condition of being a
tolerated third-party client.

serve_file also slept half a second after the last byte so the downloader could
drain before the socket closed. With a cap that is time no other peer can use,
and 64 uploads over 10 slots paid it six times over. A half-close says "that is
the whole file" and TCP still delivers everything written before the FIN.

Measured with 64 waiting peers: 2 slots 24.2s, 8 slots 6.2s, 32 slots 3.1s; at
10 slots the linger alone was 5.4s to 3.05s.
This commit is contained in:
Michel de Graaf
2026-07-26 18:25:50 +02:00
parent 5b4ef30f08
commit 7435d48b32
10 changed files with 41 additions and 18 deletions
+10
View File
@@ -13,6 +13,7 @@
//! STRESS_DOWNLOADS downloads started at once
//! STRESS_LEECHERS mock peers pulling uploads from us at once
//! STRESS_BROWSES browses fired at once
//! STRESS_UPLOAD_SLOTS concurrent upload slots (default: every leecher)
//! STRESS_FILE_KB size of every transferred file
//! STRESS_TIMEOUT seconds before the run is called off
//! STRESS_SAVE=1 store this run as the new baseline
@@ -54,6 +55,7 @@ struct Config {
downloads: usize,
leechers: usize,
browses: usize,
upload_slots: usize,
file_bytes: usize,
timeout: Duration,
save: bool,
@@ -74,6 +76,13 @@ impl Config {
downloads: env_usize("STRESS_DOWNLOADS", 512),
leechers: env_usize("STRESS_LEECHERS", 256),
browses: env_usize("STRESS_BROWSES", 128),
// Serve every leecher at once by default: this profile measures
// concurrency, and the shipped slot cap would otherwise make it a
// measurement of the queue. Lower it deliberately to stress that.
upload_slots: env_usize(
"STRESS_UPLOAD_SLOTS",
env_usize("STRESS_LEECHERS", 256).max(1),
),
file_bytes: env_usize("STRESS_FILE_KB", 4096) * 1024,
timeout: Duration::from_secs(env_usize("STRESS_TIMEOUT", 60) as u64),
save: std::env::var("STRESS_SAVE").is_ok_and(|v| v == "1"),
@@ -980,6 +989,7 @@ fn main() {
});
client.connect().expect("client connect");
assert!(client.login().expect("client login"), "client login failed");
client.set_upload_slots(cfg.upload_slots);
std::thread::sleep(Duration::from_secs(1));
let client = Arc::new(client);