From 1a411e201b71374f515d1f6cdbb1b36186ee48b0 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Mon, 8 May 2023 21:32:17 -0700 Subject: Add some comments --- src/bundler/bundle_v2.zig | 5 +++++ src/fs.zig | 8 ++++++++ 2 files changed, 13 insertions(+) (limited to 'src') diff --git a/src/bundler/bundle_v2.zig b/src/bundler/bundle_v2.zig index 9502f5dfe..aad40b961 100644 --- a/src/bundler/bundle_v2.zig +++ b/src/bundler/bundle_v2.zig @@ -1750,6 +1750,11 @@ pub const BundleV2 = struct { } // TODO: remove ResolveQueue + // + // Moving this to the Bundle thread was a significant perf improvement on Linux for first builds + // + // The problem is that module resolution has many mutexes. + // The downside is cached resolutions are faster to do in threads since they only lock very briefly. fn runResolutionForParseTask(parse_result: *ParseTask.Result, this: *BundleV2) ResolveQueue { var ast = &parse_result.value.success.ast; const source = &parse_result.value.success.source; diff --git a/src/fs.zig b/src/fs.zig index ee2fdff54..f85678136 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -885,6 +885,14 @@ pub const FileSystem = struct { return readDirectoryWithIterator(fs, _dir, _handle, generation, store_fd, void, {}); } + // One of the learnings here + // + // Closing file descriptors yields significant performance benefits on Linux + // + // It was literally a 300% performance improvement to bundling. + // https://twitter.com/jarredsumner/status/1655787337027309568 + // https://twitter.com/jarredsumner/status/1655714084569120770 + // https://twitter.com/jarredsumner/status/1655464485245845506 pub fn readDirectoryWithIterator(fs: *RealFS, _dir: string, _handle: ?std.fs.Dir, generation: bun.Generation, store_fd: bool, comptime Iterator: type, iterator: Iterator) !*EntriesOption { var dir = _dir; var cache_result: ?allocators.Result = null; -- cgit v1.2.3