diff rust/hg-core/src/dirstate.rs @ 43826:5ac243a92e37

rust-performance: introduce FastHashMap type alias for HashMap Rust's default hashing is slow, because it is meant for preventing collision attacks. For all of the current Rust code, we don't care about those attacks, because if an person with bad intentions has write access to your repo, you have other issues. I've chosen to use the TwoXHash crate because it was made by a reputable member of the Rust community and has very good benchmarks. For now it does not seem to improve performance by much for the current code, but it's something else to not worry about when benchmarking code: in a previous experiment with copytracing in Rust, it accounted for more than 10% of the time of the entire script. Differential Revision: https://phab.mercurial-scm.org/D7116
author Rapha?l Gom?s <rgomes@octobus.net>
date Mon, 14 Oct 2019 13:57:30 +0200
parents 8210c3f46912
children b51167d70f5a
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate.rs	Mon Dec 02 14:44:26 2019 +0100
+++ b/rust/hg-core/src/dirstate.rs	Mon Oct 14 13:57:30 2019 +0200
@@ -5,9 +5,8 @@
 // This software may be used and distributed according to the terms of the
 // GNU General Public License version 2 or any later version.
 
-use crate::{utils::hg_path::HgPathBuf, DirstateParseError};
+use crate::{utils::hg_path::HgPathBuf, DirstateParseError, FastHashMap};
 use std::collections::hash_map;
-use std::collections::HashMap;
 use std::convert::TryFrom;
 
 pub mod dirs_multiset;
@@ -37,9 +36,9 @@
 /// merge.
 pub const SIZE_FROM_OTHER_PARENT: i32 = -2;
 
-pub type StateMap = HashMap<HgPathBuf, DirstateEntry>;
+pub type StateMap = FastHashMap<HgPathBuf, DirstateEntry>;
 pub type StateMapIter<'a> = hash_map::Iter<'a, HgPathBuf, DirstateEntry>;
-pub type CopyMap = HashMap<HgPathBuf, HgPathBuf>;
+pub type CopyMap = FastHashMap<HgPathBuf, HgPathBuf>;
 pub type CopyMapIter<'a> = hash_map::Iter<'a, HgPathBuf, HgPathBuf>;
 
 #[derive(Copy, Clone, Debug, Eq, PartialEq)]