Skip to content

Commit 880d565

Browse files
committed
fix(rustdoc-json-types): document rustc-hash feature
The `rustc-hash` feature is publicly exposed by the `rustdoc-types`. It is already documented in that crate's README and Cargo.toml, but we might as well add some information to the crate docs themselves c: Follow up to: - rust-lang#131936 - [rust-lang/rustdoc-types#42][1] [1]: rust-lang/rustdoc-types#42
1 parent bfab34a commit 880d565

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/rustdoc-json-types/lib.rs

+12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22
//!
33
//! These types are the public API exposed through the `--output-format json` flag. The [`Crate`]
44
//! struct is the root of the JSON blob and all other items are contained within.
5+
//!
6+
//! We expose a `rustc-hash` feature that is disabled by default. This feature switches the
7+
//! [`std::collections::HashMap`] for [`rustc_hash::FxHashMap`] to improve the performance of said
8+
//! `HashMap` in specific situations.
9+
//!
10+
//! `cargo-semver-checks` for example, saw a [-3% improvement][1] when benchmarking using the
11+
//! `aws_sdk_ec2` JSON output (~500MB of JSON). As always, we recommend measuring the impact before
12+
//! turning this feature on, as [`FxHashMap`][2] only concerns itself with hash speed, and may
13+
//! increase the number of collisions.
14+
//!
15+
//! [1]: https://rust-lang.zulipchat.com/#narrow/channel/266220-t-rustdoc/topic/rustc-hash.20and.20performance.20of.20rustdoc-types/near/474855731
16+
//! [2]: https://crates.io/crates/rustc-hash
517
618
#[cfg(not(feature = "rustc-hash"))]
719
use std::collections::HashMap;

0 commit comments

Comments
 (0)