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

Re: [Patch] Optimize pkgAllUpgrade() in algorithms.cc



To clarify, that would be a const for ignoreHold to prevent anybody from accidentally modifying it with future changes?


On Sat, Nov 17, 2012 at 7:08 PM, Daniel Hartwig <mandyke@gmail.com> wrote:
On 18 November 2012 06:53, Jonathan Thomas <echidnaman@gmail.com> wrote:
> Hi,
>
> Using valgrind I noticed that pkgAllUpgrade in apt-pkg/algorithms.cc was
> checking the APT::Ignore-Hold config variable way more than it needed to.
> (It won't ever change over the life of the function.)
>
> By looking up the config value once before the for loop and caching the
> result, pkgAllUpgrade takes half as long to execute as it used to. In a
> real-world application, this reduced the startup time of an application that
> called pkgAllUpgrade as part of its startup by ~5%. (Around a 200ms gain)

Add in a missing “const” and this looks great.

There is a small potential that some application twiddles this in the
few pkgDepCache virtual functions, though I don't see that being too
practical, and strongly doubt it is actually done.

Thanks


Reply to: