I'm doing some performance analysis of go1.20 on arm64 platform, and I found that the DMB instruction in mallocgc consumes a lot of time.
I found some CLs:
- CL11083: In
go1.5, publicationBarrier was added when allocating scan objects.
- CL23043: In
go1.7, publicationBarrier is was added when allocating noscan objects because of the heapBitsSetTypeNoScan.
- CL41253: However,
publicationBarrier is still called when allocating noscan objects after heapBitsSetTypeNoScan is deleted.
I tried to find the reason why publicationBarrier was called when allocating noscan objects, but I couldn't find it.
Knowing from the comments of source code, publicationBarrier in mallocgc ensure that the stores above that initialize x to type-safe memory and set the heap bits occur before the caller can make x observable to the GC. publicationBarrier in allocSpan make sure the newly allocated span will be observed by the GC before pointers into the span are published.
My question is, GC don't scan noscan object, why is publicationBarrier required when allocating noscan objects in mallocgc?
Thank you in advance for your help.
I'm doing some performance analysis of
go1.20onarm64platform, and I found that the DMB instruction in mallocgc consumes a lot of time.I found some CLs:
go1.5,publicationBarrierwas added when allocating scan objects.go1.7,publicationBarrieris was added when allocating noscan objects because of theheapBitsSetTypeNoScan.publicationBarrieris still called when allocating noscan objects afterheapBitsSetTypeNoScanis deleted.I tried to find the reason why
publicationBarrierwas called when allocating noscan objects, but I couldn't find it.Knowing from the comments of source code,
publicationBarrierinmallocgcensure that the stores above that initialize x to type-safe memory and set the heap bits occur before the caller can make x observable to the GC.publicationBarrierinallocSpanmake sure the newly allocated span will be observed by the GC before pointers into the span are published.My question is, GC don't scan noscan object, why is
publicationBarrierrequired when allocating noscan objects inmallocgc?Thank you in advance for your help.