Mercurial > hg
comparison rust/Cargo.lock @ 48950:11c0411bf4e2
dirstate-tree: optimize HashMap lookups with raw_entry_mut
This switches to using `HashMap` from the hashbrown crate,
in order to use its `raw_entry_mut` method.
The standard library’s `HashMap` is also based on this same crate,
but `raw_entry_mut` is not yet stable there:
https://github.com/rust-lang/rust/issues/56167
Using version 0.9 because 0.10 is yanked and 0.11 requires Rust 1.49
This replaces in `DirstateMap::get_or_insert_node` a call to
`HashMap<K, V>::entry` with `K = WithBasename<Cow<'on_disk, HgPath>>`.
`entry` takes and consumes an "owned" `key: K` parameter, in case a new entry
ends up inserted. This key is converted by `to_cow` from a value that borrows
the `'path` lifetime.
When this function is called by `Dirstate::new_v1`, `'path` is in fact
the same as `'on_disk` so `to_cow` can return an owned key that contains
`Cow::Borrowed`.
For other callers, `to_cow` needs to create a `Cow::Owned` and thus make
a costly heap memory allocation. This is wasteful if this key was already
present in the map. Even when inserting a new node this is typically the case
for its ancestor nodes (assuming most directories have numerous descendants).
Differential Revision: https://phab.mercurial-scm.org/D12317
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Tue, 08 Feb 2022 15:51:52 +0100 |
parents | 7b068abe4aa2 |
children | 8848c3453661 |
comparison
equal
deleted
inserted
replaced
48949:469b9ee336a6 | 48950:11c0411bf4e2 |
---|---|
5 [[package]] | 5 [[package]] |
6 name = "adler" | 6 name = "adler" |
7 version = "0.2.3" | 7 version = "0.2.3" |
8 source = "registry+https://github.com/rust-lang/crates.io-index" | 8 source = "registry+https://github.com/rust-lang/crates.io-index" |
9 checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" | 9 checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" |
10 | |
11 [[package]] | |
12 name = "ahash" | |
13 version = "0.4.7" | |
14 source = "registry+https://github.com/rust-lang/crates.io-index" | |
15 checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e" | |
10 | 16 |
11 [[package]] | 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" |
368 [[package]] | 374 [[package]] |
369 name = "glob" | 375 name = "glob" |
370 version = "0.3.0" | 376 version = "0.3.0" |
371 source = "registry+https://github.com/rust-lang/crates.io-index" | 377 source = "registry+https://github.com/rust-lang/crates.io-index" |
372 checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" | 378 checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" |
379 | |
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 ] | |
373 | 389 |
374 [[package]] | 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" |
396 "clap", | 412 "clap", |
397 "crossbeam-channel 0.4.4", | 413 "crossbeam-channel 0.4.4", |
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", |
404 "lazy_static", | 421 "lazy_static", |
405 "libc", | 422 "libc", |