# LuaJIT's Quad-Color Garbage Collector Idea

**URL:** <https://forum.golangbridge.org/t/luajits-quad-color-garbage-collector-idea/1384>\
**Category:** Technical Discussion\
**Created:** [October 28, 2015, 3:44pm UTC](https://forum.golangbridge.org/t/luajits-quad-color-garbage-collector-idea/1384 "2015-10-28T15:44:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joshua\_Olson](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/joshua_olson/32/1433_2.png) [@Joshua\_Olson](https://forum.golangbridge.org/u/Joshua_Olson)\
**Post date:** [October 28, 2015, 3:44pm UTC](https://forum.golangbridge.org/t/luajits-quad-color-garbage-collector-idea/1384/1 "2015-10-28T15:44:18Z")

</div>

I’m not well-informed about Go’s future gc plans, but did the LuaJIT guy really [outthink](http://wiki.luajit.org/New-Garbage-Collector#gc-algorithms_quad-color-optimized-incremental-mark-sweep) the experts behind Go?

---

<div class="post-metadata">

**Author:** ![msiegel](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/msiegel/32/190_2.png) [@msiegel](https://forum.golangbridge.org/u/msiegel)\
**Post date:** [October 28, 2015, 4:58pm UTC](https://forum.golangbridge.org/t/luajits-quad-color-garbage-collector-idea/1384/2 "2015-10-28T16:58:39Z")

</div>

To me, that sounds like a loaded question : )

My opinion is that the Go development strategy avoids premature optimization. This often means using simpler, “older”, or seemingly less sophisticated technology… until a need for something else is proven.

And that “something else” tends to be extremely well thought out.

---

<div class="post-metadata">

**Author:** ![andybalholm](https://forum.golangbridge.org/letter_avatar_proxy/v4/letter/a/b487fb/32.png) [@andybalholm](https://forum.golangbridge.org/u/andybalholm)\
**Post date:** [October 28, 2015, 11:26pm UTC](https://forum.golangbridge.org/t/luajits-quad-color-garbage-collector-idea/1384/3 "2015-10-28T23:26:36Z")

</div>

From my reading of the article, the switch from 3-color to 4-color in LuaJIT interacts with their memory layout in a way that improves cache locality. One bit of the “color” is stored inline with the object, and one bit is stored elsewhere. Using four colors makes more use of the inline “gray” bit, and less use of the black/white bit that is stored elsewhere. As near as I can figure out, the “gray” bit is stored in the “object tag”. Go doesn’t have object tags, so this optimization is unlikely to be useful in Go’s garbage collector.

---

<div class="post-metadata">

**Author:** ![Joshua\_Olson](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/joshua_olson/32/1433_2.png) [@Joshua\_Olson](https://forum.golangbridge.org/u/Joshua_Olson)\
**Post date:** [October 29, 2015, 12:21am UTC](https://forum.golangbridge.org/t/luajits-quad-color-garbage-collector-idea/1384/4 "2015-10-29T00:21:13Z")

</div>

Thank you.

---

<div class="post-metadata">

**Author:** ![system](https://forum.golangbridge.org/uploads/default/original/2X/5/5ad234f7c3dbc68b6cc72d338ce4f2973d9fd81c.png) [@system](https://forum.golangbridge.org/u/system)\
**Post date:** [January 27, 2016, 12:21am UTC](https://forum.golangbridge.org/t/luajits-quad-color-garbage-collector-idea/1384/5 "2016-01-27T00:21:25Z")

</div>

Closed on January 27, 2016, 12:21am UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
