Does the time cost of the mark phase in gc is mainly depending on the amount of the living objects and has very little to do with the amount of unused objects?

126 views
Skip to first unread message

rmfr

unread,
Jul 27, 2021, 7:56:25 AM7/27/21
to golang-nuts
Hi, I'm reading the GC implementation of Golang, and some questions have come to me. As the title described:

Proposition 1:
    The time cost of the mark phase in GC is mainly depending on the amount of the living objects.

Proposition 2:
    The time cost of the mark phase in GC has very little to do with the amount of unused objects.

Do both propositions above is true? Thanks a lot.

Ian Lance Taylor

unread,
Jul 27, 2021, 6:23:02 PM7/27/21
to rmfr, golang-nuts
Yes, both statements are generally true.

That said, since Go's garbage collector runs concurrently with the
rest of the program, it's a little hard to know what "the time cost of
the mark phase" is. But it is true that in general during marking the
GC only looks at live objects.

Ian

rmfr

unread,
Jul 28, 2021, 8:59:21 PM7/28/21
to golang-nuts
Thank you very much, Ian. You gave me a deeper understanding of Golang's internal :-D
Reply all
Reply to author
Forward
0 new messages