LANGUAGES Signal 481
Speeding Up the Plush Garbage Collector
A toy language’s copying garbage collector reduced collection time from 117 ms to 43 ms for one million objects by switching hash maps and removing redundant lookups
Engineers building high-throughput actor runtimes or message-passing systems may face similar hidden overheads from default hash maps. The trade-off between safety and performance in language runtimes is concrete and measurable here
Written by elseif from the cluster below · every claim links back to a sourceThe three things worth knowing
Default Rust HashMap uses a secure hashing function that slows down pointer-heavy workloads
Replacing it with FxHashMap and removing one redundant lookup cut GC time by more than half
Remaining overhead is still dominated by the hash table’s memory footprint and poor cache locality
THE READ
What the cluster adds up to.
The event is a micro-optimisation inside the Plush language runtime. A copying garbage collector that was originally written to avoid global VM pauses was found to be several times slower than the author’s target. The collector uses a hash map to track forwarding pointers instead of mutating object headers, which decouples message copying from GC but adds indirection.
Two changes were made: replacing the default Rust HashMap with FxHashMap from the rustc_hash crate, and removing a redundant hash table lookup. These changes reduced the collection time for one million objects from 117 ms to 43 ms on an M5 MacBook Air. The remaining gap to the 20 ms target is still significant, and profiling shows the hash table itself is now the main bottleneck.
The hash table’s memory footprint is larger than the live data being copied. Each entry is a pair of pointers, and the map needs extra capacity to avoid collisions. The quasi-random distribution of hash outputs also hurts cache locality, causing more memory traffic than the data itself. This suggests that further gains will require a different data structure or algorithm.
The optimisation is specific to the Plush runtime’s design. Each actor has its own allocator and message buffer, and messages are copied into the receiver’s buffer to avoid synchronisation. The hash map was chosen to avoid mutating sender objects, but the performance cost was not obvious until profiling. Engineers working on similar actor-based or message-passing systems may encounter the same issue.
Written by elseif from the cluster below · checked for specifics the sources never containedTHE CLUSTER
↗