Skip to content

Unexpected allocations in radix sort #47474

Closed
@LilithHafner

Description

@LilithHafner

There should be two allocations, one as a scratch space for elements and one as a count vector. There are three:

julia> using BenchmarkTools

julia> v = rand(Int, 1000);

julia> @btime sort!(rand!($v));
21.259 μs (3 allocations: 10.16 KiB)

I tested this on 5dfd6c9 and current master and results are the same.

VSCode's @profview_allocs tracks the third allocation to the iteration in this line:

@inbounds for shift in 0:chunk_size:bits-1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions