Contravariant lifetimes and garbage collection: Inside Nova's Rust-based JavaScript engine
By
aapoalas
Hand-rolled, kettle-boiled, baked to perfection. Worth every minute at the bakery.
Summary
This article from the Nova blog discusses the contrarian approach to garbage collection (GC) in the Nova JavaScript engine, which is written in Rust. The author explains how they model GC using the Rust borrow checker with contravariant lifetimes, a novel approach that goes against typical GC design patterns. The piece covers the philosophical underpinnings of this model, the practical implementation challenges, and the trade-offs involved in building a 100,000+ line Rust JavaScript engine that uses this unconventional GC strategy. The author reflects on both the excellence and awfulness of this approach, particularly how it manages to explain garbage collected handles in a way the borrow checker can understand.
Key quotes
· 3 pulledIt is excellent in that it manages to explain garbage collected handles in such a way that the borrow checker can check them.
Previously on this blog I've written about how Nova JavaScript engine models garbage collection using the Rust borrow checker.
I have, together with a lot of contributors, written a JavaScript engine encompassing more than 100,000 lines of Rust using this model which is equal parts excellent and awful.
You might also wanna read
Implementing a Memory-Efficient Bit-Packed Integer Vector in Rust
This article details the engineering implementation of a memory-efficient, fixed-width bit-packed integer vector in Rust, focusing on optimi
Three Years In: A Senior Engineer's Reflection on AI's Impact on the Software Development Role
A senior engineer reflects on the long-term sustainability of AI tools in software development, three years into deep organizational adoptio
Three Years In: A Senior Engineer's Reflection on AI's Impact on the Software Development Role
A senior engineer reflects on the long-term sustainability of AI tools in software development, three years into deep organizational adoptio
Restartable Sequences: A Linux Kernel Feature for Lock-Free Thread-Safe Programming
This article explores restartable sequences (rseq), a Linux kernel feature introduced in version 4.18 (circa 2018) that enables creation of
Bijou64: A variable-length integer encoding that's both correct and accidentally fast
This article describes the development of bijou64, a variable-length integer (varint) encoding created for the Subduction CRDT sync protocol
Bijou64: A variable-length integer encoding that's both correct and accidentally fast
This article describes the development of bijou64, a variable-length integer (varint) encoding created for the Subduction CRDT sync protocol
