-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cgroup2: Reduce allocations in readHugeTlbStats
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>
- Loading branch information
Showing
1 changed file
with
84 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters