diff --git a/Cargo.lock b/Cargo.lock index 872ed9b..a063f17 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "ahash" -version = "0.8.11" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +checksum = "42cd52102d3df161c77a887b608d7a4897d7cc112886a9537b738a887a03aaff" dependencies = [ "cfg-if", "getrandom", @@ -101,9 +101,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.15.4" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bumpalo-herd" diff --git a/calculate/Cargo.toml b/calculate/Cargo.toml index af8ead3..2183055 100644 --- a/calculate/Cargo.toml +++ b/calculate/Cargo.toml @@ -4,11 +4,13 @@ version = "0.1.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[profile.release] +debug = true [dependencies] clap = { version = "4.5.2", features = ["derive"] } # This is the latest version that actually uses AES on arm64 -ahash = "0.8.11" +ahash = "=0.8.8" bumpalo-herd = "0.1.2" anyhow = "1.0.80" indicatif = "0.17.8" diff --git a/calculate/src/optimized.rs b/calculate/src/optimized.rs index 1976434..5ee5e58 100644 --- a/calculate/src/optimized.rs +++ b/calculate/src/optimized.rs @@ -24,15 +24,15 @@ struct Data { count: u64, } -const PARALLELISM_FACTOR: usize = 2; +const PARALLELISM_FACTOR: usize = 1; const BUFFER_SIZE: usize = 1 << 30; const UNIQUE_CITY_COUNT: usize = 10_000; pub(crate) fn run(args: Args) -> Result<()> { - let input = File::open(args.input)?; + let input_file = File::open(args.input)?; let mut mmap_options = MmapOptions::new(); mmap_options.populate(); - let input = unsafe { mmap_options.map(&input)? }; + let input = unsafe { mmap_options.map(&input_file)? }; input.advise(Advice::Sequential)?; input.advise(Advice::WillNeed)?; @@ -164,8 +164,9 @@ fn chunk<'input, 'bump>( let sep = Chunk::splat(b';'); let nl = Chunk::splat(b'\n'); let mut pb_since_last_inc: usize = 0; + const PB_INC_THRESHOLD: usize = 100_000_000; 'outer: while input.len() > LANES { - if pb_since_last_inc >= 10_000_000 { + if pb_since_last_inc >= PB_INC_THRESHOLD { pb.inc(pb_since_last_inc as u64); pb_since_last_inc = 0; } @@ -238,7 +239,7 @@ fn chunk<'input, 'bump>( data.count += 1; } loop { - if pb_since_last_inc >= 10_000_000 { + if pb_since_last_inc >= PB_INC_THRESHOLD { pb.inc(pb_since_last_inc as u64); pb_since_last_inc = 0; } diff --git a/flake.nix b/flake.nix index 3c7fafd..0e32beb 100644 --- a/flake.nix +++ b/flake.nix @@ -41,6 +41,7 @@ {package = pkgs.clangStdenv;} {package = pkgs.fenix.default.toolchain; } {package = pkgs.cargo-flamegraph;} + {package = pkgs.samply;} {package = pkgs.nil;} {package = pkgs.rust-analyzer-nightly;} ];