Skip to content

High allocations in Zip() #564

@artemsolod

Description

@artemsolod

Zip(x, y) allocates a lot in a simple use case (foo). Zip(x) with a single argument seems ok.
System: julia 1.9.3, Transducers v0.4.78, Ubuntu

julia> using Transducers, BenchmarkTools

julia> foo(vals) = vals |> Zip(Map(identity), Map(identity)) |> collect
foo (generic function with 1 method)

julia> vals = collect(1:10_000);

julia> @btime foo($vals); # Zip(x, y)
  6.014 ms (150060 allocations: 5.22 MiB)

julia> foo1(vals) = vals |> Zip(Map(identity)) |> collect
foo1 (generic function with 1 method)

julia> @btime foo1($vals); # Zip(x)
  205.577 μs (17 allocations: 326.78 KiB)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions