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: Wed, 3 Mar 2021 07:35:45 +0000 Message-ID: References: <83r1kw6b06.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="0000000000004e66b405bc9ce8e0" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7756"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 46881@debbugs.gnu.org, Paul Eggert To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Mar 03 08:37:10 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 1lHM4E-0001t2-1J for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 03 Mar 2021 08:37:10 +0100 Original-Received: from localhost ([::1]:45894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lHM4C-0004oL-PD for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 03 Mar 2021 02:37:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57852) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHM46-0004oE-Qb for bug-gnu-emacs@gnu.org; Wed, 03 Mar 2021 02:37:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43514) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lHM46-0001fi-JD for bug-gnu-emacs@gnu.org; Wed, 03 Mar 2021 02:37:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lHM46-0005ph-GI for bug-gnu-emacs@gnu.org; Wed, 03 Mar 2021 02:37: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: Wed, 03 Mar 2021 07:37: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.161475699222384 (code B ref 46881); Wed, 03 Mar 2021 07:37:02 +0000 Original-Received: (at 46881) by debbugs.gnu.org; 3 Mar 2021 07:36:32 +0000 Original-Received: from localhost ([127.0.0.1]:55060 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lHM3b-0005oy-MQ for submit@debbugs.gnu.org; Wed, 03 Mar 2021 02:36:32 -0500 Original-Received: from mail-oi1-f176.google.com ([209.85.167.176]:32780) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lHM3X-0005og-FX for 46881@debbugs.gnu.org; Wed, 03 Mar 2021 02:36:30 -0500 Original-Received: by mail-oi1-f176.google.com with SMTP id a13so24990995oid.0 for <46881@debbugs.gnu.org>; Tue, 02 Mar 2021 23:36:27 -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=+EECznTjamyCy/0zBbo7zaWPtTrz+NZQaFEIg71G6L8=; b=OyxWogHD1aqtW7C98jy5/rqH272gJ7yTlXMVLA5H5zBqqxUmhqJ8orR4jOSBgzWsYF KFs887UQD8Kj+kTNIwRFacM0dsp/oIi+iXvhvPyIemILHJtYJ6v/iOXaWzMEMRMy86Ty poszsU9oNAW2Tth8ozljY37IvWEjzQwDpb7U5wUmVKTBpaZRgN8HJ73K1WYQXS51Vv6V LDcKNTF47OjXIGOxJx/B2xVuF5LInqkb9902GXC+bNHXAHHQ2iZixLe+y06dsZtauMaY WZZpJB7Zb6v68ETh/V4Pn2t48Px9hqBxoi1D4HhbU4btNGdd9OKC5PVEvFDuJCO8MfoI OfQQ== 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=+EECznTjamyCy/0zBbo7zaWPtTrz+NZQaFEIg71G6L8=; b=j5Pb+j1rI593i89onfQZUZ9l3N/cFdylRyg6kItjQlAtKlXC1xltSyAJSFmu9yVVGb BochGszsIlfZ7EN0QZjSsAY5fp7uVWy2lV/8AjZJeqkJL+rnxZ/U31o7yf6l1SekndBc RwUDUdfyGUWN8I2RKII0NK7EWD18RdPoQhOM+q9QVBZZv/pk+Ugb0YhP8LQWjeM3gJPH mNgU1e6L514IlaMNuSX5bxkjyt4UqwZ4sDMzJjeHUHwx+IcMDR1MXi1bIoGDEuE5Ui8l G8rxwfSzwQ9u1JMuAS48NbrBNj+jnVa9lINJmZP1n3ghRiALRiXULkWCJMnMv4sYh/Th brew== X-Gm-Message-State: AOAM531vKJA1RWJ9VSwH1gHeGFiIjf+lk5MkkUHMahvvTPDTcRGpM9CI W1VIozKCj/ieXhpsEDbFu0A+5C+yOTMJoM5ZBDs= X-Google-Smtp-Source: ABdhPJwhcJOmI9ybAmsRtall1VyrbFUVFaWB4MoQ2UZ2NfJUJJxRA/Zc/xHYjJG1pH4Ar+zcOjifczLTCo/KEcoadvw= X-Received: by 2002:aca:d905:: with SMTP id q5mr2758632oig.30.1614756981917; Tue, 02 Mar 2021 23:36:21 -0800 (PST) In-Reply-To: <83r1kw6b06.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:201261 Archived-At: --0000000000004e66b405bc9ce8e0 Content-Type: text/plain; charset="UTF-8" On Wed, Mar 3, 2021 at 5:51 AM Eli Zaretskii wrote: > > From: Pip Cet > > Date: Tue, 2 Mar 2021 20:45:04 +0000 > > > > On Tue, Mar 2, 2021 at 8:35 PM Pip Cet wrote: > > > I've looked into the problem, and it seems easy to solve and worth it > > > in terms of debuggability and performance. Since debuggability is such a concern, we probably shouldn't leak the buffer memory. Revised patch attached. (This patch also removes the lseek() syscalls; while not quite as numerous as the read() ones, those did clutter up straces here). > In particular, is it safe to allocate > large amounts of memory off the heap while dumping? Even if it isn't, we'd still be faster re-running the dump after growing the dumper image than the current approach is. >A couple of > places in pdumper.c says some parts of code should call malloc. IIUC, the prohibition on calling malloc, if it is still a concern, applies only when loading the dump, not while writing it. My main concern is the possibility of a partly-written dump file, since we no longer turn "!UMPEDGNUEMACS" into "DUMPEDGNUEMACS" after the dump. Maybe it would make sense to restore that feature? Pip --0000000000004e66b405bc9ce8e0 Content-Type: text/x-patch; charset="US-ASCII"; name="0001-Prepare-pdumper-dump-file-in-memory-write-it-in-one-.patch" Content-Disposition: attachment; filename="0001-Prepare-pdumper-dump-file-in-memory-write-it-in-one-.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_klt4kmx30 RnJvbSBmYWU2N2MwMjk1NWE1YmJlYTE2ZDU1NGI4ZTczNWRjOGJlZjZhOWUyIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBQaXAgQ2V0IDxwaXBjZXRAZ21haWwuY29tPgpEYXRlOiBUdWUs IDIgTWFyIDIwMjEgMjA6Mzg6MjMgKzAwMDAKU3ViamVjdDogW1BBVENIX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