Skip to content

Commit 8f53d6d

Browse files
committed
perf(server): checkpoints flush new files to disk once per command instead of once per file
Checkpoint writes pass core.fsyncMethod=fsync, so `git add` does a full flush for every new object. Capturing a checkpoint with 1,500 new files took about 8 s on Linux (ext4 on NVMe), and `git add` of 500 new files took 2.6 s on an APFS Mac. Batch mode writes the objects out, issues one full flush, and only then moves them into place, so they are just as durable once they are visible. Refs still get a full flush each.
1 parent d8e9fd2 commit 8f53d6d

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

‎apps/server/src/vcs/GitVcsDriver.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,7 @@ it.effect("GitVcsDriver flushes checkpoint objects and refs to disk before publi
11671167
assert.strictEqual(writes.length, 4);
11681168
for (const args of writes) {
11691169
const command = args.findIndex((arg) => writeCommands.includes(arg));
1170-
for (const setting of ["core.fsync=objects,reference", "core.fsyncMethod=fsync"]) {
1170+
for (const setting of ["core.fsync=objects,reference", "core.fsyncMethod=batch"]) {
11711171
const index = args.indexOf(setting);
11721172
assert.strictEqual(args[index - 1], "-c", args.join(" "));
11731173
assert.isBelow(index, command);
@@ -1179,7 +1179,7 @@ it.effect("GitVcsDriver flushes checkpoint objects and refs to disk before publi
11791179
"-c",
11801180
"core.fsync=objects,reference",
11811181
"-c",
1182-
"core.fsyncMethod=fsync",
1182+
"core.fsyncMethod=batch",
11831183
"update-ref",
11841184
"refs/t3/checkpoints/thread/turn/1",
11851185
"commit0000",

‎apps/server/src/vcs/GitVcsDriver.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,11 +784,14 @@ export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* (
784784
// an unclean restart can leave 0-byte files under refs/t3/** that break every
785785
// later fetch and push. Checkpoint writes flush before they are published;
786786
// macOS defaults to writeout-only, which does not reach the disk either.
787+
// Batch mode writes out the new objects of one command and flushes the disk
788+
// once before it publishes them, instead of once per object: a turn can add
789+
// thousands of files. Refs still get a full flush each.
787790
const durableWrite = [
788791
"-c",
789792
"core.fsync=objects,reference",
790793
"-c",
791-
"core.fsyncMethod=fsync",
794+
"core.fsyncMethod=batch",
792795
] as const;
793796

794797
const checkpoints: VcsDriver.VcsCheckpointOps = {

0 commit comments

Comments
 (0)