• [gentoo-dev] [PATCH 01/11] ruby-ng.eclass: optimize: use pattern for ol

    From Sam James@21:1/5 to All on Thu Jun 15 18:00:01 2023
    Not much improvement on a grand scale, but for dev-ruby/sinatra at least, we get:
    ```
    $ pk pkg source $(pkg) --repo ~/g/ --bench 5s # before dev-ruby/sinatra-3.0.5::/home/sam/g/: mean: 76.25ms, min: 59.23ms, max: 83.674ms, σ = 4.247ms, N = 66
    dev-ruby/sinatra-3.0.5-r1::/home/sam/g/: mean: 77.465ms, min: 61.782ms, max: 85.127ms, σ = 3.592ms, N = 65
    dev-ruby/sinatra-3.0.6::/home/sam/g/: mean: 80.192ms, min: 60.922ms, max: 84.951ms, σ = 3.899ms, N = 63
    dev-ruby/sinatra-2.2.3::/home/sam/g/: mean: 80.389ms, min: 56.818ms, max: 86.915ms, σ = 4.508ms, N = 63

    $ pk pkg source $(pkg) --repo ~/g/ --bench 5s # after dev-ruby/sinatra-3.0.6::/home/sam/g/: mean: 72.761ms, min: 58.627ms, max: 76.161ms, σ = 3.276ms, N = 69
    dev-ruby/sinatra-3.0.5-r1::/home/sam/g/: mean: 72.967ms, min: 60.127ms, max: 76.75ms, σ = 3.176ms, N = 69
    dev-ruby/sinatra-3.0.5::/home/sam/g/: mean: 69.004ms, min: 58.344ms, max: 73.661ms, σ = 3.3ms, N = 73
    dev-ruby/sinatra-2.2.3::/home/sam/g/: mean: 71.061ms, min: 55.144ms, max: 74.563ms, σ = 3.848ms, N = 71
    ```

    A tiny, but seemingly consistent improvement.

    Thanks to mgorny for the idea.

    Bug: https://bugs.gentoo.org/908465
    Signed-off-by: Sam James <sam@gentoo.org>
    ---
    eclass/ruby-ng.eclass | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    diff --git a/eclass/ruby-ng.eclass b/eclass/ruby-ng.eclass
    index 8befa086ef020..5a6edb1bf6080 100644
    --- a/eclass/ruby-ng.eclass
    +++ b/eclass/ruby-ng.eclass
    @@ -107,7 +107,7 @@ _ruby_get_all_impls() {
    for i in ${USE_RUBY}; do
    case ${i} in
    # removed implementations
    - ruby19|ruby20|ruby21|ruby22|ruby23|ruby24|ruby25|ruby26|ruby27|jruby)
    + ruby19|ruby2[0-7]|jruby)
    ;;
    *)
    found_valid_impl=1
    --
    2.41.0

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sam James@21:1/5 to All on Thu Jun 15 18:00:01 2023
    Packages may try to restrict their test dependencies to ease bootstrapping/porting
    if they're not yet available for a newer Ruby implementation by setting USE_RUBY="<some subset of original USE_RUBY>" ruby_add_bdepend ...

    For example, dev-ruby/parallel does:
    ```
    # Rails isn't yet ruby32-ready in Gentoo
    USE_RUBY="ruby27 ruby30 ruby31" ruby_add_bdepend "
    test? ( dev-ruby/activerecord[sqlite] )
    ```

    This isn't ideal, but we don't have a ruby_gen_cond_dep right now, so
    cater to this usecase by invalidating the caches we've previously added
    if we've detected USE_RUBY changed.

    Signed-off-by: Sam James <sam@gentoo.org>
    ---
    eclass/ruby-ng.eclass | 40 ++++++++++++++++++++++++++++++++++++----
    1 file changed, 36 insertions(+), 4 deletions(-)

    diff --git a/eclass/ruby-ng.eclass b/eclass/ruby-ng.eclass
    index 3269ed52cafe0..14f4414337d6f 100644
    --- a/eclass/ruby-ng.eclass
    +++ b/eclass/ruby-ng.eclass
    @@ -102,8 +102,9 @@ ruby_implementation_depend() {
    # @DESCRIPTION:
    # Return a list of valid implementations in USE_RUBY, skipping the old
    # implementations that are no longer supported.
    -_RUBY_GET_ALL_IMPLS=()
    _ruby_get_all_impls() {
    + _RUBY_GET_ALL_IMPLS=()
    +
    local i found_valid_impl
    for i in ${USE_RUBY}; do
    case ${i} in
    @@ -132,6 +133,8 @@ _ruby_get_all_impls() {
    ruby_samelib() {
    debug-print-function ${FUNCNAME} "${@}"

    + _ruby_set_globals_invalidate_if_stale
    +
    local res=
    for _ruby_implementation in "${_RUBY_GET_ALL_IMPLS[@]}"; do
    has -${_ruby_implementation} $@ || \
    @@ -176,6 +179,7 @@ _ruby_atoms_samelib() {
    atoms+=" ) "
    eshopts_pop

    + _ruby_set_globals_invalidate_if_stale
  • From Sam James@21:1/5 to All on Thu Jun 15 18:00:01 2023
    I don't see us adding a non-ruby* target any time soon so this should be fine.

    Signed-off-by: Sam James <sam@gentoo.org>
    ---
    eclass/ruby-ng.eclass | 3 +++
    1 file changed, 3 insertions(+)

    diff --git a/eclass/ruby-ng.eclass b/eclass/ruby-ng.eclass
    index 8fe26057e7ffe..043e3eefcbd68 100644
    --- a/eclass/ruby-ng.eclass
    +++ b/eclass/ruby-ng.eclass
    @@ -105,6 +105,8 @@ ruby_implementation_depend() {
    _ruby_get_all_impls() {
    _RUBY_GET_ALL_IMPLS=()

    + # XXX: Please update _ruby_get_use_targets if adding a non-'ruby*'
    + # target.
    local i found_valid_impl
    for i in ${USE_RUBY}; do
    case ${i} in
    @@ -350,6 +352,7 @@ _ruby_get_use_targets() {
    _ruby_set_globals_invalidate_if_stale

    local impls="${_RUBY_GET_ALL_IMPLS[@]}"
    + # XXX: This assumes all targets begin with 'ruby'.
    _RUBY_GET_USE_TARGETS="${impls//ruby/ruby_targets_ruby}"
    }

    --
    2.41.0

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sam James@21:1/5 to All on Thu Jun 15 18:00:01 2023
    - Inline ruby_atoms_samelib (only used by one caller)
    - Avoid repeated (subshell) calls to _ruby_atoms_samelib_generic by using a result
    variable instead.

    We go from 3.5s -> 2.5s to source dev-ruby/*.

    Thanks to mgorny for the ideas here.

    Bug: https://bugs.gentoo.org/908465
    Signed-off-by: Sam James <sam@gentoo.org>
    ---
    eclass/ruby-ng.eclass | 57 ++++++++++++++++++++++---------------------
    1 file changed, 29 insertions(+), 28 deletions(-)

    diff --git a/eclass/ruby-ng.eclass b/eclass/ruby-ng.eclass
    index ee2e6b89edb41..cf66fcec2f05d 100644
    --- a/eclass/ruby-ng.eclass
    +++ b/eclass/ruby-ng.eclass
    @@ -141,23 +141,6 @@ ruby_samelib() {
    echo "[${res%,}]"
    }

    -_ruby_atoms_samelib_generic() {
    - eshopts_push -o noglob
    - echo "RUBYTARGET? ("
    - for token in $*; do
    - case "$token" in
    - "||" | "(" | ")" | *"?")
    - echo "${token}" ;;
    - *])
    - echo "${token%[*}[RUBYTARGET(-),${token/*[}" ;; - *)
    - echo "${token}[RUBYTARGET(-)]" ;;
    - esac
    - done
    - echo ")"
    - eshopts_pop
    -}
    -
    # @FUNCTION: ruby_implementation_command
    # @RETURN: the path to the given ruby implementation
    # @DESCRIPTION:
    @@ -173,11 +156,29 @@ ruby_implementation_command() {
    echo $(type -p ${_ruby_name} 2>/dev/null)
    }

    +_RUBY_ATOMS_SAMELIB_RESULT=""
    _ruby_atoms_samelib() {
    - local atoms=$(_ruby_atoms_samelib_gene
  • From Sam James@21:1/5 to All on Thu Jun 15 18:00:01 2023
    Signed-off-by: Sam James <sam@gentoo.org>
    ---
    eclass/ruby-ng.eclass | 4 ++--
    1 file changed, 2 insertions(+), 2 deletions(-)

    diff --git a/eclass/ruby-ng.eclass b/eclass/ruby-ng.eclass
    index b20c3b4629155..f10c987ac44a7 100644
    --- a/eclass/ruby-ng.eclass
    +++ b/eclass/ruby-ng.eclass
    @@ -392,7 +392,7 @@ fi

    _ruby_invoke_environment() {
    old_S=${S}
    - if [ -z "${RUBY_S}" ]; then
    + if [[ -z ${RUBY_S} ]]; then
    sub_S=${P}
    else
    sub_S=${RUBY_S}
    @@ -728,7 +728,7 @@ ruby-ng_rspec() {

    # Explicitly pass the expected spec directory since the versioned
    # rspec wrappers don't handle this automatically.
    - if [ ${#@} -eq 0 ]; then
    + if [[ $# -eq 0 ]]; then
    files="spec"
    fi

    --
    2.41.0

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sam James@21:1/5 to All on Thu Jun 15 18:00:01 2023
    ulm points out that estack.eclass is particularly inefficient (although
    it'll get slightly better once https://github.com/gentoo/gentoo/pull/31437
    is fixed).

    Let's just manually roll it like llvm.eclass does.

    Bug: https://bugs.gentoo.org/908465
    Signed-off-by: Sam James <sam@gentoo.org>
    ---
    eclass/ruby-ng.eclass | 5 +++--
    1 file changed, 3 insertions(+), 2 deletions(-)

    diff --git a/eclass/ruby-ng.eclass b/eclass/ruby-ng.eclass
    index 14f4414337d6f..8fe26057e7ffe 100644
    --- a/eclass/ruby-ng.eclass
    +++ b/eclass/ruby-ng.eclass
    @@ -163,7 +163,8 @@ _RUBY_ATOMS_SAMELIB_RESULT=""
    _ruby_atoms_samelib() {
    _RUBY_ATOMS_SAMELIB_RESULT=""

    - eshopts_push -o noglob
    + local shopt_save=$(shopt -p -o noglob)
    + set -f
    local token
    local atoms=" RUBYTARGET? ("
    for token in $*; do
    @@ -177,7 +178,7 @@ _ruby_atoms_samelib() {
    esac
    done
    atoms+=" ) "
    - eshopts_pop
    + ${shopt_save}

    _ruby_set_globals_invalidate_if_stale
    local _ruby_implementation
    --
    2.41.0

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Petr =?utf-8?B?VmFuxJtr?=@21:1/5 to Sam James on Thu Jun 15 18:30:01 2023
    On Thu, Jun 15, 2023 at 04:52:37PM +0100, Sam James wrote:
    ulm points out that estack.eclass is particularly inefficient (although
    it'll get slightly better once https://github.com/gentoo/gentoo/pull/31437
    is fixed).

    Let's just manually roll it like llvm.eclass does.

    Bug: https://bugs.gentoo.org/908465
    Signed-off-by: Sam James <sam@gentoo.org>
    ---
    eclass/ruby-ng.eclass | 5 +++--
    1 file changed, 3 insertions(+), 2 deletions(-)

    diff --git a/eclass/ruby-ng.eclass b/eclass/ruby-ng.eclass
    index 14f4414337d6f..8fe26057e7ffe 100644
    --- a/eclass/ruby-ng.eclass
    +++ b/eclass/ruby-ng.eclass
    @@ -163,7 +163,8 @@ _RUBY_ATOMS_SAMELIB_RESULT=""
    _ruby_atoms_samelib() {
    _RUBY_ATOMS_SAMELIB_RESULT=""

    - eshopts_push -o noglob
    + local shopt_save=$(shopt -p -o noglob)
    ^~~~~~~~
    Wrong indentation - expanded tab instead of tab
    + set -f
    local token
    local atoms=" RUBYTARGET? ("
    for token in $*; do
    @@ -177,7 +178,7 @@ _ruby_atoms_samelib() {
    esac
    done
    atoms+=" ) "
    - eshopts_pop
    + ${shopt_save}

    _ruby_set_globals_invalidate_if_stale
    local _ruby_implementation
    --
    2.41.0



    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Hans de Graaff@21:1/5 to Sam James on Thu Jun 15 20:10:01 2023
    On Thu, 1970-01-01 at 00:00 +0000, Sam James wrote:
    ulm points out that estack.eclass is particularly inefficient
    (although
    it'll get slightly better once
    https://github.com/gentoo/gentoo/pull/31437
    is fixed).

    Let's just manually roll it like llvm.eclass does.

    It looks like that was the only use for inhering estack? If so that
    inherit can go too, right?

    Hans

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Hans de Graaff@21:1/5 to Sam James on Thu Jun 15 20:10:01 2023
    On Thu, 1970-01-01 at 00:00 +0000, Sam James wrote:
    Not much improvement on a grand scale, but for dev-ruby/sinatra at
    least, we get:

    Reviewed all patches and they look good to me.

    Thanks!

    Hans

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sam James@21:1/5 to arkamar@atlas.cz on Thu Jun 15 23:20:01 2023
    Petr Vaněk <arkamar@atlas.cz> writes:

    On Thu, Jun 15, 2023 at 04:52:37PM +0100, Sam James wrote:
    ulm points out that estack.eclass is particularly inefficient (although
    it'll get slightly better once https://github.com/gentoo/gentoo/pull/31437 >> is fixed).

    Let's just manually roll it like llvm.eclass does.

    Bug: https://bugs.gentoo.org/908465
    Signed-off-by: Sam James <sam@gentoo.org>
    ---
    eclass/ruby-ng.eclass | 5 +++--
    1 file changed, 3 insertions(+), 2 deletions(-)

    diff --git a/eclass/ruby-ng.eclass b/eclass/ruby-ng.eclass
    index 14f4414337d6f..8fe26057e7ffe 100644
    --- a/eclass/ruby-ng.eclass
    +++ b/eclass/ruby-ng.eclass
    @@ -163,7 +163,8 @@ _RUBY_ATOMS_SAMELIB_RESULT=""
    _ruby_atoms_samelib() {
    _RUBY_ATOMS_SAMELIB_RESULT=""

    - eshopts_push -o noglob
    + local shopt_save=$(shopt -p -o noglob)
    ^~~~~~~~
    Wrong indentation - expanded tab instead of tab
    + set -f

    Thanks!

    --=-=-Content-Type: application/pgp-signature; name="signature.asc"

    -----BEGIN PGP SIGNATURE-----

    iOUEARYKAI0WIQQlpruI3Zt2TGtVQcJzhAn1IN+RkAUCZIt+4l8UgAAAAAAuAChp c3N1ZXItZnByQG5vdGF0aW9ucy5vcGVucGdwLmZpZnRoaG9yc2VtYW4ubmV0MjVB NkJCODhERDlCNzY0QzZCNTU0MUMyNzM4NDA5RjUyMERGOTE5MA8cc2FtQGdlbnRv by5vcmcACgkQc4QJ9SDfkZD0HgEAlB2khzTalJ/pFkMtuIikG4LQGHcP3XSqD293 cst3TREA/3MpR/ZjH5EFb33FAdKbNmN/hAsg7T8XhAGp72ttsH0K
    Údx
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sam James@21:1/5 to Hans de Graaff on Thu Jun 15 23:20:01 2023
    Hans de Graaff <graaff@gentoo.org> writes:

    On Thu, 1970-01-01 at 00:00 +0000, Sam James wrote:
    Not much improvement on a grand scale, but for dev-ruby/sinatra at
    least, we get:

    Reviewed all patches and they look good to me.

    Thanks!

    And thank you!


    Hans

    best,
    sam

    -----BEGIN PGP SIGNATURE-----

    iOUEARYKAI0WIQQlpruI3Zt2TGtVQcJzhAn1IN+RkAUCZIt+y18UgAAAAAAuAChp c3N1ZXItZnByQG5vdGF0aW9ucy5vcGVucGdwLmZpZnRoaG9yc2VtYW4ubmV0MjVB NkJCODhERDlCNzY0QzZCNTU0MUMyNzM4NDA5RjUyMERGOTE5MA8cc2FtQGdlbnRv by5vcmcACgkQc4QJ9SDfkZChnAD/dBmur5zB+wLiblGN+5RmkEol+N4nuSy6uUGk rw+ouCoBALSvLWZjWKNc2Z1h7J7fmXy/8wOLnG3eKipdokKKDXwO
    =XpH1
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sam James@21:1/5 to Hans de Graaff on Thu Jun 15 23:20:01 2023
    Hans de Graaff <graaff@gentoo.org> writes:

    On Thu, 1970-01-01 at 00:00 +0000, Sam James wrote:
    ulm points out that estack.eclass is particularly inefficient
    (although
    it'll get slightly better once
    https://github.com/gentoo/gentoo/pull/31437
    is fixed).

    Let's just manually roll it like llvm.eclass does.

    It looks like that was the only use for inhering estack? If so that
    inherit can go too, right?

    Good spot - thanks!

    Hans

    best,
    sam

    --=-=-Content-Type: application/pgp-signature; name="signature.asc"

    -----BEGIN PGP SIGNATURE-----

    iOUEARYKAI0WIQQlpruI3Zt2TGtVQcJzhAn1IN+RkAUCZIt+d18UgAAAAAAuAChp c3N1ZXItZnByQG5vdGF0aW9ucy5vcGVucGdwLmZpZnRoaG9yc2VtYW4ubmV0MjVB NkJCODhERDlCNzY0QzZCNTU0MUMyNzM4NDA5RjUyMERGOTE5MA8cc2FtQGdlbnRv by5vcmcACgkQc4QJ9SDfkZAo3AEA+hQJeD32O4x7HIk2+9JV6Y9ud8G9n53WJng3 t/cGpXoA+gNVZLz8n9gEw3pFGw5i44MlIBxwen3FtFo5KjOAiUIO
    =vZ9+
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)