From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#14273: `write-region-inhibit-fsync' should default to t Date: Thu, 25 Apr 2013 23:41:13 -0700 Organization: UCLA Computer Science Department Message-ID: <517A2189.3040900@cs.ucla.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1366959187 17048 80.91.229.3 (26 Apr 2013 06:53:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 26 Apr 2013 06:53:07 +0000 (UTC) To: 14273@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Apr 26 08:53:10 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UVcWs-0005TQ-Ge for geb-bug-gnu-emacs@m.gmane.org; Fri, 26 Apr 2013 08:53:10 +0200 Original-Received: from localhost ([::1]:42090 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVcWs-0005CZ-4Q for geb-bug-gnu-emacs@m.gmane.org; Fri, 26 Apr 2013 02:53:10 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:33424) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVcWo-0005CA-0s for bug-gnu-emacs@gnu.org; Fri, 26 Apr 2013 02:53:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UVcWm-0003vH-6c for bug-gnu-emacs@gnu.org; Fri, 26 Apr 2013 02:53:05 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:39971) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVcWm-0003vD-32 for bug-gnu-emacs@gnu.org; Fri, 26 Apr 2013 02:53:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UVcWk-0007hc-Sw for bug-gnu-emacs@gnu.org; Fri, 26 Apr 2013 02:53:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 26 Apr 2013 06:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 14273 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.136695916229552 (code B ref -1); Fri, 26 Apr 2013 06:53:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 26 Apr 2013 06:52:42 +0000 Original-Received: from localhost ([127.0.0.1]:44080 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UVcWP-0007gW-FS for submit@debbugs.gnu.org; Fri, 26 Apr 2013 02:52:42 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:50134) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UVcWI-0007g4-99 for submit@debbugs.gnu.org; Fri, 26 Apr 2013 02:52:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UVcWC-0003p4-1e for submit@debbugs.gnu.org; Fri, 26 Apr 2013 02:52:34 -0400 Original-Received: from lists.gnu.org ([208.118.235.17]:51588) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVcWB-0003mM-V0 for submit@debbugs.gnu.org; Fri, 26 Apr 2013 02:52:27 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:59434) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVcLU-0000P6-Fn for bug-gnu-emacs@gnu.org; Fri, 26 Apr 2013 02:41:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UVcLT-0008PG-3n for bug-gnu-emacs@gnu.org; Fri, 26 Apr 2013 02:41:24 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:54202) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVcLS-0008OF-RQ for bug-gnu-emacs@gnu.org; Fri, 26 Apr 2013 02:41:23 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id DBE1139E8106 for ; Thu, 25 Apr 2013 23:41:15 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KsMfmUNmsfvE for ; Thu, 25 Apr 2013 23:41:13 -0700 (PDT) Original-Received: from [192.168.1.9] (pool-71-189-154-249.lsanca.fios.verizon.net [71.189.154.249]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id CC94B39E8008 for ; Thu, 25 Apr 2013 23:41:13 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:73702 Archived-At: 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 + + `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 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 + + * NEWS: `write-region-inhibit-fsync' now defaults to t. + 2013-04-24 Tassilo Horn * 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 + + * fileio.c (syms_of_fileio): + `write-region-inhibit-fsync' now defaults to t. + 2013-04-24 Kenichi Handa * 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.