From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.bugs Subject: bug#60474: 30.0.50; `write-region-inhibit-fsync' and copy-on-write file systems Date: Sun, 01 Jan 2023 18:51:59 +0000 Message-ID: <87r0we5bqo.fsf@localhost> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7631"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Timothy To: 60474@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jan 01 19:52:19 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pC3RT-0001oP-1B for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 01 Jan 2023 19:52:19 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pC3RF-0004Wh-24; Sun, 01 Jan 2023 13:52:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pC3RD-0004WS-61 for bug-gnu-emacs@gnu.org; Sun, 01 Jan 2023 13:52:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pC3RC-00050k-LN for bug-gnu-emacs@gnu.org; Sun, 01 Jan 2023 13:52:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pC3RC-0006Hm-3R for bug-gnu-emacs@gnu.org; Sun, 01 Jan 2023 13:52:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ihor Radchenko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 01 Jan 2023 18:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 60474 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.167259909924130 (code B ref -1); Sun, 01 Jan 2023 18:52:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 1 Jan 2023 18:51:39 +0000 Original-Received: from localhost ([127.0.0.1]:41765 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pC3Qp-0006H8-4G for submit@debbugs.gnu.org; Sun, 01 Jan 2023 13:51:39 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:45510) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pC3Qn-0006H0-3i for submit@debbugs.gnu.org; Sun, 01 Jan 2023 13:51:37 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pC3Qm-0004U1-PK for bug-gnu-emacs@gnu.org; Sun, 01 Jan 2023 13:51:36 -0500 Original-Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pC3Qk-0004lL-Q3 for bug-gnu-emacs@gnu.org; Sun, 01 Jan 2023 13:51:36 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id CDDC72402A5 for ; Sun, 1 Jan 2023 19:51:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1672599092; bh=3er555ATivl1Myo2f7v/aEn+30QApXCi1gcSPRWdLH0=; h=From:To:Cc:Subject:Date:From; b=P6/PvXw/i1A1LESbCrZVPfESTm4TzbXqo62WEC9uhC0VgsqQ+34y/uhp2h/7xCPG8 HqNYkvYweVqWrCzQRNNmODqyRKKuU8f3ntlE1Ve6ueGI0TrTQPQ1jk8ofmMRGTow3x qwmO9CI6MYIL92jVhnr2Gks2z6EkpOwZCCh/LihfZIw6MtZ0pnhhYbwl/hM+I1uVfn 5VT6qMC6cfiO/B18YyRt/60rJIouUVtpDYnTBkywFGcNCNQrcmg9aFkPgyoI1NKRdO xmGUMOfH7+Vum4fIK1DzOpFUoyvEma8u3lXyf9lq2dbxPxxSFymofopFHhmm+xjjAT Gn5taq6mhlO2A== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4NlSl82PhQz6tmx; Sun, 1 Jan 2023 19:51:32 +0100 (CET) Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:252277 Archived-At: Hi, We are currently exploring performance of frequent file writes in Emacs. This is important in org-persist library when we need to cache large number of data pieces, writing them on disk. It turns out that Emacs is pretty slow when writing hundreds of files: (benchmark-run-compiled 1000 (with-temp-file "/tmp/test" (insert "test"))) ; => 4 sec Mostly because of fsync: (benchmark-run-compiled 1000 (let ((write-region-inhibit-fsync t)) (with-temp-file "/tmp/test" (insert "test")))) ; => 0.15 sec Timothy have found the following comment in src/fileio.c: /* fsync can be a significant performance hit. Often it doesn't suffice to make the file-save operation survive a crash. For batch scripts, which are typically part of larger shell commands that don't fsync other files, its effect on performance can be significant so its utility is particularly questionable. Hence, for now by default fsync is used only when interactive. For more on why fsync often fails to work on today's hardware, see: Zheng M et al. Understanding the robustness of SSDs under power fault. 11th USENIX Conf. on File and Storage Technologies, 2013 (FAST '13), 271-84 https://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 https://austingroupbugs.net/view.php?id=672 */ write_region_inhibit_fsync = noninteractive; Although fsync may provide some benefit on generic file systems, it does not look like it is any useful in copy-on-write file systems. I am wondering if Emacs could detect file system when writing the file and disable fsync for FSes like BTRFS and other CoW file systems. In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.35, cairo version 1.17.6) of 2022-12-26 built on localhost Repository revision: cc29fab3a66c59e77d0ff67c0f3e2e34ec80a03c Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101004 System Description: Gentoo Linux -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at