[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: libtool 2.4 args parsing incredibly slow

From: Ingo Krabbe
Subject: Re: libtool 2.4 args parsing incredibly slow
Date: Tue, 25 Jan 2011 10:37:38 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On Mon, Jan 24, 2011 at 07:05:17PM -0600, Dan McGee wrote:
> Hadn't noticed this regression until I was running some things on my
> slower Atom laptop today, but thought I'd let you guys know what we're
> seeing in our test suite. The project is pacman
> (http://projects.archlinux.org/pacman.git/), the Arch Linux package
> manager. I've tried to put together a small test case to show the
> difference; a tarball is attached. Extract it and copy your /bin/echo
> to .libs/lt-echo and it should work.
> I'm noticing the super slow argument parsing when invoking the wrapper
> script during our test runs. This particular test is meant to provide
> 1000 test packages as arguments; it performs fine on our maint branch
> but takes forever on master now due to a libtool upgrade.
> Here is the output of my test harness/script:
> $ ./time-test.sh
> no wrapper:
> real  0m0.038s
> user  0m0.033s
> sys   0m0.003s
> libtool 1.5 wrapper:
> real  0m0.174s
> user  0m0.157s
> sys   0m0.020s
> libtool 2.4 wrapper:
> real  1m0.118s
> user  0m59.806s
> sys   0m0.077s
> If the attachment does not come through or it is stripped, it is
> available here for now as well:
> http://dev.archlinux.org/~dan/lt-args-regression.tar.gz

Hi Dan,

the reason for this behaviour is, that libtool 2.4 is able to
pass own arguments to the wrapper (prefixed with --lt-), that needs to
be filtered out when building the call to ".libs/lt-echo".

The removal of such arguments is done in func_exec_program, where the
argument list is rebuild by:

for lt_wr_arg; do #[...]
        set x "$@" "$lt_wr_arg"
shift; done

So with n args set is called with n+1 args n times, which is surely a
O(n^2) operation.

Maybe it would be better to replace this loop by something like:

func_exec_program ()
  func_exec_program_core $(printf "\"%s\" " "$@" | sed \
        -e 's/"--lt-[^"]*"[ \t]*//g' \
        -e 's/^"\([^"]*\)"/\1/g' \
        -e 's/[ \t]*"\([^"]*\)"/ \1/g'

bye ingo

reply via email to

[Prev in Thread] Current Thread [Next in Thread]