Commit 7eb699e
file: implement relaxed sync for macos
On macOS, fsync() flushes the filesystem cache to the drive, but doesn't
request the drive to flush it's internal cache to its persistent
storage. To do the latter, there's a specific fcntl: F_FULLFSYNC.
The reason why they decided to have fsync() behave this way it's because
in Apple Silicon hardware flushing the drive cache has a very
significant performance impact.
In File::sync() we were calling std::fs::File::sync_all(), which does
use F_FULLSYNC, which is safer but comes with a high cost.
Let's allow crate users on macOS opt for a more relaxed synchronization
using fsync() instead of std::fs::File::sync_all(). Expose the option
in StorageOpenOptions as relaxed_sync but gate it behind a build-time
conditional for target_os = macos.
Signed-off-by: Sergio Lopez <slp@redhat.com>
(cherry picked from commit 16db536)
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>1 parent 6acc672 commit 7eb699e
2 files changed
+54
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
57 | 61 | | |
58 | 62 | | |
59 | 63 | | |
| |||
66 | 70 | | |
67 | 71 | | |
68 | 72 | | |
69 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
70 | 80 | | |
71 | 81 | | |
72 | 82 | | |
| |||
333 | 343 | | |
334 | 344 | | |
335 | 345 | | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
336 | 352 | | |
337 | 353 | | |
338 | 354 | | |
| |||
346 | 362 | | |
347 | 363 | | |
348 | 364 | | |
349 | | - | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
350 | 371 | | |
351 | 372 | | |
352 | 373 | | |
| |||
385 | 406 | | |
386 | 407 | | |
387 | 408 | | |
| 409 | + | |
| 410 | + | |
388 | 411 | | |
389 | 412 | | |
390 | 413 | | |
| |||
663 | 686 | | |
664 | 687 | | |
665 | 688 | | |
666 | | - | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
667 | 696 | | |
668 | 697 | | |
669 | 698 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
30 | 34 | | |
31 | 35 | | |
32 | 36 | | |
| |||
533 | 537 | | |
534 | 538 | | |
535 | 539 | | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
536 | 552 | | |
537 | 553 | | |
538 | 554 | | |
| |||
547 | 563 | | |
548 | 564 | | |
549 | 565 | | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
550 | 572 | | |
0 commit comments