Re: [PATCH 1/3] Add caching to catpkgsplit function

Zac Medico <[email protected]>
Newsgroups gmane.linux.gentoo.portage.devel
Message-ID <[email protected]>
On 7/6/20 10:30 AM, Chun-Yu Shei wrote:
> I finally got a chance to try Sid's lru_cache suggestion, and the
> results were really good.  Simply adding it on catpkgsplit and moving
> the body of use_reduce into a separate function (that accepts tuples
> instead of unhashable lists/sets) and decorating it with lru_cache
> gets a similar 40% overall speedup for the upgrade case I tested.  It
> seems like even a relatively small cache size (1000 entries) gives
> quite a speedup, even though in the use_reduce case, the cache size
> eventually reaches almost 20,000 entries if no limit is set.  With
> these two changes, adding caching to match_from_list didn't seem to
> make much/any difference.

That's great!

> The catch is that lru_cache is only available in Python 3.2, so would
> it make sense to add a dummy lru_cache implementation for Python < 3.2
> that does nothing?  There is also a backports-functools-lru-cache
> package that's already available in the Portage tree, but that would
> add an additional external dependency.
> 
> I agree that refactoring could yield an even bigger gain, but
> hopefully this can be implemented as an interim solution to speed up
> the common emerge case of resolving upgrades.  I'm happy to submit new
> patches for this, if someone can suggest how to best handle the Python
> < 3.2 case. :)
> 
> Thanks,
> Chun-Yu

We can safely drop support for < Python 3.6 at this point. Alternatively
we could add a compatibility shim for Python 2.7 that does not perform
any caching, but I really don't think it's worth the trouble to support
it any longer.
-- 
Thanks,
Zac
signature.asc (application/pgp-signature, 981 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQKTBAEBCgB9FiEE8OgXaltWzqgSupCu0HX7jBBKPSAFAl8DZ4xfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldEYw
RTgxNzZBNUI1NkNFQTgxMkJBOTBBRUQwNzVGQjhDMTA0QTNEMjAACgkQ0HX7jBBK
PSABVA/+N7cRNL0LAN5Cz8mynVA1RS+xIiwcHjwMQa97TuvYub7tUknqSBUio4bp
STYEwvUgdtwWR8T6r1NmXhXriZeSRADjE+Qepg+9kV4OmgIfcFaXsFMFo2TwF4Zm
d5iNYQaH4GcrRVz+wor2uW6SyHPnBrs8ejK21m57bW015tP/IlIGpqDf648TpvVd
zmwpT3nnXGE+gAzRGF7U5bzX7UFeXWksXJMhXjwJG4yavb3EwcBaP/klfsYsp+vo
48gWa1OuwVtX91IsvnobndZaAwXQ03MrrLXqnw3tvBpSwwc9e8dsN8eep7KnSjKI
Z3JvE1G+c3z83Wq52Kx6dQw1nu5L28EeFpW/7uVY0ctH+A7CfM/2LUbDv3EgnMqq
P+rcIcmZJ5ETngSki4NzFRNxz89TszuoBf3NqpNjYGtTUSALVm9hRnfa5ViarX+F
EX89XhvEP83JYper2/IXJI1LRnrCUnsHo7UL/jclUFSBFid2fam2YttFqHwakOMM
5Q1JDyfoZBMMYnAxXb+gpmlvB7/JioOi274VI+rdti12j8SnFymnboOcc3q3qsCo
s5ciuTcixYcYAKTCUlOkzyVilzUl25EgKgQrNsPnW9TL2An1ZJyEAMK2uQxNd7/+
+y9/nKLaYF4veJW5YLIT8IXNSLZUguHe10S0rfqsdHP6iPYfKeo=
=PsH5
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.