From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id D8F43158008 for ; Fri, 16 Jun 2023 12:07:49 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 49420E0917; Fri, 16 Jun 2023 12:07:45 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id EE4E6E08FE for ; Fri, 16 Jun 2023 12:07:44 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-dev@lists.gentoo.org Cc: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-dev] [PATCH 0/5] cargo.eclass: optimizations Date: Fri, 16 Jun 2023 14:01:03 +0200 Message-ID: <20230616120739.8656-1-mgorny@gentoo.org> X-Mailer: git-send-email 2.41.0 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: 49c99814-7c33-4b79-a38c-0482d876c4bd X-Archives-Hash: 7339987a1e9745fd9cdf5c3b0fca6ee5 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