Improve performance of cgroup access (#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)
commit4a6753dcacf44df6a8e91b91029e4b7a4f12d917
tree686419b543dab4a1adf68b53e1319824428584d8
parent8aa0869eb9153429091fdba49469d89ec33092cb
Improve performance of cgroup access (#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.
src/gc/unix/cgroup.cpp
src/gc/unix/cgroup.h [new file with mode: 0644]
src/gc/unix/gcenv.unix.cpp
src/pal/src/include/pal/cgroup.h [new file with mode: 0644]
src/pal/src/init/pal.cpp
src/pal/src/misc/cgroup.cpp