commit:     839ab46be1777e5886da28b98b53a462b992c5bf
Author:     Pin-yen Lin <treapking <AT> chromium <DOT> org>
AuthorDate: Fri Nov 25 03:36:27 2022 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Nov 28 00:37:41 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=839ab46b

Add caching to _slot_operator_check_reverse_dependencies

Add lru_cache to speed up the running time of "Calculating
dependencies".

In a ChromeOS use case, this patch decreases the running time from
311s to 197s with almost no memory usage increase.

Bug: https://bugs.gentoo.org/883071
Signed-off-by: Pin-yen Lin <treapking <AT> chromium.org>
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/_emerge/depgraph.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py
index bb0824324..d0ea92ad9 100644
--- a/lib/_emerge/depgraph.py
+++ b/lib/_emerge/depgraph.py
@@ -2240,6 +2240,7 @@ class depgraph:
 
         return None
 
+    @functools.lru_cache(maxsize=100)
     def _slot_operator_check_reverse_dependencies(
         self, existing_pkg, candidate_pkg, replacement_parent=None
     ):

Reply via email to