From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pip Cet Newsgroups: gmane.emacs.bugs Subject: bug#46881: 28.0.50; pdumper dumping causes way too many syscalls Date: Fri, 5 Mar 2021 13:16:14 +0000 Message-ID: References: <83r1kw6b06.fsf@gnu.org> <90e99fc5-280d-63bb-9bc4-3efe89b9f9e2@dancol.org> <83a6riysnv.fsf@gnu.org> <83zgzixcfy.fsf@gnu.org> <83v9a5yfc0.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13876"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 46881@debbugs.gnu.org, eggert@cs.ucla.edu To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 05 14:17:13 2021 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 1lIAKP-0003WU-2V for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 05 Mar 2021 14:17:13 +0100 Original-Received: from localhost ([::1]:35670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIAKO-00082D-4K for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 05 Mar 2021 08:17:12 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52840) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIAKF-00081G-4K for bug-gnu-emacs@gnu.org; Fri, 05 Mar 2021 08:17:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49899) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lIAKE-00068P-Is for bug-gnu-emacs@gnu.org; Fri, 05 Mar 2021 08:17:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lIAKE-0004DZ-E4 for bug-gnu-emacs@gnu.org; Fri, 05 Mar 2021 08:17:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Pip Cet Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 05 Mar 2021 13:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46881 X-GNU-PR-Package: emacs Original-Received: via spool by 46881-submit@debbugs.gnu.org id=B46881.161495021816002 (code B ref 46881); Fri, 05 Mar 2021 13:17:02 +0000 Original-Received: (at 46881) by debbugs.gnu.org; 5 Mar 2021 13:16:58 +0000 Original-Received: from localhost ([127.0.0.1]:33212 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lIAK9-00049d-Mq for submit@debbugs.gnu.org; Fri, 05 Mar 2021 08:16:58 -0500 Original-Received: from mail-oi1-f175.google.com ([209.85.167.175]:35934) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lIAK8-00044Q-Dh for 46881@debbugs.gnu.org; Fri, 05 Mar 2021 08:16:57 -0500 Original-Received: by mail-oi1-f175.google.com with SMTP id j1so2467027oiw.3 for <46881@debbugs.gnu.org>; Fri, 05 Mar 2021 05:16:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=H0SXET0ERFvOY8lTy7BnLVCeaYnyZz1ClNI5Aa6Rr1k=; b=KHBoAln4dkiPDt1K7dk/CD05wWfrGFrKkpTKjHkQPYDBZjKKFnNi6P3oRVe/MvrNjA XSzX4gLRvsqDDSqlvSScbcn7ZVmEwMUl/qEam6y7ytwRSTDiCJB6ZGAdgQDVQr/X3anG fsbeL4Iun4Lit+SgWujb8uKwamzSUx8u00y5tL9uGpA88mMrI7tcptdMj8szJuhxYeO/ FN6Ue5nux35oPs+5G9b/rA7Q9Wp70x+E6JnNzeymQaxXWipY+jHdPOuJURRM9hSDOSuL vXE8HrRq1A2vH9rOj6lxeiNKA37W+Wf4obLz/hY4NpsyCehw3KjzJl7iKIMXrZrBX/jD V06Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=H0SXET0ERFvOY8lTy7BnLVCeaYnyZz1ClNI5Aa6Rr1k=; b=Uts56fRDR4fyEDNKdFLptg5fpO+5oOqjcifcbcvZB0U2Q/Br6jNInQ5q+/5aIWLY3N 3vKI4TiJUkbeEiifnkHLHuuhp8fqEgCadE1EGgMPV3UpHnsJH/hT3+xv+xKR0prGgOHm L+9EAsUs0CC/uacUGO/c+2TFqXyINHKj2vgEI7HkZoTEo+8ViE0HGNa6LA20MIHcfqct yhSACMjy+gpRi+f1AHkoOyWfMS0+rE/Y9RbJstuHvWr8H50AxLiYgyrqgLTRN4EKzQ76 rfiFnlcxVNOfoDbxxX67n5EQcGYnRuqCF2XqvEz0wKpA2234uZMK2EPitqVRkyQSIDMn oZDA== X-Gm-Message-State: AOAM530epCuOWzRjHlEGLHr5X8tiMp5X4JdbS7E/XZGrSa5V9Z1XwWpg ZFwQrwZsK4jFOR+HzR4uC20jfz527cY07gO2Gx0= X-Google-Smtp-Source: ABdhPJyrccCB5s04d5/bgzi+YG0ag4UF7eDxUZlwZGS/HcavT4D2asqz4WCtxIsxj8i5S6vrhF1jlW0+QMshPDXyH1M= X-Received: by 2002:aca:4c0f:: with SMTP id z15mr3194359oia.44.1614950210855; Fri, 05 Mar 2021 05:16:50 -0800 (PST) In-Reply-To: <83v9a5yfc0.fsf@gnu.org> 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" Xref: news.gmane.io gmane.emacs.bugs:201532 Archived-At: On Fri, Mar 5, 2021 at 12:07 PM Eli Zaretskii wrote: > > From: Pip Cet > > Date: Fri, 5 Mar 2021 09:54:32 +0000 > > Cc: Daniel Colascione , eggert@cs.ucla.edu, 46881@debbugs.gnu.org > > > > My patch: > > > > real 0m1.988s > > user 0m1.916s > > sys 0m0.073s > > > > fwrite-based patch: > > > > real 0m3.576s > > user 0m2.571s > > sys 0m1.006s > > 30% slowdown and 1.5 sec absolute time difference doesn't sound bad > enough to me to It's a 30% slowdown of the entire dump process, including the CPU-intensive part which loads Emacs. I think you get a better idea of the performance difference from the "sys" numbers above. And the absolute time difference is more than that, because Emacs is dumped twice during each build; the first dump file is about 2.5 times the size of the ultimate dump file, so my guess (as I said before, unfortunately Intel decided to make this system not have a predictable CPU clock, so I can't really run good benchmarks) is we're talking about 4.5 seconds here. > justify a homemade solution. "Create a buffer in memory and do all the IO at once" is such an old solution that even the GNU Coding Standards explicitly recommend it (albeit for input files): You could keep the entire input file in memory and scan it there instead of using stdio >I say let's go with stdio. Maybe setbuffer(3) could help us here? I could run some benchmarks for that if the idea isn't out of the question. > > > > Also, we're not currently using fseek-and-write anywhere in Emacs. > > > > > > I don't see why this would be important. > > > > Because the stream returned by emacs_fopen might not be generally seekable? > > I don't see how that could happen. It has, to me, but I'm willing to accept I did some inadvisable things first. > > By preparing the data in memory and writing it in one go, which > > doesn't require any of the major complications of implementing > > buffered streams. > > There are no complications I can see, not in our sources. (And you > don't actually write it in one go anyway, see emacs_full_write.) Er, precisely. I was the one saying there are no complications, so we shouldn't let the idea of "implementing our own buffered streams" scare us, because that is a complicated project but it's also not what we are doing. > So let's go with the stdio solution, please. Should I add a sync after every seek to make absolutely certain, rather than merely likely, this will destroy someone's flash chip one day? Pip