Skip to content

Performance regression when using FunctionWrappers on Julia 1.4 and 1.5 #36977

@rdeits

Description

@rdeits

Copied from: https://discourse.julialang.org/t/performance-and-memory-regression-with-function-wrappers-in-julia-1-4/44589

Setup:

julia> using BenchmarkTools

julia> using FunctionWrappers: FunctionWrapper

julia> w = let closed_over=([1], [2])
         FunctionWrapper{typeof(closed_over), Tuple{}}(() -> closed_over)
       end;

Results

Julia 1.3.1:

julia> @btime $w()
  5.435 ns (0 allocations: 0 bytes)

Julia 1.4.2:

julia> @btime $w()
  9.919 ns (1 allocation: 16 bytes)

Julia 1.5.0

julia> @btime $w()
  10.112 ns (1 allocation: 32 bytes)

Julia 1.6.0-DEV.607

julia> @btime $w()
  11.846 ns (1 allocation: 32 bytes)

This turns out to be the source of a significant performance regression in Parametron.jl (which was designed to allocate zero memory).

Here's my system info:

julia> versioninfo()
Julia Version 1.5.0
Commit 96786e22cc (2020-08-01 23:44 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, skylake)

@yuyichao pointed to JuliaLang/FunctionWrappers.jl#14 as a related issue. I cannot reproduce the MWE from JuliaLang/FunctionWrappers.jl#14 (comment) on Julia 1.5, but the slowness and extra allocation of my example here is still present in Julia 1.5.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceMust go fasterregressionRegression in behavior compared to a previous version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions