# `phonebook`: Mapping names to numbers, fast
`phonebook` is a Rust library providing a high-performance, multi-threaded
identifier interning data structure. It is primarily intended for compilers
(i.e. interning identifiers for name resolution), but it may be useful in other
contexts as well.
`phonebook` offers an unusual multi-threaded API, where interning has to
be performed through thread-local data structures. These structures cache
information and amortize the cost of inter-thread synchronization, greatly
improving performance.
The implementation is inspired by [`hashbrown`] and [`papaya`], but has been
heavily specialized; the internal data structures are thoroughly documented and
explain the various design decisions involved.
[`hashbrown`]: https://crates.io/crates/hashbrown
[`papaya`]: https://crates.io/crates/papaya
## Alternatives
[`string-interner`] is a single-threaded interning library, which (currently)
builds on [`hashbrown`]. It is likely faster than `phonebook`, so prefer it if
your use case is single-threaded.
[`symbol-table`] is a popular multi-threaded interning library; it is currently
implemented as a sharded hash table built on [`hashbrown`]. It has a much more
general interface than `phonebook`, and so may be easier to use, at the cost of
performance.
[`string-interner`]: https://crates.io/crates/string-interner
[`symbol_table`]: https://crates.io/crates/symbol_table
## Origins
`phonebook` was developed for [`krabby`], an experimental Rust compiler, due
to its strong performance requirements. It contains a number of interesting
optimizations for concurrent data structures, and its ideas may be applicable to
other data structures.
[`krabby`]: https://sr.ht/~bal-e/krabby
## License
Copyright (C) 2025 arya dradjica (<wkmejd078fo5mrqv@bal-e.org>)
`phonebook` is available under the MIT or Apache-2.0 licenses, at your option.
Their terms are available in `LICENSES/MIT.txt` and `LICENSES/Apache-2.0.txt`
respectively.