]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fs-util: increase start buffer size in readlinkat_malloc()
authorLennart Poettering <lennart@poettering.net>
Thu, 25 Oct 2018 19:16:47 +0000 (21:16 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 25 Oct 2018 19:37:14 +0000 (21:37 +0200)
I noticed while profiling journald that we invoke readlinkat() a ton on
open /proc/self/fd/<fd>, and that the returned paths are more often than
not longer than the 99 chars used before, when we look at archived
journal files. This means for these cases we generally need to execute
two rather than one syscalls.

Let's increase the buffer size a tiny bit, so that we reduce the number
of syscalls executed. This is really a low-hanging fruit of
optimization.

src/basic/fs-util.c

index fd1951827128c4885dfb4f5132fef53c280437c0..55651baa80c2283c01173c9c39286ff88e1ec5bf 100644 (file)
@@ -132,7 +132,7 @@ int rename_noreplace(int olddirfd, const char *oldpath, int newdirfd, const char
 }
 
 int readlinkat_malloc(int fd, const char *p, char **ret) {
-        size_t l = 100;
+        size_t l = FILENAME_MAX+1;
         int r;
 
         assert(p);