From 4e77979e85ebc3ad92f13396375ac9393d7d4798 Mon Sep 17 00:00:00 2001 From: Ishan Jain Date: Thu, 11 Jan 2024 03:14:45 +0530 Subject: [PATCH] fxhash --- Cargo.lock | 16 ++++++++++++++++ Cargo.toml | 1 + src/main.rs | 4 ++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7e0ab09..2f48fb3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,12 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + [[package]] name = "crossbeam-deque" version = "0.8.5" @@ -33,10 +39,20 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + [[package]] name = "onebrc" version = "0.1.0" dependencies = [ + "fxhash", "rayon", ] diff --git a/Cargo.toml b/Cargo.toml index 3dddfcd..0cd9642 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,4 +6,5 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +fxhash = "0.2.1" rayon = "1.8.0" diff --git a/src/main.rs b/src/main.rs index 19ccac7..f04ee14 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,10 +1,10 @@ -use std::collections::HashMap; +use fxhash::FxHashMap; use std::fs::File; use std::io::Read; use std::time::Instant; fn main() { - let mut map = HashMap::new(); + let mut map = FxHashMap::default(); let mut buf = Vec::new(); let t1 = Instant::now();