I can reproduce this on current Jaunty as well as Intrepid, so I'm re-
confirming.

However, the extremely slow completion only occurs when the current
working directory or the Java classpath directories contain a large
number of files.

If you try it in an empty or almost empty directory (such as the
~/Desktop folder), the problem doesn't manifest itself. Try it in your
home directory (assuming you have a lot of files in the directory
structure under it), or even at the filesystem root or something. You
don't even need to have a Java class file in there to reproduce the
issue, and just typing "java <tab>" in such a directory should trigger
the slow completion routine causing the shell to get stuck, potentially
for several minutes.


Quick analysis:

My understanding of how bash-completion works isn't very good but just
by looking at the source in /etc/bash_completion I think most of the
time is spent in the _java_classes() function.

If no classpath has been explicitly set either with a command-line
option or an environment variable, the current working directory is used
as the search path for classes available for running. The
_java_classes() function runs a "find" command on that directory to
locate all .class files within that path, and that can be a pretty slow
thing to do on a large directory tree, probably taking an approximately
linear amount of time in proportion to the number of files within the
entire tree.

On my system with empty disk buffers and caches it took about 20 seconds
on a tree with ~23,000 files, and probably more than two minutes when
done at the top of a directory tree with more than 200,000 files. The
performance of the find operation is disk I/O-bound, so if the contents
of the tree are already in the disk cache, the completion will happen a
lot faster.

I'm not quite sure how that should or could be fixed yet. If it's
possible to avoid going through the entire directory tree with find,
that would probably be strongly preferable. It seems that should be
possible but I'm not quite sure yet how much the completion routines
would need to be modified in order to get things working that way.

There might also be other performance issues but this is the most
immediately obvious one I can see.


The completion routines for Java-related file names is in the 
/etc/bash_completion file. The file belongs to the bash-completion package, so 
the package designation seems to be appropriate.


As mentioned in the original report, the problem does not occur in a root shell 
with the default Ubuntu setup. This is because bash-completion is not in use 
for the root account. Likewise, if your user account doesn't have 
bash-completion enabled for one reason or another, the bug will not appear.


** Changed in: bash-completion (Ubuntu)
       Status: Incomplete => Confirmed

-- 
bash freezes when using completion as normal user.
https://bugs.launchpad.net/bugs/106500
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to