aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorRyan Liptak <squeek502@hotmail.com>2022-10-05 16:05:02 -0700
committerRyan Liptak <squeek502@hotmail.com>2022-10-05 16:05:02 -0700
commit39f192d54eba99ba3dfc7066476912633e694d51 (patch)
treeca8f102cbcac4bd7c9a21207f0eae8db3135e9bb /lib/std
parent274d19575ea1ebaea593cdca7c5afa8303153cb4 (diff)
downloadzig-39f192d54eba99ba3dfc7066476912633e694d51.tar.gz
zig-39f192d54eba99ba3dfc7066476912633e694d51.zip
fs: Reduce IterableDir.Iterator `buf` size to 1024
This was sized large so that `getdents` (and other platforms' equivalents) could provide large amounts of entries per syscall, but some benchmarking seems to indicate that the larger 8192 sizing doesn't actually lead to performance gains outside of edge cases like extremely large amounts of entries within a single directory (e.g. 25,000 files in one directory), and even then the gains are minimal ('./walk-8192 dir-with-tons-of-entries' ran 1.02 ± 0.34 times faster than './walk-1024 dir-with-tons-of-entries'). Note: Sizes 1024 and 2048 had similar performance characteristics, so the smaller of the two was chosen.
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/fs.zig10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/std/fs.zig b/lib/std/fs.zig
index 416f3ce313..c75cf88b84 100644
--- a/lib/std/fs.zig
+++ b/lib/std/fs.zig
@@ -301,7 +301,7 @@ pub const IterableDir = struct {
.macos, .ios, .freebsd, .netbsd, .dragonfly, .openbsd, .solaris => struct {
dir: Dir,
seek: i64,
- buf: [8192]u8, // TODO align(@alignOf(os.system.dirent)),
+ buf: [1024]u8, // TODO align(@alignOf(os.system.dirent)),
index: usize,
end_index: usize,
first_iter: bool,
@@ -499,7 +499,7 @@ pub const IterableDir = struct {
},
.haiku => struct {
dir: Dir,
- buf: [8192]u8, // TODO align(@alignOf(os.dirent64)),
+ buf: [1024]u8, // TODO align(@alignOf(os.dirent64)),
index: usize,
end_index: usize,
first_iter: bool,
@@ -594,7 +594,7 @@ pub const IterableDir = struct {
dir: Dir,
// The if guard is solely there to prevent compile errors from missing `linux.dirent64`
// definition when compiling for other OSes. It doesn't do anything when compiling for Linux.
- buf: [8192]u8 align(if (builtin.os.tag != .linux) 1 else @alignOf(linux.dirent64)),
+ buf: [1024]u8 align(if (builtin.os.tag != .linux) 1 else @alignOf(linux.dirent64)),
index: usize,
end_index: usize,
first_iter: bool,
@@ -676,7 +676,7 @@ pub const IterableDir = struct {
},
.windows => struct {
dir: Dir,
- buf: [8192]u8 align(@alignOf(os.windows.FILE_BOTH_DIR_INFORMATION)),
+ buf: [1024]u8 align(@alignOf(os.windows.FILE_BOTH_DIR_INFORMATION)),
index: usize,
end_index: usize,
first_iter: bool,
@@ -754,7 +754,7 @@ pub const IterableDir = struct {
},
.wasi => struct {
dir: Dir,
- buf: [8192]u8, // TODO align(@alignOf(os.wasi.dirent_t)),
+ buf: [1024]u8, // TODO align(@alignOf(os.wasi.dirent_t)),
cookie: u64,
index: usize,
end_index: usize,