Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Poor performance of sample with large source array #8703

@headius

Description

@headius

From https://bugs.ruby-lang.org/issues/13136.

When sampling more than 3 items from a large array (ten in the original issue because of how the C code is designed) performance of Array#sample can degrade. This is primarily because the fallback logic dups the original array and uses it as a temporary store while sampling elements.

The logic in JRuby largely mimics the CRuby logic, so the patch provided to fix the above issue should help us in the same way. It is more complex than I wanted to tackle while fixing up remaining failures for JRuby 10, and does not resolve any of them.

See the fix in ruby/ruby@2de1dbd.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions