Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 917660 - Regression in dependency resolution times for --emptytree
Summary: Regression in dependency resolution times for --emptytree
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Portage team
URL:
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks: 916977
  Show dependency tree
 
Reported: 2023-11-21 06:44 UTC by Sam James
Modified: 2024-01-20 18:28 UTC (History)
3 users (show)

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


Attachments
emerge -pev @world --usepkg=n --debug (xz-compressed) (debug.xz,422.54 KB, application/x-xz)
2023-11-21 07:08 UTC, Sam James
Details
emerge -pev @world --usepkg=n --debug (xz-compressed) (with revert) (debug_revert.xz,418.63 KB, application/x-xz)
2023-11-21 07:08 UTC, Sam James
Details
emerge --info (file_917660.txt,10.45 KB, text/plain)
2023-11-21 07:09 UTC, Sam James
Details

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-11-21 06:44:25 UTC
'emerge -pev @world --backtrack=0 --usepkg=n' seems to take a huge amount of time to complete here (dropping the backtrack and/or usepkg param doesn't make a difference).

This problem started recently, as in the past, it would take ~10s or so.

If I revert 9206d5a75ecd2d9ae0fe63e57d28aa8061b5927e ('find_smallest_cycle: Increase ignore_priority to find smaller cycles'), then it completes quickly again.
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-11-21 06:46:05 UTC
I haven't tried to analyse this (yet) with a profile or getting a backtrace or anything. I'm going to get the --debug output for both first.
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-11-21 07:08:09 UTC
Created attachment 875266 [details]
emerge -pev @world --usepkg=n --debug (xz-compressed)
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-11-21 07:08:28 UTC
Created attachment 875267 [details]
emerge -pev @world --usepkg=n --debug (xz-compressed) (with revert)
Comment 4 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-11-21 07:09:05 UTC
Created attachment 875268 [details]
emerge --info
Comment 5 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-11-21 07:12:02 UTC
(In reply to Sam James from comment #2)
> Created attachment 875266 [details]
> emerge -pev @world --usepkg=n --debug (xz-compressed)

This one took > 10 minutes, while the revert was done in seconds.
Comment 6 Zac Medico gentoo-dev 2023-11-21 17:20:42 UTC
Seems like we need to find some way to terminate the ignore_priority loop earlier than 9206d5a75ecd2d9ae0fe63e57d28aa8061b5927e does. With search terminating at len(smallest_cycle) == 1, it probably has to search through every ignore_priority quite often.
Comment 7 Zac Medico gentoo-dev 2023-11-21 18:16:38 UTC
We might make gather_deps abort early if the number of selected_nodes meets or exceeds the size of the current smallest_cycle.
Comment 8 Zac Medico gentoo-dev 2023-11-21 19:47:31 UTC
(In reply to Zac Medico from comment #7)
> We might make gather_deps abort early if the number of selected_nodes meets
> or exceeds the size of the current smallest_cycle.

That's what https://github.com/gentoo/portage/pull/1187 does, and on my laptop where emerge -pe @world takes about 10 minutes, with this patch it took about 43 seconds less than it did with portage-3.0.55.
Comment 9 Zac Medico gentoo-dev 2023-11-22 22:24:18 UTC
We'll have to revert the change from bug 917259 since it was not optimal and it was far too expensive. I've updated https://github.com/gentoo/portage/pull/1187 to include the revert.

On my laptop, this brings the emerge -pe @world time down to 3m40.081s, compared to 10m44.268s with portage-3.0.55.
Comment 10 Larry the Git Cow gentoo-dev 2023-11-25 06:30:19 UTC
The bug has been referenced in the following commit(s):

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

commit cdc781349337fa755bc15773e2a87e4b41f5ff1e
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2023-11-22 21:46:12 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2023-11-22 22:26:13 +0000

    Revert "find_smallest_cycle: Increase ignore_priority to find smaller cycles"
    
    This reverts commit 9206d5a75ecd2d9ae0fe63e57d28aa8061b5927e.
    The len(smallest_cycle) == 1 loop termination condition is
    not optimal and it's too expensive as reported in bug 917660.
    
    Bug: https://bugs.gentoo.org/917660
    Bug: https://bugs.gentoo.org/917259
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 lib/_emerge/depgraph.py                            |  7 +++----
 .../tests/resolver/test_alternatives_gzip.py       |  7 +++++--
 lib/portage/tests/resolver/test_merge_order.py     | 24 ++++++++++------------
 .../tests/resolver/test_rebuild_ghostscript.py     |  6 +++---
 4 files changed, 22 insertions(+), 22 deletions(-)