Try changing alignment (#76451)
authorPeter Sollich <petersol@microsoft.com>
Fri, 14 Oct 2022 12:35:00 +0000 (14:35 +0200)
committerGitHub <noreply@github.com>
Fri, 14 Oct 2022 12:35:00 +0000 (14:35 +0200)
commitd47767ad2c56ae0d947af211c2e7f88020727e4e
tree6030a7599b6c34868e0b98ebc10db468f5925f52
parent65d20644b7852307fe076225a4f78395287bdb93
Try changing alignment (#76451)

Looking at CPU traces for microbenchmarks, I noticed a hotspot in memset (the flavor that uses AVX2 instructions) for the instruction that clears the very last double quadword at the end of an allocation context. Also, the buffer being cleared is not aligned on a 32-byte boundary.

Two tiny changes address this:

1. adding additional padding at the start of regions align the allocation context for the microbenchmark cases.
2. increasing CLR_SIZE slightly ensure the end of an allocation context doesn't consistently fall on a page boundary.

Change 1 makes sure we start with an aligned allocation context at the start of a region.
Change 2 minimizes the number of movdqu instructions executed and makes sure we don't concistently hit a new page at the end of the memset range.
src/coreclr/gc/gc.cpp
src/coreclr/gc/gcpriv.h