Skip to content

Precompilation: Try adding failsafe against deadlocks #2058

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

Conversation

IanButterworth
Copy link
Member

@IanButterworth IanButterworth commented Sep 30, 2020

As discussed in #2057 it'd be good if deadlocks weren't possible.

This does two things:

  • Assert that all deps of the entries in a manifest are themselves entries in the Manifest (if not, that would've deadlocked)
  • As a more general unknown deadlock avoidance, allow each task to skip waiting for a dep if the precomp tasks have been idle for >~250ms

@@ -939,29 +939,34 @@ function precompile(ctx::Context; internal_call::Bool=false)
]
end

was_processed = Dict{Base.PkgId,Base.Event}()
was_processed = Dict{Base.PkgId,Bool}()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this PR, was_processed Events are just being used for their underlying Bool, so I just switched it to a Bool

@IanButterworth
Copy link
Member Author

I tried deleting an ColorTypes from the env Manifest that another package depended on, and it was caught by Context(), so the @assert isn't needed

julia> Pkg.precompile()
ERROR: `ColorVectorSpace=c3611d14-8923-5661-9e6a-0046d554d3a4` depends on `ColorTypes`, but no such entry exists in the manifest.
Stacktrace:
  [1] pkgerror(::String, ::Vararg{String, N} where N)
    @ Pkg.Types ~/Documents/GitHub/Pkg.jl/src/Types.jl:52
  [2] normalize_deps(name::String, uuid::Base.UUID, deps::Vector{String}, manifest::Dict{String, Vector{Pkg.Types.Stage1}})
    @ Pkg.Types ~/Documents/GitHub/Pkg.jl/src/manifest.jl:95
  [3] validate_manifest(stage1::Dict{String, Vector{Pkg.Types.Stage1}})
    @ Pkg.Types ~/Documents/GitHub/Pkg.jl/src/manifest.jl:109
  [4] Dict{Base.UUID, Pkg.Types.PackageEntry}(raw::Dict{String, Any})
    @ Pkg.Types ~/Documents/GitHub/Pkg.jl/src/manifest.jl:158
  [5] read_manifest(f_or_io::String)
    @ Pkg.Types ~/Documents/GitHub/Pkg.jl/src/manifest.jl:170
  [6] Pkg.Types.EnvCache(env::Nothing)
    @ Pkg.Types ~/Documents/GitHub/Pkg.jl/src/Types.jl:294
  [7] EnvCache
    @ ~/Documents/GitHub/Pkg.jl/src/Types.jl:274 [inlined]
  [8] Pkg.Types.Context()
    @ Pkg.Types ./util.jl:442
  [9] #precompile#195
    @ ~/Documents/GitHub/Pkg.jl/src/API.jl:913 [inlined]
 [10] precompile
    @ ~/Documents/GitHub/Pkg.jl/src/API.jl:913 [inlined]

I'm also going off the approach in this PR.. it does away with a fair amount of elegance, and increases the no-op about 10-20%..
I'm going to mark this draft and try to figure out how the #2057 deadlock is happening..

@IanButterworth IanButterworth marked this pull request as draft September 30, 2020 23:42
@IanButterworth
Copy link
Member Author

Not needed anymore. precompile guards against circular deps, and we haven't seen any other deadlocks being reported

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.

1 participant