mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-23 08:00:20 +00:00
SpaceAnalyzer: Use fstatat instead of lstat
By using fstatat during file system analyzation instead of lstat, we reduce the amount of work the kernel has to do for each stat call. During profiling it came up that the kernel was spending a lot of time resolving paths. Because each call to stat passed an absolute path the kernel had to do the same work over and over again. When using relative paths the kernel only has to resolve the relative part as it can reuse the already resolved path of the base directory.
This commit is contained in:
parent
758085571f
commit
f70d0f03de
Notes:
sideshowbarker
2024-07-18 18:08:18 +09:00
Author: https://github.com/Maato Commit: https://github.com/SerenityOS/serenity/commit/f70d0f03de9 Pull-request: https://github.com/SerenityOS/serenity/pull/7109
1 changed files with 2 additions and 1 deletions
|
@ -22,6 +22,7 @@
|
|||
#include <LibGUI/Menubar.h>
|
||||
#include <LibGUI/MessageBox.h>
|
||||
#include <LibGUI/Statusbar.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -170,7 +171,7 @@ static void populate_filesize_tree(TreeNode& root, Vector<MountInfo>& mounts, Ha
|
|||
int name_len = name.length();
|
||||
builder.append(name);
|
||||
struct stat st;
|
||||
int stat_result = lstat(builder.to_string().characters(), &st);
|
||||
int stat_result = fstatat(dir_iterator.fd(), name.characters(), &st, AT_SYMLINK_NOFOLLOW);
|
||||
if (stat_result < 0) {
|
||||
int error_sum = error_accumulator.get(errno).value_or(0);
|
||||
error_accumulator.set(errno, error_sum + 1);
|
||||
|
|
Loading…
Reference in a new issue