all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Romain Francoise <romain@orebokech.com>
Subject: Making fsync() optional
Date: Mon, 12 Sep 2005 21:27:02 +0200	[thread overview]
Message-ID: <87oe6yf5o9.fsf@pacem.orebokech.com> (raw)

Would people be conceptually opposed to making the fsync() call optional
in Fwrite_region?  Calling it after each write defeats the kernel's
ability to commit consecutive buffers to disk in one go, which can be
beneficial in a lot of cases (like nnml files in an nnml directory).  It
also means that the user has to wait for the file to hit the disk when
saving files interactively (under heavy system load, this can take a
while).  It also forces the disk to spin up on laptops (even with laptop
mode and friends).

Of course calling fsync() is safer if the system goes down right after
saving the file, but for systems with uninterruptible power, it doesn't
matter.

Tentative patch:

Index: src/fileio.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/fileio.c,v
retrieving revision 1.553
diff -c -r1.553 fileio.c
*** src/fileio.c	12 Sep 2005 13:42:49 -0000	1.553
--- src/fileio.c	12 Sep 2005 18:49:20 -0000
***************
*** 225,230 ****
--- 225,236 ----
     expanding file names.  This can be bound to / or \. */
  Lisp_Object Vdirectory_sep_char;
  
+ #ifdef HAVE_FSYNC
+ /* Nonzero means avoid calling fsync() after each write in
+    Fwrite-region.  */
+ int inhibit_fsync;
+ #endif
+ 
  extern Lisp_Object Vuser_login_name;
  
  #ifdef WINDOWSNT
***************
*** 5298,5304 ****
       Disk full in NFS may be reported here.  */
    /* mib says that closing the file will try to write as fast as NFS can do
       it, and that means the fsync here is not crucial for autosave files.  */
!   if (!auto_saving && fsync (desc) < 0)
      {
        /* If fsync fails with EINTR, don't treat that as serious.  */
        if (errno != EINTR)
--- 5304,5310 ----
       Disk full in NFS may be reported here.  */
    /* mib says that closing the file will try to write as fast as NFS can do
       it, and that means the fsync here is not crucial for autosave files.  */
!   if (!auto_saving && !inhibit_fsync && fsync (desc) < 0)
      {
        /* If fsync fails with EINTR, don't treat that as serious.  */
        if (errno != EINTR)
***************
*** 6743,6748 ****
--- 6749,6760 ----
  shortly after Emacs reads your `.emacs' file, if you have not yet given it
  a non-nil value.  */);
    Vauto_save_list_file_name = Qnil;
+ 
+ #ifdef HAVE_FSYNC
+   DEFVAR_BOOL ("inhibit-fsync", &inhibit_fsync,
+ 	       doc: /* Non-nil means avoid calling fsync() after each save.  */);
+   inhibit_fsync = 0;
+ #endif
  
    defsubr (&Sfind_file_name_handler);
    defsubr (&Sfile_name_directory);

-- 
Romain Francoise <romain@orebokech.com> | I've become someone else's
it's a miracle -- http://orebokech.com/ | nightmare...

             reply	other threads:[~2005-09-12 19:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-12 19:27 Romain Francoise [this message]
2005-09-13 15:55 ` Making fsync() optional Richard M. Stallman
2005-09-13 18:19   ` Romain Francoise
2005-09-14 14:06     ` Richard M. Stallman
2005-09-15  8:45       ` Romain Francoise
2005-09-16  1:01         ` Richard M. Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87oe6yf5o9.fsf@pacem.orebokech.com \
    --to=romain@orebokech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.