[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#14273: `write-region-inhibit-fsync' should default to t
From: |
Paul Eggert |
Subject: |
bug#14273: `write-region-inhibit-fsync' should default to t |
Date: |
Thu, 25 Apr 2013 23:41:13 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 |
Tags: patch
These days it's better to default write-region-inhibit-fsync to t.
Here's a proposed patch, which I hope is self-explanatory.
This change speeds up "make compile-always" by 15% on my platform.
=== modified file 'doc/emacs/ChangeLog'
--- doc/emacs/ChangeLog 2013-04-04 03:46:25 +0000
+++ doc/emacs/ChangeLog 2013-04-26 06:35:33 +0000
@@ -1,3 +1,20 @@
+2013-04-26 Paul Eggert <eggert@cs.ucla.edu>
+
+ `write-region-inhibit-fsync' now defaults to t.
+ * files.texi (Customize Save): Document this.
+ fsync can be a major performance hit. Often it doesn't suffice to
+ make the file-save operation survive a crash anyway, so its
+ utility is questionable.
+ For more on why fsync often fails to work on today's hardware, see:
+ Zheng M, Tucek J, Qin F, Lillibridge M. Understanding the
+ robustness of SSDs under power fault. 11th USENIX Conference on
+ File and Storage Technologies, 2013 (FAST '13), 271-84
+ http://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
+ http://austingroupbugs.net/view.php?id=672
+
2013-03-17 Paul Eggert <eggert@cs.ucla.edu>
doc: convert some TeX accents to UTF-8
=== modified file 'doc/emacs/files.texi'
--- doc/emacs/files.texi 2013-02-25 17:36:03 +0000
+++ doc/emacs/files.texi 2013-04-26 06:35:33 +0000
@@ -705,13 +705,20 @@
final newlines.
@vindex write-region-inhibit-fsync
- When Emacs saves a file, it invokes the @code{fsync} system call to
-force the data immediately out to disk. This is important for safety
-if the system crashes or in case of power outage. However, it can be
-disruptive on laptops using power saving, as it may force a disk
-spin-up each time you save a file. If you accept an increased risk of
-data loss, you can set @code{write-region-inhibit-fsync} to a
-non-@code{nil} value to disable the synchronization.
+ Normally, when programs like Emacs write a file, the operating
+system briefly caches the file's data in main memory before committing
+the data to disk. This can greatly improve performance; for example,
+when running on laptops, it can avoid a disk spin-up each time Emacs
+saves a file. However, it risks data loss if the operating system
+crashes before committing the cache to disk.
+
+ To lessen this risk, set @code{write-region-inhibit-fsync} to
+@code{nil}: this causes Emacs to invoke the @code{fsync} system call
+after saving a file. Using @code{fsync} does not eliminate the risk
+of data loss, partly because many systems do not implement
+@code{fsync} properly, and partly because Emacs's file-saving
+procedure typically relies also on directory updates that might not
+survive a crash even if @code{fsync} works properly.
@node Interlocking
@subsection Protection against Simultaneous Editing
=== modified file 'etc/ChangeLog'
--- etc/ChangeLog 2013-04-24 16:50:14 +0000
+++ etc/ChangeLog 2013-04-26 06:35:33 +0000
@@ -1,3 +1,7 @@
+2013-04-26 Paul Eggert <eggert@cs.ucla.edu>
+
+ * NEWS: `write-region-inhibit-fsync' now defaults to t.
+
2013-04-24 Tassilo Horn <tsdh@gnu.org>
* themes/tsdh-dark-theme.el (tsdh-dark): Add ido faces and remove
=== modified file 'etc/NEWS'
--- etc/NEWS 2013-04-25 17:39:44 +0000
+++ etc/NEWS 2013-04-26 06:35:33 +0000
@@ -61,6 +61,8 @@
** `initial-buffer-choice' can now specify a function to set up the
initial buffer.
+** `write-region-inhibit-fsync' now defaults to t instead of to nil.
+
** ACL support has been added.
+++
*** Emacs preserves the ACL entries of files when backing up.
=== modified file 'src/ChangeLog'
--- src/ChangeLog 2013-04-24 15:09:49 +0000
+++ src/ChangeLog 2013-04-26 06:35:33 +0000
@@ -1,3 +1,8 @@
+2013-04-26 Paul Eggert <eggert@cs.ucla.edu>
+
+ * fileio.c (syms_of_fileio):
+ `write-region-inhibit-fsync' now defaults to t.
+
2013-04-24 Kenichi Handa <handa@gnu.org>
* coding.c (decode_coding_iso_2022): When an invalid escape
=== modified file 'src/fileio.c'
--- src/fileio.c 2013-04-07 16:18:41 +0000
+++ src/fileio.c 2013-04-26 06:35:33 +0000
@@ -6072,8 +6072,9 @@
DEFVAR_BOOL ("write-region-inhibit-fsync", write_region_inhibit_fsync,
doc: /* Non-nil means don't call fsync in `write-region'.
This variable affects calls to `write-region' as well as save commands.
-A non-nil value may result in data loss! */);
- write_region_inhibit_fsync = 0;
+Setting this to nil may avoid data loss if the system loses power or
+the operating system crashes. */);
+ write_region_inhibit_fsync = 1;
DEFVAR_BOOL ("delete-by-moving-to-trash", delete_by_moving_to_trash,
doc: /* Specifies whether to use the system's trash can.
- bug#14273: `write-region-inhibit-fsync' should default to t,
Paul Eggert <=