aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-01-04 04:00:06 -0800
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-01-04 04:00:06 -0800
commit623f77e0973085bf7a7eea34278679cf751b964b (patch)
tree8bc548b3320db9f0f632b3535562d3ba42af1fab
parent61d6f8f18f4b55ff1cc5ef482ef9c6467879b889 (diff)
downloadbun-623f77e0973085bf7a7eea34278679cf751b964b.tar.gz
bun-623f77e0973085bf7a7eea34278679cf751b964b.tar.zst
bun-623f77e0973085bf7a7eea34278679cf751b964b.zip
minor perf optimization: remove this loop on macOS
-rw-r--r--src/feature_flags.zig2
-rw-r--r--src/watcher.zig10
2 files changed, 8 insertions, 4 deletions
diff --git a/src/feature_flags.zig b/src/feature_flags.zig
index b9bcf3bab..42c1d1782 100644
--- a/src/feature_flags.zig
+++ b/src/feature_flags.zig
@@ -84,3 +84,5 @@ pub const disable_compression_in_http_client = false;
// Time (mean ± σ): 306.7 ms ± 6.1 ms [User: 31.7 ms, System: 269.8 ms]
// Range (min … max): 299.5 ms … 318.8 ms 10 runs
pub const use_libgit2 = true;
+
+pub const atomic_file_watcher = env.isLinux;
diff --git a/src/watcher.zig b/src/watcher.zig
index 33d5aa9a3..35606f697 100644
--- a/src/watcher.zig
+++ b/src/watcher.zig
@@ -532,10 +532,12 @@ pub fn NewWatcher(comptime ContextType: type) type {
comptime copy_file_path: bool,
) !void {
if (this.indexOf(hash)) |index| {
- // On Linux, the file descriptor might be out of date.
- if (fd > 0) {
- var fds = this.watchlist.items(.fd);
- fds[index] = fd;
+ if (comptime FeatureFlags.atomic_file_watcher) {
+ // On Linux, the file descriptor might be out of date.
+ if (fd > 0) {
+ var fds = this.watchlist.items(.fd);
+ fds[index] = fd;
+ }
}
return;
}