bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#60474: 30.0.50; `write-region-inhibit-fsync' and copy-on-write file


From: Eli Zaretskii
Subject: bug#60474: 30.0.50; `write-region-inhibit-fsync' and copy-on-write file systems
Date: Sun, 01 Jan 2023 22:07:03 +0200

> Cc: Timothy <orgmode@tec.tecosaur.net>
> From: Ihor Radchenko <yantar92@posteo.net>
> Date: Sun, 01 Jan 2023 18:51:59 +0000
> 
> We are currently exploring performance of frequent file writes in Emacs.
> This is important in org-persist library when we need to cache large
> number of data pieces, writing them on disk.
> 
> It turns out that Emacs is pretty slow when writing hundreds of files:
> 
> (benchmark-run-compiled
>     1000
>   (with-temp-file "/tmp/test"
>     (insert "test"))) ; => 4 sec
> 
> Mostly because of fsync:
> 
> (benchmark-run-compiled
>     1000
>   (let ((write-region-inhibit-fsync t))
>     (with-temp-file "/tmp/test"
>       (insert "test")))) ; => 0.15 sec
> 
> Timothy have found the following comment in src/fileio.c:
> 
>   /* fsync can be a significant performance hit.  Often it doesn't
>      suffice to make the file-save operation survive a crash.  For
>      batch scripts, which are typically part of larger shell commands
>      that don't fsync other files, its effect on performance can be
>      significant so its utility is particularly questionable.
>      Hence, for now by default fsync is used only when interactive.
> 
>      For more on why fsync often fails to work on today's hardware, see:
>      Zheng M et al. Understanding the robustness of SSDs under power fault.
>      11th USENIX Conf. on File and Storage Technologies, 2013 (FAST '13), 
> 271-84
>      https://www.usenix.org/system/files/conference/fast13/fast13-final80.pdf
> 
>      For more on why fsync does not suffice even if it works properly, see:
>      Roche X. Necessary step(s) to synchronize filename operations on disk.
>      Austin Group Defect 672, 2013-03-19
>      https://austingroupbugs.net/view.php?id=672  */
>   write_region_inhibit_fsync = noninteractive;
> 
> Although fsync may provide some benefit on generic file systems, it does
> not look like it is any useful in copy-on-write file systems.
> 
> I am wondering if Emacs could detect file system when writing the file
> and disable fsync for FSes like BTRFS and other CoW file systems.

Paul, any comments?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]