Subject: bug#46881: 28.0.50; pdumper dumping causes way too many syscalls

From: Stefan Monnier <[email-masked]>
Date: Wed, 16 Jun 2021 10:13:01 -0400

Pip Cet [2021-03-02 20:33:42] wrote:
> Playing around with the WebAssembly port, I noticed that pdumper, in
> creating the dump file, makes way too many syscalls: it uses
> emacs_write(), not fwrite(), so these calls translate to actual
> syscalls and context switches. On immature systems (or in special
> circumstances like a device mounted synchronously),

Thanks for this patch.  For the little story, this inefficiency showed
up on one of my Thinkpads running GNU/Linux with a plain
old ext4 partition mounted in the most standard way (no synchronous
mount or other funny business):

https://serverfault.com/questions/996495/writes-throttled-to-500kb-s

The way this manifested itself is that after some uptime individual
writes to the SSD became very slow.  For most operations, this was
completely invisible, but it was quite noticeable during Emacs's dump
which sometimes took several minutes (while all the rest of the
compilation (including the "load" part of the dump)) progressed at
(apparently) usual speeds.

        Stefan