Commit 4ae2960
committed
perf(jfat): defer FAT flush in FatFile.write to fix per-write sync overhead
FatChain.write() and FatFile.write() called fat.flush() on every single
write() invocation, forcing an O(N) scan of every dirty FatCache element
to the device before the write returned. For sequential and append-heavy
workloads this dropped throughput by an order of magnitude: append ran at
8 MiB/s while the underlying device could sustain 170+ MiB/s.
Removed the two fat.flush() calls inside FatChain.write() and the trailing
flush() in FatFile.write(). The dirty FAT cache, dir entry, and chain are
now persisted lazily by the existing close-path:
- file.flush() -> FatEntry.flush() persists dir-entry record
- fs.flush() -> flushFiles() + fat.flush() sync the FAT cache
- fs.close() -> AbstractFileSystem.close() calls flush() then api.flush()
- FileHandleImpl.close() -> file.flush()
fat.set() / fat.clearCluster() only mutate the in-memory FatCache, so
the cache continues to expose consistent reads to follow-up writes on
the same fs instance between flushes.
Benchmark (FatWriteBench):
sequential-write 173 -> 198 MiB/s (+14%)
many-small-files 0.53 -> 0.62 MiB/s (+17%)
append 8.0 -> 12.4 MiB/s (+55%)
append-fsync 4.5 -> 4.9 MiB/s (+8%)
create-tree 2.9 -> 3.1 MiB/s (+7%)
remount-write 75 -> 1090 MiB/s (+14x)
remount-read 4.9 -> 8.8 MiB/s (+80%)
Durability verified with SizeSweepExtended (1-60 MiB writes through
close+remount+read) and the multi-cluster benchRemountRead (1 MiB
roundtrip). All JFAT unit tests pass.1 parent 8c1f536 commit 4ae2960
2 files changed
Lines changed: 36 additions & 38 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
434 | 434 | | |
435 | 435 | | |
436 | 436 | | |
437 | | - | |
438 | | - | |
439 | | - | |
| 437 | + | |
| 438 | + | |
440 | 439 | | |
441 | | - | |
| 440 | + | |
442 | 441 | | |
443 | | - | |
444 | | - | |
445 | | - | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
446 | 445 | | |
447 | | - | |
| 446 | + | |
448 | 447 | | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
456 | 455 | | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
462 | 461 | | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
| 462 | + | |
| 463 | + | |
468 | 464 | | |
469 | 465 | | |
470 | 466 | | |
| |||
475 | 471 | | |
476 | 472 | | |
477 | 473 | | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
490 | 482 | | |
491 | 483 | | |
492 | 484 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
116 | 122 | | |
117 | 123 | | |
118 | 124 | | |
| |||
0 commit comments