From: Bastian Beischer <bastian.beischer@rwth-aachen.de>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Alex Harsanyi <alexharsanyi@gmail.com>,
Emacs-Devel <emacs-devel@gnu.org>
Subject: Re: vc-dir operation is very slow on large git repositories in Emacs 26.1
Date: Mon, 25 Jun 2018 17:44:21 +0200 [thread overview]
Message-ID: <CAK9AuB9pi7jhVuzkqULZam0Y7=wxsBJAzp5p=LVAeJs+MAWAGA@mail.gmail.com> (raw)
In-Reply-To: <83lgb2sxnr.fsf@gnu.org>
On Mon, Jun 25, 2018 at 5:17 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Bastian Beischer <bastian.beischer@rwth-aachen.de>
>> Date: Mon, 25 Jun 2018 13:09:37 +0200
>> Cc: Eli Zaretskii <eliz@gnu.org>, Emacs-Devel <emacs-devel@gnu.org>
>>
>> >From these timings it appears that you have been using a 4096 byte
>> buffer.
>
> Yes, the default buffer size of a pipe on Windows is 4KB.
>
>> Assume that all the delay in the 83.7 seconds is due to 50ms waits,
>> one such wait whenever the buffer is full. This is based on the fact
>> that you observe a ~proportional slowdown when increasing the
>> read-delay. Then this means that the buffer was full 1674 times, which
>> means that the buffer size is 6.5 MB / 1674 = 4071 - approx. 4096
>> bytes. So the predicted approximate delay for a message of size S is
>>
>> D = (S / B) * W
>>
>> where B is the buffer size (4096) and W is the w32-pipe-read-delay
>> (0.05 s). Based on that logic it appears that setting
>> w32-pipe-buffer-size to 16384 should give you a ~four times smaller
>> total delay - especially when w32-pipe-read-delay is 50 ms, for
>> example. Unless the OS refuses to provide you with such a buffer size?
>
> I think you ignore a few factors here.
Yes indeed, but the fact that one can go to ~1s by reducing the delay
suggests that all of this can be ignored to first order. It looks like
the input rate to the pipe can be considered infinite in a good
approximation.
> Are you familiar with how
> Emacs on Windows reads data from async subprocesses? If not, I
> suggest to read the large comment around line 800 of w32proc.c and
> study the code it describes.
No I'm not familiar with the actual code - you are very right to point
me to it and I will study it. I'm just making some very naive
observations :)
>
> With 50-msec delay, it is reasonable to assume that the pipe's buffer
> gets filled while the reader thread waits for 50 msec, so most of the
> time is indeed due to these waits. But with zero waits, its quite
> possible that Emacs reads the stuff from the pipe as fast as Git
> writes to its other end, because the reading can begin very soon after
> the first byte is written to the pipe (in reality, writes are
> probably buffered, so the first chunk is much larger than 1 byte). If
> Emacs empties the pipe as fast as Git writes to it or faster, the size
> of the pipe will have (almost) no effect whatsoever.
I agree with all of this, but the point is that _if_ with 50 msec
delay the buffer get's filled completely, we should assume that a
buffer twice as large woud also get filled completely, provided that
the input rate is near infinite. I think that assumption is valid
because the total time is linear with the delay down to delays of
order 5 msec at least. That should result in a data rate which is
twice as large. Therefore I don't understand how the timing can be
independent of the buffer size. But maybe studying the code will make
me understand the situation :)
Looking at commit 58a622d473112f8ff5b4bdb3e49bc6573dfd3404 (where you
introduced w32-pipe-buffer-size) I can see a code path that results in
resetting the buffer size to 4 KB. Maybe that get's taken?
>
>> Unless the OS refuses to provide you with such a buffer size?
>
> No, there should be no such problem.
>
> Enlarging the pipe buffer size is (IME) only needed when Emacs needs
> to _write_ large amounts of data to the subprocesses, and the
> subprocesses doesn't keep up. We write to the pipe in the main
> thread, so with small enough buffer and slow enough reading by the
> subprocesses will eventually cause Emacs to hang, which is not really
> user-friendly. See bug#22344 and bug#24143, for example.
next prev parent reply other threads:[~2018-06-25 15:44 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-20 10:50 vc-dir operation is very slow on large git repositories in Emacs 26.1 Alex Harsanyi
2018-06-20 15:51 ` Eli Zaretskii
2018-06-20 22:33 ` Alex Harsanyi
2018-06-21 14:32 ` Eli Zaretskii
2018-06-22 1:12 ` Alex Harsanyi
2018-06-22 8:57 ` Eli Zaretskii
2018-06-22 9:46 ` Alex Harsanyi
2018-06-22 12:46 ` Alex Harsanyi
2018-06-22 18:24 ` Eli Zaretskii
2018-06-22 20:43 ` w32-pipe-read-delay (was: vc-dir operation is very slow on large git repositories in Emacs 26.1) Stefan Monnier
2018-06-23 7:21 ` Eli Zaretskii
[not found] ` <CAH-ciFrCk=pVTDUA+8F1XZSK40Wr21yzz3u=mutJ0NM3UdojNw@mail.gmail.com>
2018-06-23 13:30 ` Fwd: " Alex Harsanyi
2018-06-23 13:32 ` Alex Harsanyi
2018-06-23 13:40 ` Eli Zaretskii
2018-06-23 14:00 ` Alex Harsanyi
2018-06-23 14:31 ` Eli Zaretskii
2018-06-30 8:46 ` Eli Zaretskii
2018-06-25 10:40 ` vc-dir operation is very slow on large git repositories in Emacs 26.1 Alex Harsanyi
2018-06-25 11:09 ` Bastian Beischer
2018-06-25 12:23 ` Alex Harsanyi
2018-06-25 15:17 ` Eli Zaretskii
2018-06-25 15:44 ` Bastian Beischer [this message]
2018-06-25 16:23 ` Eli Zaretskii
2018-06-25 22:28 ` Alex Harsanyi
2018-06-25 14:51 ` Eli Zaretskii
2018-06-22 9:04 ` Dmitry Gutov
2018-06-23 13:37 ` Eli Zaretskii
2018-06-23 18:28 ` Dmitry Gutov
2018-06-23 18:44 ` Eli Zaretskii
2018-06-25 12:55 ` Dmitry Gutov
2018-06-25 15:20 ` Eli Zaretskii
2018-06-26 15:14 ` Sergey Organov
2018-06-27 2:01 ` Dmitry Gutov
2018-06-27 2:49 ` Tom Tromey
2018-06-27 9:41 ` Dmitry Gutov
2018-06-27 15:12 ` Eli Zaretskii
2018-06-28 0:30 ` Dmitry Gutov
2018-06-28 12:55 ` Eli Zaretskii
2018-06-28 13:06 ` Dmitry Gutov
2018-06-28 13:12 ` Eli Zaretskii
2018-06-28 13:18 ` Dmitry Gutov
2018-06-28 13:38 ` Eli Zaretskii
2018-06-28 13:47 ` Dmitry Gutov
2018-06-28 14:00 ` Eli Zaretskii
2018-06-28 13:21 ` Sergey Organov
2018-06-28 13:28 ` Dmitry Gutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAK9AuB9pi7jhVuzkqULZam0Y7=wxsBJAzp5p=LVAeJs+MAWAGA@mail.gmail.com' \
--to=bastian.beischer@rwth-aachen.de \
--cc=alexharsanyi@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.