Here is another one. This is the first patch mentioned here that touches
the dependency resolver. I'd be nice if we had more people with the
ability to work on it. So if you're interested in that, take a look.
Bug 498122 - portage-2.2.8 takes nearly twice as long to calculate
dependencies for world update
The problem with the patch mentioned in that bug is, that from there on
metadata access (specifically USE needs to be computed) is required to
search for slot operator rebuilds.
I expect that the metadata access can be avoided in most cases. To fix
this bug, I suggest to implement a check that decides if the metadata
access is required.
Here are some hints.
Take a look at the first block of the patch. It's about computing the
'atoms' variable. This variable is a set of all atoms in all *DEPEND
strings of some package ('replacement_parent').
This list is later searched for atoms for which atom.cp is equal to
dep.atom.cp (and which aren't blockers).
Before this patch the whole content of the *DEPEND string was added to
'atoms'. An example:
DEPEND=x? ( cat/foo ) would always result in atoms = {cat/foo}, even
if the use flag 'x' was disabled for the package.
The leads to problems in the following case:
DEPEND=x? ( =cat/foo-1 ) !x? ( =cat/foo-2 ).
The code later in the function tries to find a package that matches all
atoms in 'atoms'. Obviously there cannot be any package that satisfies
both =cat/foo-1 and =cat/foo-2 at the same time.
And this is not necessary at all here, because of the way the DEPEND is
written. After evaluating the use conditionals there is always one atom
left. But to figure this out, you need to know USE (the set of enabled
use flags).
Since computing USE is expansive, we'd like to avoid computing it.
Consider the following example:
We're searching for atoms with atom.cp == cat/foo:
DEPEND=cat/foo x? ( cat/bar )
No use conditional influences the set of atoms in this DEPEND for which
atom.cp == cat/foo. There's no point in evaluation them and in
consequence there's no point of computing USE.
I propose to implement a function* that maps (package, cp) to the set of
atoms in the *DEPEND of package for which atom.cp == cp (and which
aren't blockers).
This function should:
* First decide if evaluating USE is necessary or not
* Then evaluate the conditionals if required
* Compute and return the set of atoms with atom.cp == cp.
This function should cache its results. For the case without USE, the
cache should be part of self._frozen_config (contains stuff that never
changes). For the case that needs USE, it should be in
self._dynamic_config (contains stuff that may change between
backtracking steps).
For the implementation of the check you'll want to look at the functions
in portage.dep, specifically paren_reduce (ignore the deprecation
warning, we may have to remove that).
Feel free to ask questions here or on IRC.
hf :)