##// END OF EJS Templates
dirstate-tree: optimize HashMap lookups with raw_entry_mut...
Simon Sapin -
r49805:11c0411b default
parent child Browse files
Show More
@@ -9,6 +9,12 b' source = "registry+https://github.com/ru'
9 checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e"
9 checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e"
10
10
11 [[package]]
11 [[package]]
12 name = "ahash"
13 version = "0.4.7"
14 source = "registry+https://github.com/rust-lang/crates.io-index"
15 checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e"
16
17 [[package]]
12 name = "aho-corasick"
18 name = "aho-corasick"
13 version = "0.7.15"
19 version = "0.7.15"
14 source = "registry+https://github.com/rust-lang/crates.io-index"
20 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -372,6 +378,16 b' source = "registry+https://github.com/ru'
372 checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
378 checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
373
379
374 [[package]]
380 [[package]]
381 name = "hashbrown"
382 version = "0.9.1"
383 source = "registry+https://github.com/rust-lang/crates.io-index"
384 checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
385 dependencies = [
386 "ahash",
387 "rayon",
388 ]
389
390 [[package]]
375 name = "hermit-abi"
391 name = "hermit-abi"
376 version = "0.1.17"
392 version = "0.1.17"
377 source = "registry+https://github.com/rust-lang/crates.io-index"
393 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -398,6 +414,7 b' dependencies = ['
398 "derive_more",
414 "derive_more",
399 "flate2",
415 "flate2",
400 "format-bytes",
416 "format-bytes",
417 "hashbrown",
401 "home",
418 "home",
402 "im-rc",
419 "im-rc",
403 "itertools",
420 "itertools",
@@ -13,6 +13,7 b' bitflags = "1.2"'
13 bytes-cast = "0.2"
13 bytes-cast = "0.2"
14 byteorder = "1.3.4"
14 byteorder = "1.3.4"
15 derive_more = "0.99"
15 derive_more = "0.99"
16 hashbrown = {version = "0.9.1", features = ["rayon"]}
16 home = "0.5"
17 home = "0.5"
17 im-rc = "15.0.*"
18 im-rc = "15.0.*"
18 itertools = "0.9"
19 itertools = "0.9"
@@ -22,7 +22,7 b' use crate::DirstateError;'
22 use crate::DirstateParents;
22 use crate::DirstateParents;
23 use crate::DirstateStatus;
23 use crate::DirstateStatus;
24 use crate::EntryState;
24 use crate::EntryState;
25 use crate::FastHashMap;
25 use crate::FastHashbrownMap as FastHashMap;
26 use crate::PatternFileWarning;
26 use crate::PatternFileWarning;
27 use crate::StatusError;
27 use crate::StatusError;
28 use crate::StatusOptions;
28 use crate::StatusOptions;
@@ -585,13 +585,11 b" impl<'on_disk> DirstateMap<'on_disk> {"
585 .next()
585 .next()
586 .expect("expected at least one inclusive ancestor");
586 .expect("expected at least one inclusive ancestor");
587 loop {
587 loop {
588 // TODO: can we avoid allocating an owned key in cases where the
588 let (_, child_node) = child_nodes
589 // map already contains that key, without introducing double
590 // lookup?
591 let child_node = child_nodes
592 .make_mut(on_disk, unreachable_bytes)?
589 .make_mut(on_disk, unreachable_bytes)?
593 .entry(to_cow(ancestor_path))
590 .raw_entry_mut()
594 .or_default();
591 .from_key(ancestor_path.base_name())
592 .or_insert_with(|| (to_cow(ancestor_path), Node::default()));
595 if let Some(next) = inclusive_ancestor_paths.next() {
593 if let Some(next) = inclusive_ancestor_paths.next() {
596 each_ancestor(child_node);
594 each_ancestor(child_node);
597 ancestor_path = next;
595 ancestor_path = next;
@@ -56,6 +56,11 b' pub type LineNumber = usize;'
56 /// write access to your repository, you have other issues.
56 /// write access to your repository, you have other issues.
57 pub type FastHashMap<K, V> = HashMap<K, V, RandomXxHashBuilder64>;
57 pub type FastHashMap<K, V> = HashMap<K, V, RandomXxHashBuilder64>;
58
58
59 // TODO: should this be the default `FastHashMap` for all of hg-core, not just
60 // dirstate_tree? How does XxHash compare with AHash, hashbrown’s default?
61 pub type FastHashbrownMap<K, V> =
62 hashbrown::HashMap<K, V, RandomXxHashBuilder64>;
63
59 #[derive(Debug, PartialEq)]
64 #[derive(Debug, PartialEq)]
60 pub enum DirstateMapError {
65 pub enum DirstateMapError {
61 PathNotFound(HgPathBuf),
66 PathNotFound(HgPathBuf),
General Comments 0
You need to be logged in to leave comments. Login now