Subject: bug#42911: 28.0.50; write_region sometimes extremely very slow

From: Tino Calancha <[email-masked]>
Date: Tue, 25 Aug 2020 18:04:17 +0200

Eli Zaretskii <[email-masked]> writes:

>> Recipe:
>> emacs -Q ~/save-buffer-slow.txt
>> ;; insert few characters and run
>> M-: (benchmark-run nil (save-buffer))
>> 
>> ;; Repeat several times: sometimes it takes a reasonable time, but
>> ;; in others it takes huge time
>> ;; (6-10 s to save a buffer with less that 50 characters)
>> 
>> It happens randomly.
>
> Did you check that GC doesn't kick in when the "slow" saving happens?
`benchmark-run` lets you know teh number of GC and the time used by them
while running the form.  The reported slowliness was happening even
without GC.
I was curious if someone runnning opensuse Tumbleweed was seeing something similar.

I suspect this might be a problem of my OS (probably it was under heavy stress).
Now I am in vacation, and the computer seems more relax (same like me).  I have also
upgraded the OS and got a new kernel.

The following is data right now running this:
emacs -Q /tmp/save-slow-buffer.txt
;; evaluate the following key binding:

(global-set-key (kbd "<f5>") (lambda () (interactive) (print
(benchmark-run nil (save-buffer)) (current-buffer))))

;; now push <f5> slowly several times
;; Still seems a bit slow sometimes (~0.1 s) but it is acceptable for my needs:

(0.058208321 0 0.0)
(0.10882129 1 0.025746066999999928)
(0.051934588 0 0.0)
(0.068579962 0 0.0)
(0.066899402 0 0.0)
(0.078017127 0 0.0)
(0.078926675 0 0.0)
(0.117405042 0 0.0)
(0.04960965 0 0.0)
(0.043352053 0 0.0)
(0.086415222 0 0.0)
(0.064884219 0 0.0)
(0.06522908 0 0.0)
(0.058116398 0 0.0)
(0.109880304 0 0.0)
(0.049452437 0 0.0)
(0.10265914 0 0.0)
(0.080930332 0 0.0)
(0.298022584 0 0.0)
(0.067618432 0 0.0)
(0.059602676 0 0.0)
(0.0712565 0 0.0)
(0.066321402 0 0.0)
(0.062397403 0 0.0)
(0.16588965 0 0.0)
(0.123642695 0 0.0)
(0.055607216 0 0.0)
(0.070665992 0 0.0)
(0.087962897 0 0.0)
(0.179056865 0 0.0)
(0.084647328 0 0.0)
(0.152946603 0 0.0)
(0.074221478 0 0.0)
(0.0797594 0 0.0)
(0.117525087 0 0.0)
(0.068923711 0 0.0)
(0.074521989 0 0.0)
(0.074681374 0 0.0)
(0.202450873 0 0.0)
(0.102854426 0 0.0)
(0.083368982 0 0.0)
(0.074109755 0 0.0)
(0.070000116 0 0.0)
(0.065221696 0 0.0)
(0.077440244 0 0.0)