Re: [PATCH v2 0/7] Add io_dir to avoid memory overhead from opendir
From: David Laight
Date: Sat Feb 08 2025 - 05:58:36 EST
On Fri, 7 Feb 2025 15:24:41 -0800
Ian Rogers <irogers@xxxxxxxxxx> wrote:
> glibc's opendir allocates a minimum of 32kb, when called recursively
> for a directory tree the memory consumption can add up - nearly 300kb
> during perf start-up when processing modules. Add a stack allocated
> variant of readdir sized a little more than 1kb
Does 300kB really matter?
You seem to be trading memory allocation against system calls.
My 'gut feel' is that the system call cost will dominate.
(Unless all the directories are small.)
There might, of course, be other code in glibc that is designed
to make it all slower than necessary.
David