Go's New Green Tea Garbage Collector May Improve Performance up to 40%
Briefly

Go's New Green Tea Garbage Collector May Improve Performance up to 40%
"Go 1.25 introduces a new experimental garbage collector that delivers up to 40% faster than the current implementation, bringing a significant performance improvement for GC-heavy workloads. The new garbage collector, called Green Tea, uses the same mark-sweep approach as the existing GC, but with a key difference: instead of operating on individual objects, it works at the memory page level. This means Green Tea scans and tracks entire pages globally, whilt tracking individual objects locally within each page rather than across the heap."
"This all adds up to a better fit with the microarchitecture. We can now scan objects closer together with much higher probability, so there's a better chance we can make use of our caches and avoid main memory. Likewise, per-page metadata is more likely to be in cache. Tracking pages instead of objects means work lists are smaller, and less pressure on work lists means less contention and fewer CPU stalls."
"This approach greatly reduces the number of scans required to mark the whole heap, which is significant since "about 90% of the cost of the garbage collector is spent marking, and only about 10% is sweeping", according to Go contributors Michael Knyszek and Austin Clements. Knyszek and Clements also explain that Green Tea was developed in response to the challenges posed by modern CPU hardware, which risk to make code slower rather than faster as hardware evolves."
Go 1.25 introduces Green Tea, an experimental garbage collector that implements mark-sweep at the memory page level instead of per-object, scanning and tracking whole pages globally while tracking objects locally. Page-level operation improves cache locality by scanning objects that are physically closer and keeping per-page metadata and work lists smaller, reducing contention and CPU stalls. The approach significantly lowers the number of scans required to mark the heap, addressing the fact that roughly 90% of GC cost is marking. Green Tea targets modern CPU characteristics—non-uniform memory access, reduced per-core memory bandwidth, and increasing core counts—while enabling better use of vector instructions and wide registers for speedups.
Read at InfoQ
Unable to calculate read time
[
|
]