Improve performance of cgroup access (dotnet/coreclr#21229)
authorJan Vorlicek <janvorli@microsoft.com>
Wed, 28 Nov 2018 08:55:35 +0000 (09:55 +0100)
committerGitHub <noreply@github.com>
Wed, 28 Nov 2018 08:55:35 +0000 (09:55 +0100)
commit650a81dce44619963748bc12433f6a5b81297eaa
tree20263be87e63e2692d72acae93cab97bd56ca523
parent5ed818e4301b0bf0a4cbcdffa12e7005dbdaca42
Improve performance of cgroup access (dotnet/coreclr#21229)

Currently, we create a CGroup instance on each request for getting
used or total physical memory. This has an extra cost of finding
filesystem paths of the current cgroup files. I have found that
if we do the initialization just once, the performance of getting
the used or total memory in a tight loop improves 22 times.

Accidentally, I was also looking into a perf regression in the
ByteMark.BenchBitOps test that was observed in the past, seemingly
related to the recent change to the way we get the used memory.
And I've found that the benchmark results improve two fold with
the change in this commit.

This change was made both in PAL and in the standalone GC.

Commit migrated from https://github.com/dotnet/coreclr/commit/4a6753dcacf44df6a8e91b91029e4b7a4f12d917
src/coreclr/src/gc/unix/cgroup.cpp
src/coreclr/src/gc/unix/cgroup.h [new file with mode: 0644]
src/coreclr/src/gc/unix/gcenv.unix.cpp
src/coreclr/src/pal/src/include/pal/cgroup.h [new file with mode: 0644]
src/coreclr/src/pal/src/init/pal.cpp
src/coreclr/src/pal/src/misc/cgroup.cpp