JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.76k stars 5.49k forks source link

`with_logger(NullLogger())` allocates in v1.11 #55761

Open rfourquet opened 2 months ago

rfourquet commented 2 months ago

This is a regression from v1.10, but OK to close if considered normal.

julia> using Logging; f() = with_logger(NullLogger()) do
           @debug "f"
       end

julia> @allocations f(); @allocations f()
8 # was 0 on v1.10

NullLogger() was useful to make logging macros essentially free when not used. A workaround is to use Logging.disable_logging(Logging.Debug).

nsajko commented 2 months ago

Caused by #53584.

EdsterG commented 2 months ago

Number of allocations seems to grow with the number of calls to @debug.

julia> using Logging; f() = with_logger(NullLogger()) do
            for i=1:100
               @debug "f"
            end
       end

julia> @allocations f(); @allocations f()
206  # is 0 on v1.10