While doing some profiling I noticed reading /proc/[pid]/maps takes the top spot. This file is read by default due to the enabled by default check for deleted shared libraries (#595).
I tried to optimize the stream handling
diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c
index 487a4df..517c9f6 100644
--- a/linux/LinuxProcessList.c
+++ b/linux/LinuxProcessList.c
@@ -582,8 +582,11 @@ static void LinuxProcessList_readMaps(LinuxProcess* process, openat_arg_t procFd
if (calcSize)
ht = Hashtable_new(64, true);
+ char internalBuf[8192];
+ setvbuf(mapsfile, internalBuf, _IOFBF, sizeof(internalBuf));
+
char buffer[1024];
- while (fgets(buffer, sizeof(buffer), mapsfile)) {
+ while (fgets_unlocked(buffer, sizeof(buffer), mapsfile)) {
uint64_t map_start;
uint64_t map_end;
bool map_execute;
but it seems only calling the function less reduces the utilization.
I had the idea to only parse /proc/[pid]/maps if the value shared in /proc/[pid]/statm changes, but replacing a shared library on disk won't modify that.
While doing some profiling I noticed reading
/proc/[pid]/mapstakes the top spot. This file is read by default due to the enabled by default check for deleted shared libraries (#595).I tried to optimize the stream handling
but it seems only calling the function less reduces the utilization.
I had the idea to only parse
/proc/[pid]/mapsif the valuesharedin/proc/[pid]/statmchanges, but replacing a shared library on disk won't modify that.