bash-completion icon indicating copy to clipboard operation
bash-completion copied to clipboard

make completion is slow for huge Makefiles (generated by Automake)

Open philipp-classen opened this issue 9 years ago • 4 comments

(This is a follow-up on the discussion of #63)

For huge Makefiles, as generated by Automake, bash completions becomes very slow (>10 seconds).

To reproduce, use huge_makefile_example.zip. Completion for make should take several seconds. On my machine, it takes about 4 seconds for the call to "make", and additionally more than 10 seconds for the call to "sed".

The archive also contains the Make database generated by

__BASH_MAKE_COMPLETION__=1 make -f Makefile -npq .DEFAULT 2>/dev/null 1>Makefile.db

philipp-classen avatar Aug 13 '16 23:08 philipp-classen

Is there any progress on this in the meantime? I even encounter a few seconds wait time with very short makefiles which need to run commands for variables. Can command running be disabled to speedup tab completion at the cost of correctnes?

SuperSandro2000 avatar Sep 08 '21 07:09 SuperSandro2000

I think there are no efforts on this for now.

with very short makefiles which need to run commands for variables.

In the original report, the time of sed (10 secs) seems to be longer than that of make (4 secs). In the case that commands are run for variables, I guess the time of make should be dominant. What is the result of the following command in the directory?

$ time make -npq | wc

If this explains the most part of the delay you observe, I think it's difficult to improve the response because there is no way to disable only $(shell slow-command) in Makefile unless GNU make supports the feature. However, if we give up completions of all the targets that includes variables or wildcards (such as $(OBJDIR)/file or %.o) and also give up tracking includes, we may just run sed -n 's/^[[:space:]]*\([^:]*[^[:space:]]\)[[:space:]]*:\([^=].*\)\{0,1\}$/\1/p' Makefile to extract target names. Or another way might be to use timeout command to set a timeout for the call of make -npq, and to fall back to the above simple sed on the timeout.

akinomyoga avatar Sep 08 '21 08:09 akinomyoga