perennial: design
perennial is a set of persistent (immutable, structurally shared) collections for Rust —
HashMap, HashSet, OrdMap, OrdSet and Vector — whose public interface is a drop-in
replacement for im-rc 15.1.0 and im 15.1.0, with the additions of imbl 7.0.2.
It is an independent implementation written from a clean-room behavioural specification
(docs/spec/) and the published algorithm literature; see NOTICE.
Chapters
- The interface perennial matches: crates and migration lines, shape decisions, and every place where the references disagree or are defective, with the choice made and why.
- Architecture: crates, the pointer-kind abstraction, copy on
write by ownership, SBIO layering, the
unsafepolicy, the module map. - Where the speed comes from: a black-box probe of the references first, then the mechanism and the predicted gain per collection, and the honest limits.
- Safety and the known bug classes: one negative test per advisory, panic safety by construction, iterative drop, fuzzing.
- Proof plan: differential model tests against imbl, im/im-rc and std; cargo's own test suite with perennial-rc in place of im-rc; compile-level API checks.
- Benchmark method: contenders, workloads, harness and outputs.
Behaviour differences, item by item: COMPAT.md.
Decisions in one place
- Reference versions: im-rc 15.1.0, im 15.1.0, imbl 7.0.2; rpds 1.2.1 and std are measured alongside.
- Two crates:
perennial(Arc, im paths) andperennial-rc(Rc, im-rc paths); both are aliases over generic types parameterised by a pointer kind. #![forbid(unsafe_code)]; no I/O;no_std+allocwith thestdfeature on by default (it suppliesRandomState).- OrdMap/OrdSet: B+tree; HashMap/HashSet: CHAMP-style HAMT; Vector: RRB tree with head/tail buffers and a cached focus. Mutation edits uniquely owned nodes in place.
- Where im 15.1 and imbl 7 disagree, chapter 1's table decides; every such row has a test.