Re: [RFC] should physmem be cgroup-aware?

Lasse Collin <[email protected]>
Newsgroups gmane.comp.lib.gnulib.bugs
Message-ID <[email protected]>
On 2026-08-20 Pádraig Brady wrote:
> Re syscall overhead, it's unfortunate, but I don't see a way around
> that at present.

The syscall count in get_cgroup2_cpu_quota could be reduced by 25 % by
avoiding stdio. With glibc, fopen + getline + fclose is four syscalls:
openat + fstat + read + close. Using open + read + close would need only
three.

> I do note that sort(1) uses both nproc() and physmem_total(), which
> suggests a shared or cached interface may be useful, but that can
> come at a later stage.

One could cache the mount point and the cgroup path from
/proc/self/cgroup. It would typically save 4-5 syscalls. I don't know
if it's worth the extra code.

"sort /dev/null" (coreutils 9.11) makes over 40 rt_sigaction syscalls,
so in sort(1) the cgroup related syscalls aren't so large portion of
the total syscall count.

-- 
Lasse Collin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.