Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 891137 - sys-apps/portage: doesn't merge repeated identical || (... ) any-of dependency blocks (and is very slow at dependency resolution when encountering such duplicates)
Summary: sys-apps/portage: doesn't merge repeated identical || (... ) any-of dependenc...
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Dependencies (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on: 921380
Blocks: 155723 835380
  Show dependency tree
 
Reported: 2023-01-16 16:03 UTC by Sam James
Modified: 2024-02-22 07:24 UTC (History)
6 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-01-16 16:03:01 UTC
See https://forums.gentoo.org/viewtopic-t-1160727.html and bug 891133.

Portage ends up having extremely slow performance with repeated identical any-of || ( ...) blocks:
```
$ diff -ruN ed-1.{18,19}
--- ed-1.18	2023-01-13 08:28:35.632365180 +0000
+++ ed-1.19	2023-01-13 08:29:28.822655700 +0000
@@ -1,13 +1,13 @@
-BDEPEND=sys-apps/texinfo || ( >=app-arch/xz-utils-5.4.0 app-arch/plzip app-arch/pdlzip app-arch/lzip ) || ( >=app-arch/xz-utils-5.4.0 app-arch/plzip app-arch/pdlzip app-arch/lzip ) || ( >=app-arch/xz-utils-5.4.0 app-arch/plzip app-arch/pdlzip app-arch/lzip ) || ( >=app-arch/xz-utils-5.4.0 app-arch/plzip app-arch/pdlzip app-arch/lzip ) || ( >=app-arch/xz-utils-5.4.0 app-arch/plzip app-arch/pdlzip app-arch/lzip ) verify-sig? ( sec-keys/openpgp-keys-antoniodiazdiaz ) verify-sig? ( app-crypt/gnupg >=app-portage/gemato-16 )
+BDEPEND=sys-apps/texinfo || ( >=app-arch/xz-utils-5.4.0 app-arch/plzip app-arch/pdlzip app-arch/lzip ) || ( >=app-arch/xz-utils-5.4.0 app-arch/plzip app-arch/pdlzip app-arch/lzip ) || ( >=app-arch/xz-utils-5.4.0 app-arch/plzip app-arch/pdlzip app-arch/lzip ) || ( >=app-arch/xz-utils-5.4.0 app-arch/plzip app-arch/pdlzip app-arch/lzip ) || ( >=app-arch/xz-utils-5.4.0 app-arch/plzip app-arch/pdlzip app-arch/lzip ) || ( >=app-arch/xz-utils-5.4.0 app-arch/plzip app-arch/pdlzip app-arch/lzip ) || ( >=app-arch/xz-utils-5.4.0 app-arch/plzip app-arch/pdlzip app-arch/lzip ) verify-sig? ( sec-keys/openpgp-keys-antoniodiazdiaz ) verify-sig? ( app-crypt/gnupg >=app-portage/gemato-16 )
 DEFINED_PHASES=configure unpack
 DESCRIPTION=Your basic line editor
-EAPI=7
+EAPI=8
 HOMEPAGE=https://www.gnu.org/software/ed/
-INHERIT=toolchain-funcs unpacker verify-sig
+INHERIT=edo toolchain-funcs unpacker verify-sig
 IUSE=verify-sig
-KEYWORDS=~alpha amd64 arm arm64 hppa ~ia64 ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris
+KEYWORDS=~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris
 LICENSE=GPL-2+
 SLOT=0
-SRC_URI=mirror://gnu/ed/ed-1.18.tar.lz verify-sig? ( mirror://gnu/ed/ed-1.18.tar.lz.sig )
-_eclasses_=toolchain-funcs	ec8bbc28394c7305b43ea07164bd8f5f	multilib	5ca4e49abed8e3a2f7b56920eadee157	multiprocessing	b4e253ab22cef7b1085e9b67c7a3b730	unpacker	8bbea377a8dd2b5d5c8bc0d834ae6157	verify-sig	afb98fe4696292e4234ce36713fd4e9e
-_md5_=bf63ad1b4806a01a7000e3fe6ce90271
+SRC_URI=mirror://gnu/ed/ed-1.19.tar.lz https://download.savannah.gnu.org/releases/ed/ed-1.19.tar.lz verify-sig? ( mirror://gnu/ed/ed-1.19.tar.lz.sig https://download.savannah.gnu.org/releases/ed/ed-1.19.tar.lz.sig )
+_eclasses_=edo	c0eb9cbe6b0bd01fcb4918f12598a4d3	toolchain-funcs	ec8bbc28394c7305b43ea07164bd8f5f	multilib	5ca4e49abed8e3a2f7b56920eadee157	multiprocessing	b4e253ab22cef7b1085e9b67c7a3b730	unpacker	8bbea377a8dd2b5d5c8bc0d834ae6157	verify-sig	afb98fe4696292e4234ce36713fd4e9e
+_md5_=3f460bcb7087cbbadf886cad16e886c9
```

With bad ed:
```
$ emerge -v1 -p sys-apps/ed
These are the packages that would be merged, in order:
Calculating dependencies... done!
Dependency resolution took 79.72 s.
[ebuild   R    ] sys-apps/ed-1.19::gentoo  USE="verify-sig" 0 KiB
Total: 1 package (1 reinstall), Size of downloads: 0 KiB
```

With good ed, it takes <7s.
Comment 1 Larry the Git Cow gentoo-dev 2023-01-16 16:05:15 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2575ec6caaa80ed8d3c9361312c797837c7c2ec3

commit 2575ec6caaa80ed8d3c9361312c797837c7c2ec3
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-01-16 16:04:22 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-01-16 16:05:08 +0000

    sys-apps/ed: workaround unpacker.eclass/Portage dep resolution bug
    
    1. unpacker_src_uri_depends doesn't flatten the deps (bug #891133) and emits
    several || ( ... ) blocks (4).
    
    2. Portage doesn't handle several repeated identical || ( ...) blocks correctly
    and takes ages to resolve (bug #891137). It should merge them together.
    
    Bug: https://bugs.gentoo.org/891137
    Bug: https://bugs.gentoo.org/891133
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-apps/ed/{ed-1.19.ebuild => ed-1.19-r1.ebuild} | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
Comment 2 Zac Medico gentoo-dev 2024-01-18 22:16:44 UTC
Must be something about the disjunctive normal form (DNF) handling added for bug 632026.
Comment 3 Zac Medico gentoo-dev 2024-02-10 04:58:11 UTC
We can probably just have the _overlap_dnf function trigger deduplication when it detects overlap between any-of blocks, since a duplicate is a special kind of overlap.
Comment 4 Larry the Git Cow gentoo-dev 2024-02-11 03:31:07 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=15c173dcea2401a13cfb3313918c77d7dbde133d

commit 15c173dcea2401a13cfb3313918c77d7dbde133d
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2024-02-11 03:28:27 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2024-02-11 03:29:23 +0000

    DuplicateOverlapDNFTestCase: Add test for bug 891137
    
    Bug: https://bugs.gentoo.org/891137
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 lib/portage/tests/dep/test_overlap_dnf.py | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)
Comment 5 Larry the Git Cow gentoo-dev 2024-02-11 05:44:09 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=12f6056da88041f82a9c9dfc23ee0eab39077782

commit 12f6056da88041f82a9c9dfc23ee0eab39077782
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2024-02-11 04:12:45 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2024-02-11 04:36:22 +0000

    _overlap_dnf: deduplicate any-of blocks
    
    Duplicate any-of blocks are eliminated since DNF expansion
    of duplicates is nonsensical.
    
    Bug: https://bugs.gentoo.org/891137
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 lib/portage/dep/dep_check.py              | 17 ++++++++++++++---
 lib/portage/tests/dep/test_overlap_dnf.py | 31 +++++++++++++++++++++++++------
 2 files changed, 39 insertions(+), 9 deletions(-)
Comment 6 Larry the Git Cow gentoo-dev 2024-02-22 07:24:15 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=77c44c46194922509bc4f2b5cfc099412a560a69

commit 77c44c46194922509bc4f2b5cfc099412a560a69
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-02-22 07:23:40 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-02-22 07:23:50 +0000

    sys-apps/portage: add 3.0.62
    
    Closes: https://bugs.gentoo.org/663324
    Closes: https://bugs.gentoo.org/728046
    Closes: https://bugs.gentoo.org/891137
    Closes: https://bugs.gentoo.org/906368
    Closes: https://bugs.gentoo.org/916566
    Closes: https://bugs.gentoo.org/921170
    Closes: https://bugs.gentoo.org/921208
    Closes: https://bugs.gentoo.org/921400
    Closes: https://bugs.gentoo.org/922038
    Closes: https://bugs.gentoo.org/922142
    Closes: https://bugs.gentoo.org/923368
    Closes: https://bugs.gentoo.org/923750
    Closes: https://bugs.gentoo.org/923841
    Closes: https://bugs.gentoo.org/923852
    Closes: https://bugs.gentoo.org/923854
    Closes: https://bugs.gentoo.org/924192
    Closes: https://bugs.gentoo.org/924273
    Closes: https://bugs.gentoo.org/924585
    Closes: https://bugs.gentoo.org/921380
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-apps/portage/Manifest              |   1 +
 sys-apps/portage/portage-3.0.62.ebuild | 246 +++++++++++++++++++++++++++++++++
 2 files changed, 247 insertions(+)