"Nightly" allocates but 1.6 doesn't

In KeywordCalls.jl we have some tests like this:

 @testset "No Allocation" begin
            @test 0 == @ballocated f(a=1, b=2, c=3)
            @test 0 == @ballocated f((a=1, b=2, c=3))
            @test 0 == @ballocated Foo((b=1,a=2))
            @test 0 == @ballocated g(a=1, b=2)
            @test 0 == @ballocated g((a=1, b=2))
            @test 0 == @ballocated g(a=1, b=2, c=3)
            @test 0 == @ballocated g((a=1, b=2, c=3))
            @test 0 == @ballocated f(alpha=1,b=2,c=3)
            @test 0 == @ballocated g(beta=1, alpha=3)
        end

These are passing in 1.6 but failing in the nightly build. Details here.

Are others seeing this kind of thing as well? Is it significant, or just a matter of the nightly builds being incomplete?

2 Likes

I would report this. Are they also failing on 1.7-beta?

1 Like

Yes, tests fail on 1.7-beta :frowning:

Update: I opened this issue. The only (very small) allocation is here:

No Allocation: Test Failed at /home/chad/git/KeywordCalls.jl/test/runtests.jl:66
  Expression: 0 == #= /home/chad/git/KeywordCalls.jl/test/runtests.jl:66 =# @ballocated(Foo((b = 1, a = 2)))
   Evaluated: 0 == 32

@jeff.bezanson responded,

This is interesting: @allocated gives 0; @ballocated gives 32. It can be difficult to exclude 100% of allocations that may happen around testing something.

Also code_llvm confirms there are no heap allocations in the generated code.

And @jameson pointed out,

We changed the @allocated macro in v1.7 to attempt to be a bit more reliable and consistent–though possibly not actually a more useful number

I’ll mark this as solved now, please follow the Github issue for more information.

1 Like