Skip to content

Commit 627a292

Browse files
committed
fetch: remove calls to fsync
fsync blocks until the contents have been actually written to disk, which would be useful if we didn't want to report success until having achieved durability. But the OS will ensure coherency; i.e. if one process writes stuff without calling fsync, then another process reads that stuff, the writes will be seen even if they didn't get flushed to disk yet. Since this code deals with ephemeral cache data, it's not worth trying to achieve this kind of durability guarantee. This is consistent with all the other tooling on the system. Certainly, if we wanted to change our stance on this, it would not be something that affects only the git fetching logic.
1 parent 1a15fbe commit 627a292

File tree

2 files changed

+0
-4
lines changed

2 files changed

+0
-4
lines changed

src/Package/Fetch.zig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,7 +1386,6 @@ fn unpackGitPack(f: *Fetch, out_dir: fs.Dir, resource: *Resource.Git) anyerror!U
13861386
defer pack_file.close();
13871387
var fifo = std.fifo.LinearFifo(u8, .{ .Static = 4096 }).init();
13881388
try fifo.pump(resource.fetch_stream.reader(), pack_file.deprecatedWriter());
1389-
try pack_file.sync();
13901389

13911390
var index_file = try pack_dir.createFile("pkg.idx", .{ .read = true });
13921391
defer index_file.close();
@@ -1396,7 +1395,6 @@ fn unpackGitPack(f: *Fetch, out_dir: fs.Dir, resource: *Resource.Git) anyerror!U
13961395
var index_buffered_writer = std.io.bufferedWriter(index_file.deprecatedWriter());
13971396
try git.indexPack(gpa, object_format, pack_file, index_buffered_writer.writer());
13981397
try index_buffered_writer.flush();
1399-
try index_file.sync();
14001398
}
14011399

14021400
{

src/Package/Fetch/git.zig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ pub const Repository = struct {
238238
};
239239
defer file.close();
240240
try file.writeAll(file_object.data);
241-
try file.sync();
242241
},
243242
.symlink => {
244243
try repository.odb.seekOid(entry.oid);
@@ -1690,7 +1689,6 @@ pub fn main() !void {
16901689
var index_buffered_writer = std.io.bufferedWriter(index_file.deprecatedWriter());
16911690
try indexPack(allocator, format, pack_file, index_buffered_writer.writer());
16921691
try index_buffered_writer.flush();
1693-
try index_file.sync();
16941692

16951693
std.debug.print("Starting checkout...\n", .{});
16961694
var repository = try Repository.init(allocator, format, pack_file, index_file);

0 commit comments

Comments
 (0)