Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes IntrusiveLinkedListSynchronized mutable to avoid allocation on poptask #1

Closed
wants to merge 1 commit into from

Conversation

andrebsguedes
Copy link
Owner

Currently poptask is allocating every time it calls into jl_task_get_next due to StickyWorkqueue (IntrusiveLinkedListSynchronized) being immutable and requiring an allocation to be used as Any on the ccall.

The allocations can be seen in the following snippet:

function work()
    done = 0.0
    l = Threads.SpinLock()
    Threads.@sync for _ in 1:(Threads.nthreads() / 2)
        Threads.@spawn begin
            v = 1.0
            for i in 1:(1<<33)
                v *= 1.0001
                if i % (1 << 13) == 0
                    yield()
                end
            end
            Base.@lock_nofail l done += v
        end
    end
    return done
end

julia> @time work()
 15.758794 seconds (5.03 M allocations: 153.523 MiB, 0.35% gc time)

Which after the change becomes:

julia> @time work()
 15.907513 seconds (67 allocations: 4.719 KiB)

@NHDaly
Copy link

NHDaly commented Aug 9, 2023

Ah, Nick pointed me to the upstream PR, which corresponds to this one: JuliaLang#50802

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants