Skip to content

Commit d19bc25

Browse files
committed
Better defaults / estimates
1 parent 14777f1 commit d19bc25

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "hibp_downloader"
3-
version = "1.0.1"
3+
version = "1.0.2"
44
license = "MIT"
55
authors = [
66
"Jonathan Underwood <[email protected]>"

src/config.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub struct Config {
1212
#[arg(long, default_value_t = default_workers())]
1313
pub workers: usize,
1414
/// The number of requests per worker
15-
#[arg(long, default_value = "20")]
15+
#[arg(long, default_value_t = default_multiplier())]
1616
pub multiplier: usize,
1717
/// Download NTLM hashes instead of SHA1 hashes
1818
#[arg(short, long)]
@@ -69,6 +69,12 @@ fn default_workers() -> usize {
6969
.get()
7070
}
7171

72+
fn default_multiplier() -> usize {
73+
// Cloudflare seems to throttle at 128 in-flight connections at a time
74+
// (Note: available_parallelism is guaranteed to be non-zero)
75+
128 / default_workers()
76+
}
77+
7278
/// This function gives a static reference to a Config struct.
7379
pub fn get_config<'a>() -> &'a Config {
7480
static CONFIG: OnceLock<Config> = OnceLock::new();

src/sort/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ pub fn run_sort(input: &Path, output: &Path, temp_dir: &Path) -> anyhow::Result<
3737
assert!(len == 32 || len == 40);
3838
len
3939
};
40-
// colon + average of 3 length number (max 8, min 1) + new line
41-
let row_size = hash_size + 5;
40+
// colon + average of 5 length number (max 8, min 1) + new line
41+
let row_size = hash_size + 7;
4242
let rows_in_file = input_byte_size / row_size as u64;
4343

4444
// This is a rough estimate.

0 commit comments

Comments
 (0)