Hallo Gabriel F. T. Gomes, 25.11.18 15:35 Gabriel F. T. Gomes: > On 25 Nov 2018, Timo Weingärtner wrote: > >with the last upgrade of bash-completion completing hostnames has > >become slow (takes more than two seconds). My /etc/ssh/ssh_known_hosts > >file has quite some size (23084 lines / 12 MB), but this was not a > >problem with the previous implementation. > > OK, sounds like a lot of time. > > >I guess the problem is the while read … done < known_hosts_file loop, > >where the shell has to read() one byte at a time, causing a massive > >amount of syscalls (which have become even more costly this year).
OK, it is not the one-byte-per-read()-problem, which still occurs with pipes; bash has an optimisation for seek()able files and read()s 128 bytes per call, then seek()s back to behind the line terminator. > I have backported a patch [1] from the upstream master branch, in order > to fix bug #848125 [2]. Running the following command against current > upstream sources shows that there are no newer patches related to this > (lines 1479 to 1665 contain the function, _known_hosts_real, that > parses the known_hosts file): > > git log --stat -L1479,1665:bash_completion > (lastest commit is the patch that I backported [1]) Before reporting the bug I read the changelog and a quick research found that code change as a debian patch. > I think we need to forward this problem report upstream. Do you have > more information that I could add to it (maybe the syscall trace you > ran)? $ time bash -c 'while read -ra line; do :; done' < kh_file real 0m0,811s user 0m0,749s sys 0m0,059s I can't provide my /etc/ssh/ssh_known_hosts file because it contains information some people consider confidential. But I can say that for a host in that file there are several names (up to 221) and multiple key( type)s aka duplicate hostlists (up to 3). > PS: I don't want to remove the patch from Debian, because it would only > solve the problem you are reporting until bash-completion 2.9 is > released. Of course. I'll try to hack something with the same features using only essential tools (cut, grep, tr, sed, …) that will do in under 0,1s with the same input. Grüße Timo
signature.asc
Description: This is a digitally signed message part.

