From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Romain Francoise Newsgroups: gmane.emacs.devel Subject: Making fsync() optional Date: Mon, 12 Sep 2005 21:27:02 +0200 Organization: orebokech dot com Message-ID: <87oe6yf5o9.fsf@pacem.orebokech.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1126554478 8321 80.91.229.2 (12 Sep 2005 19:47:58 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 12 Sep 2005 19:47:58 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 12 21:47:47 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EEuGb-0004Ev-1Q for ged-emacs-devel@m.gmane.org; Mon, 12 Sep 2005 21:47:01 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EEuGa-000481-Fw for ged-emacs-devel@m.gmane.org; Mon, 12 Sep 2005 15:47:00 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EEu4q-00086Q-Qo for emacs-devel@gnu.org; Mon, 12 Sep 2005 15:34:53 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EEu4c-0007yh-KB for emacs-devel@gnu.org; Mon, 12 Sep 2005 15:34:45 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EEu4a-0007wb-5t for emacs-devel@gnu.org; Mon, 12 Sep 2005 15:34:36 -0400 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtp (TLS-1.0:RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1EEu1r-0003n4-7I for emacs-devel@gnu.org; Mon, 12 Sep 2005 15:31:48 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1EEtz9-0005uK-Cv for emacs-devel@gnu.org; Mon, 12 Sep 2005 21:28:59 +0200 Original-Received: from yeast.orebokech.com ([82.67.41.165]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 12 Sep 2005 21:28:59 +0200 Original-Received: from romain by yeast.orebokech.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 12 Sep 2005 21:28:59 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: emacs-devel@gnu.org Original-Lines: 73 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: yeast.orebokech.com X-Face: }9mYu,e_@+e!`Z-P5kVXa3\_b:hdJ"B)ww[&=b<2=awG:GOIM List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:42857 Archived-At: 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 | I've become someone else's it's a miracle -- http://orebokech.com/ | nightmare...