Skip to content

Commit

Permalink
Merge pull request #17542 from JuliaLang/jn/dump
Browse files Browse the repository at this point in the history
remove serializer dump lock
  • Loading branch information
JeffBezanson authored Jul 22, 2016
2 parents 21f28c9 + 59e38cc commit f13719e
Show file tree
Hide file tree
Showing 3 changed files with 365 additions and 342 deletions.
2 changes: 1 addition & 1 deletion base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ end

module_uuid(m::Module) = ccall(:jl_module_uuid, UInt64, (Any,), m)

isvalid_cache_header(f::IOStream) = 0 != ccall(:jl_deserialize_verify_header, Cint, (Ptr{Void},), f.ios)
isvalid_cache_header(f::IOStream) = 0 != ccall(:jl_read_verify_header, Cint, (Ptr{Void},), f.ios)

function cache_dependencies(f::IO)
modules = Tuple{Symbol,UInt64}[]
Expand Down
33 changes: 27 additions & 6 deletions doc/devdocs/locks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ The following strategies are used to ensure that the code is dead-lock free

3. avoid constructs that expect to need unrestricted recursion


Locks
-----

Below are all of the locks that exist in the system and the mechanisms
for using them that avoid the potential for deadlocks (no Ostrich algorithm allowed here):

Expand All @@ -38,10 +42,9 @@ The following are definitely leaf locks (level 1), and must not try to acquire a

The following is a leaf lock (level 2), and only acquires level 1 locks (safepoint) internally:

* dump (this lock may be possible to eliminate by storing the state on the stack)
* typecache

The following are level 3 locks, which can only acquire level 1 or level 2 locks internally:
The following is a level 3 lock, which can only acquire level 1 or level 2 locks internally:

* Method->writelock

Expand Down Expand Up @@ -81,9 +84,10 @@ The following is the root lock, meaning no other lock shall be held when trying
additionally, it's unclear if *any* code can safely run in parallel with an arbitrary toplevel expression,
so it may require all threads to get to a safepoint first

Broken Locks
------------

The following locks are broken:
-------------------------------

* toplevel

Expand Down Expand Up @@ -121,8 +125,25 @@ The following locks are broken:
fix: lock for ``apply_type`` / global (level 2?)


* dump
Shared Global Data Structures
-----------------------------

These data structures each need locks due to being shared mutable global state.
It is the inverse list for the above lock priority list.
This list does not include level 1 leaf resources due to their simplicity.

MethodTable modifications (def, cache, kwsorter type) : MethodTable->writelock

Type declarations : toplevel lock

Type application : typecache lock

Module serializer : toplevel lock

JIT : codegen lock

may be able to eliminate this by making the state thread-local
LLVMContext : codegen lock

might also need to ensure that incremental deserialize has a toplevel expression lock
Method : Method->writelock
- roots array (serializer and codegen)
- invoke / specializations / tfunc modifications
Loading

0 comments on commit f13719e

Please sign in to comment.