JuliaLang/julia

Consider improving performance of rand! for view of BitArray

Open

#41,862 opened on Aug 11, 2021

View on GitHub
 (1 comment) (4 reactions) (0 assignees)Julia (5,773 forks)batch import
help wantedperformance

Repository metrics

Stars
 (48,709 stars)
PR merge metrics
 (Avg merge 20d 6h) (157 merged PRs in 30d)

Description

Currently the fast path for rand! is used only for BitArray but not for views of BitArray:

julia> x = falses(10^8);

julia> y = @view x[:];

julia> @time rand!(x);
  0.002921 seconds

julia> @time rand!(y);
  0.206912 seconds (1 allocation: 48 bytes)

I propose to add support for views also (it requires careful handling of view boundaries along the fastest changing dimension, but for large vectors this should be negligible overhead).

Contributor guide