branch: externals/org commit e9c0696f795628e86d8c526f8a7656b674b1b3ee Author: TEC <g...@tecosaur.net> Commit: Ihor Radchenko <yanta...@posteo.net>
org-persist: Inhibit fsync when writing cachefiles * lisp/org-persist.el (org-persist--write-elisp-file): For the reasons mentioned in the large code comment, it simply does not make much sense to use fsync when writing cache files. The value of fsync in general on modern hardware seems questionable, particularly with CoW filesystems which take care of the problem better than it seems fsync ever could. --- lisp/org-persist.el | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lisp/org-persist.el b/lisp/org-persist.el index da74257de8..6fbc8d87b0 100644 --- a/lisp/org-persist.el +++ b/lisp/org-persist.el @@ -420,7 +420,19 @@ FORMAT and ARGS are passed to `message'." (defun org-persist--write-elisp-file (file data &optional no-circular pp) "Write elisp DATA to FILE." - (let ((print-circle (not no-circular)) + ;; Fsync slightly reduces the chance of an incomplete filesystem + ;; write, however on modern hardware its effectiveness is + ;; questionable and it is insufficient to garantee complete writes. + ;; Coupled with the significant performance hit if writing many + ;; small files, it simply does not make sense to use fsync here, + ;; particularly as cache corruption is only a minor inconvenience. + ;; With all this in mind, we ensure `write-region-inhibit-fsync' is + ;; set. + ;; + ;; To read more about this, see the comments in Emacs' fileio.c, in + ;; particular the large comment block in init_fileio. + (let ((write-region-inhibit-fsync t) + (print-circle (not no-circular)) print-level print-length print-quoted