File tree 3 files changed +23
-3
lines changed
3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,16 @@ repository = "https://github.com/rust-lang/rustdoc-types"
9
9
10
10
[dependencies ]
11
11
serde = {version =" 1" , features =[" derive" ]}
12
+ rustc-hash = {version =" 2" , optional =true }
13
+
14
+ [features ]
15
+ default = []
16
+
17
+ # Switch the hashmaps used in rustdoc-types to the FxHashMap from rustc-hash.
18
+ #
19
+ # This might improve performace if your are reading the rustdoc JSON from large
20
+ # crates like aws_sdk_ec2
21
+ rustc-hash = [" dep:rustc-hash" ]
12
22
13
23
[dev-dependencies ]
14
24
bincode = " 1.3.3"
Original file line number Diff line number Diff line change @@ -13,6 +13,18 @@ let krate: rustdoc_types::Crate = serde_json::from_str(&json_string)?;
13
13
println! (" the index has {} items" , krate . index. len ());
14
14
```
15
15
16
+ For performance sensitive crates we suggest turning on the ` rustc-hash `
17
+ feature. This switches all data structures from ` std::collections::HashMap ` to
18
+ ` rustc-hash::FxHashMap ` which improves performance when reading big JSON files
19
+ (like ` aws_sdk_rs ` 's).
20
+
21
+ ` cargo-semver-checks ` benchmarked this change with ` aws_sdk_ec2 ` 's JSON and
22
+ [ observed a -3% improvement to the runtime] [ csc benchmarks ] . The performance
23
+ here depends on how much time you spend querying the ` HashMap ` s, so as always,
24
+ measure first c:
25
+
26
+ [ csc benchmarks ] : https://rust-lang.zulipchat.com/#narrow/channel/266220-t-rustdoc/topic/rustc-hash.20and.20performance.20of.20rustdoc-types/near/474855731
27
+
16
28
## Contributing
17
29
18
30
This repo is a reexport of
Original file line number Diff line number Diff line change @@ -9,9 +9,7 @@ repo="rust"
9
9
branch=" master"
10
10
11
11
curl -# https://raw.githubusercontent.com/${user} /${repo} /${branch} /src/rustdoc-json-types/lib.rs \
12
- | sed ' s/rustc_hash::/std::collections::/g' \
13
- | sed ' s/FxHashMap/HashMap/g' \
14
- | sed ' s/^pub use /use /' \
12
+ | sed ' /^pub type FxHashMap.*$/d' \
15
13
> src/lib.rs
16
14
17
15
curl -# https://raw.githubusercontent.com/${user} /${repo} /${branch} /src/rustdoc-json-types/tests.rs > src/tests.rs
You can’t perform that action at this time.
0 commit comments