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 09:54:32 +0000 Message-ID: References: <83r1kw6b06.fsf@gnu.org> <90e99fc5-280d-63bb-9bc4-3efe89b9f9e2@dancol.org> <83a6riysnv.fsf@gnu.org> <83zgzixcfy.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="39532"; 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 10:56:34 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 1lI7CE-000AC2-73 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 05 Mar 2021 10:56:34 +0100 Original-Received: from localhost ([::1]:58038 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lI7CC-0000iI-W0 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 05 Mar 2021 04:56:33 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41038) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lI7Bi-0000h2-Q3 for bug-gnu-emacs@gnu.org; Fri, 05 Mar 2021 04:56:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49592) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lI7Bi-0006NW-IF for bug-gnu-emacs@gnu.org; Fri, 05 Mar 2021 04:56:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lI7Bi-0001av-Go for bug-gnu-emacs@gnu.org; Fri, 05 Mar 2021 04:56: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 09:56: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.16149381176076 (code B ref 46881); Fri, 05 Mar 2021 09:56:02 +0000 Original-Received: (at 46881) by debbugs.gnu.org; 5 Mar 2021 09:55:17 +0000 Original-Received: from localhost ([127.0.0.1]:32905 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lI7Az-0001Zv-1N for submit@debbugs.gnu.org; Fri, 05 Mar 2021 04:55:17 -0500 Original-Received: from mail-oo1-f53.google.com ([209.85.161.53]:43607) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lI7Aw-0001Zh-OS for 46881@debbugs.gnu.org; Fri, 05 Mar 2021 04:55:15 -0500 Original-Received: by mail-oo1-f53.google.com with SMTP id x19so280470ooj.10 for <46881@debbugs.gnu.org>; Fri, 05 Mar 2021 01:55:14 -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=/pUVpAbPc7Snr4jWcgI+Fr34P94CvOSjnbZxL7DVfXU=; b=k4Dnu2pWWSsfRJn16TNN3tfWhtXAxXhvCo+knS4NNTUuSu43WRATaf7Kgh0W9k0ydH 24CIXmVIK794htiv2bPmOsvX7ZbuRY7y8kPWgFNg+/bE8XbdTIe2FIcGBDbupOWailTz c+CXt37E6BHifUh62oApnwbrZtnlqDqPDaXf9EAY3CXU0LzRrtjP9c8pfniYzIo2gm4Z kRC5Kux5sRMHksbPR1ZcQA0VwS8c3UagF/OhFFtTwfDL5Hyn1+4FEGWfsG95Exio6beC ex4hErZWpAeleZ3YYMrNr1oshOyM2LJioTEqaVo64Nkt0OkafA3LKZGmIP2WgoV+zsuN CdzQ== 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=/pUVpAbPc7Snr4jWcgI+Fr34P94CvOSjnbZxL7DVfXU=; b=jnD5Io+GgbdOLO8sUnhekX9cOoCKMZ7c+NIWq2i+5C+8baZZ9oH1wh5QX5A9yRTiw6 chkdEh+Ofbcj/EX8r5lm1xxFi9Huq5t+OBhqHvp0McZjmlQwT90zEF4ZIFt0V0HhPefU dtJr9Qwec1xRVbyLXPzJsP4dug8mQhG2pFz+DDOAWY7CNYIrYAceWovWyYRta0FMNzP/ ypt7wjObOljvqM9LF8fw6LEqJ8QiA1L+ZiFHjcrXvTMN+dbV3DFQC+1ETfTkL4hSXNvX AYooUwhMsBXikUNB7KgXYRSJS6GmL3jpVaNIKSixV5oQPWXkU/p+vuzozQb3SBUY5D/+ v5sw== X-Gm-Message-State: AOAM532dvDTA1CKuVp70nSJ3ueI1eJDIymzUyNY9vN4c0coRMdkAz5fk perIGSQVFHZy0XgygY7gQGlvelnwc4L/fL3G1Sg= X-Google-Smtp-Source: ABdhPJzwUz0HRGSnxn97A5/I2FLppqHNkracf205PzStwH++5E9gyq/88OUef5GOlI5zuICJfNzWCwag/vRDs9B+ZJk= X-Received: by 2002:a4a:2a0a:: with SMTP id k10mr7039762oof.88.1614938109021; Fri, 05 Mar 2021 01:55:09 -0800 (PST) In-Reply-To: <83zgzixcfy.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:201514 Archived-At: On Fri, Mar 5, 2021 at 7:55 AM Eli Zaretskii wrote: > > From: Pip Cet > > Date: Fri, 5 Mar 2021 07:38:27 +0000 > > Cc: Daniel Colascione , eggert@cs.ucla.edu, 46881@debbugs.gnu.org > > > > > I'm not sure I understand: what's wrong with fseek? > > > > Nothing, assuming you're fine with the current performance. Many libcs > > aren't going to be smart enough to avoid I/O when you fseek through a > > "large" file and write a word here and there, and my suspicion is that > > would include glibc. > > Could we benchmark the two implementations instead of acting on > suspicions? Sure. My patch: real 0m1.988s user 0m1.916s sys 0m0.073s fwrite-based patch: real 0m3.576s user 0m2.571s sys 0m1.006s This is as I expected: glibc just isn't doing a very good job for this buffered stream. > In general, I'd prefer not to reinvent the wheel, and trust modern > libc's that they are efficient enough in handling buffered streams, > unless we have hard evidence to the contrary. We do, now. > If nothing else, it > would prevent people asking, like Daniel did, why didn't we use stdio > in the first place. I think it's a very good question (in fact, the brach I'm working on is called pdumper-fwrite because I decided only after creating it that all the seeking would hurt performance too much). I'll try including a comment explaining why. > > 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? > Since we open the file in > binary mode, fseek should work correctly even on non-Posix systems. I guess I should have used emacs_fopen :-) > > We're talking about a file which Emacs is going to have to keep in > > memory anyway, when reading the dump. The only case in which there > > might be a problem is if the build machine has significantly less > > available memory than the machine we intend to run on, and I just > > don't think that's going to happen. > > You are thinking about memory consumption, while I am thinking how to > avoid implementing our own private buffered streams. 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. Pip