String interning for attribute names and identifiers.
Converts heap-allocated String comparisons into cheap u32
comparisons. Every unique string is stored exactly once; lookups
and comparisons use the [Symbol] handle (a u32 index).
Performance Impact
Attrset key operations (GetAttr, HasAttr, MakeAttrs, UpdateAttrs)
go from O(n) string comparison to O(1) integer comparison. This is
the single highest-ROI optimization for Nix evaluation because
nixpkgs is dominated by attrset operations.
Storage
Strings are stored as Rc<str>. The forward map's key and the reverse
strings vector share the same allocation — no double-allocation on
intern, and resolve_rc returns a cheap Rc::clone instead of a
full String::from copy. Hashing uses FxHashMap (rustc-hash) —
~2x faster than SipHash for the short strings typical of Nix keys
and identifiers.
Thread-Local Helpers
For convenience in single-threaded evaluation, this crate provides
[intern()] and [resolve()] free functions that operate on a
thread-local [Interner] instance. [prewarm()] pre-interns a
curated set of hot nixpkgs symbols so common names get low indices
and the hashmap's initial resize cost is paid upfront.