You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the journey of continuing to reduce allocations in manager.Stat,
this sets its eyes on optimizing readHugeTlbStats. The number of allocs
shaved off here is tied to the number of files in the cgroup directory
as f.Readdir(-1) was being called which returns a slice of interfaces.
To optimize this we can use a trick runc's cgroup code does which is to
take advantage of the fact that we know exactly what files we need to
open as they're fixed, the only variable portion is the hugepage sizes
available on the host. To get around this we can compute the hugepage
sizes in a sync.Once, and all future manager.Stat calls can reap the
benefits as we don't need to Readdir() the entire cgroup path to search
for hugetlb.pagesize.foobar's.
This brings the total number of allocations on Go 1.19.4 down to 199 from
the starting point of 322.
Signed-off-by: Danny Canter <danny@dcantah.dev>
Co-authored-by: Kir Kolyshkin <kolyshkin@gmail.com>
// Model after https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/mm/hugetlb_cgroup.c?id=eff48ddeab782e35e58ccc8853f7386bbae9dec4#n574
0 commit comments