Hi, cargo.eclass is one of the slowest eclasses in ::gentoo, and does some pretty heavy processing in global scope. Here's a series of patches to optimize its behavior.
Unfortunately, the optimizations cannot be done without changing the API. However, the series preserves backwards compatibility -- existing ebuilds will simply remain slower. The two main changes are: 1. Replacing subshell-based `$(cargo_crate_uris)` with global variable `${CARGO_CRATE_URIS}`. This requires that `CRATES` and `GIT_CRATES` are defined prior to inherit -- this was already the case for the former, and only one case of `GIT_CRATES` does not conform. If they're not, then the variable will simply be empty but the old function will still work. 2. Supporting separate crate names from versions using a forward slash rather than a hyphen. This makes it possible to parse the crate list using a simple cutting rather than regular expressions. Again, existing syntax continues working but it remains much slower. To compare, the initial timings for the eclass give, using the 52 CRATES from dev-python/cryptography: real 252 it/s user 289 it/s While the timings for fully optimized form (using variable and slashes) give: real 952 it/s user 952 it/s -- Best regards, Michał Górny Michał Górny (5): eclass/tests: Add a minimal benchmark for cargo.eclass cargo.eclass: Add variable alternative to $(cargo_crate_uris) cargo.eclass: Optimize GIT_CRATES check cargo.eclass: Support separating crate names/versions via slash cargo.eclass: Mark GIT_CRATES as pre-inherit eclass/cargo.eclass | 127 ++++++++++++++++++++++-------------- eclass/tests/cargo-bench.sh | 114 ++++++++++++++++++++++++++++++++ 2 files changed, 192 insertions(+), 49 deletions(-) create mode 100755 eclass/tests/cargo-bench.sh -- 2.41.0