Skip to content

Commit

Permalink
Merge branch 'nhd-method-macros' into nhd-default-values
Browse files Browse the repository at this point in the history
  • Loading branch information
NHDaly committed Jul 29, 2020
2 parents bfd2b8e + d40e470 commit 795eeea
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Salsa"
uuid = "1fbf2c77-44e2-4d5d-8131-0fa618a5c278"
authors = ["Nathan Daly <[email protected]>", "Todd J. Green <[email protected]>"]
version = "2.1.0"
version = "2.2.0"

[deps]
ExceptionUnwrapping = "460bff9d-24e4-43bc-9d9f-a8973cb893f4"
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ Running x_plus_one.
11
```

### Flags

For maximum performance in deployed software, you can disable all runtime assertions and debug code by setting this environment variable before building Salsa: `SALSA_STATIC_DEBUG=false`.

Or, for slightly less peformance gain, you can toggle it at runtime via `Salsa.Debug.disable_debug()`.


## Credits
This package was closely modelled off of the Rust
Expand Down
28 changes: 15 additions & 13 deletions src/inspect.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ function build_graph(rt::Salsa.Runtime; module_boxes=false)
println(io, "{")
println(io, "rank=sink;")
end
for (input_key, name) in inputs
println(io, """$(vertex_name(input_key)) [label="$name"]""")
for (input_key_func, name) in inputs
println(io, """$(vertex_name(input_key_func)) [label="$name"]""")
end
if !module_boxes
println(io, "}")
Expand All @@ -76,43 +76,45 @@ function build_graph(rt::Salsa.Runtime; module_boxes=false)
end

function _build_graph(io::IO, st::DefaultStorage, seen::_IdSet, modules_map::Dict, out_edges::Dict, out_inputs::Dict)
for ((F,k),v) in st.inputs_map
for (input_key,v) in st.inputs_map
F = key_function(input_key)
m = F.name.module
out_inputs[F] = "@input $(nameof(F.instance))"
push!(get!(modules_map, m, Set([])), F)
end

for (derived_key,derived_map) in st.derived_function_maps
_build_graph(io, st, derived_key, derived_map, seen, modules_map, out_edges)
for (derived_key_t,derived_map) in st.derived_function_maps
_build_graph(io, st, derived_key_t, derived_map, seen, modules_map, out_edges)
end
end

key_function(::Union{Salsa.InputKey{F}, Salsa.DerivedKey{F}}) where F = F
function vertex_name(::Salsa.InputKey{F}) where F
return vertex_name(F)
end
function vertex_name(x::Any)::String
return "v$(objectid(x))"
end

function _build_graph(io, st::DefaultStorage, derived_key::Salsa.DerivedKey{F,TT}, derived_map::Dict,
function _build_graph(io, st::DefaultStorage, derived_key_t::Type{<:Salsa.DerivedKey{F,TT}}, derived_map::Dict,
seen::_IdSet{Any}, modules_map::Dict{Module,Set}, edges::Dict{Pair, Int}) where {F,TT}
in(derived_key, seen) && return
push!(seen, derived_key)
in(derived_key_t, seen) && return
push!(seen, derived_key_t)
m = methods(F.instance).mt.module
push!(get!(modules_map, m, Set([])), derived_key)
key_str = _derived_key_as_call_str(derived_key)
println(io, "$(vertex_name(derived_key)) [shape=rect,label=\"$key_str\"]")
push!(get!(modules_map, m, Set([])), F)
key_str = _derived_key_as_call_str(derived_key_t)
println(io, "$(vertex_name(F)) [shape=rect,label=\"$key_str\"]")
for (k,v) in derived_map
for d in v.dependencies
edge = (derived_key) => (d.key)
edge = (F) => (key_function(d))
count = get!(edges, edge, 0) + 1
edges[edge] = count
end
end
#_build_graph(io, s.leaf_node, seen)
end

function _derived_key_as_call_str(key::Salsa.DerivedKey{F,TT})::String where {F,TT}
function _derived_key_as_call_str(::Type{<:Salsa.DerivedKey{F,TT}})::String where {F,TT}
f = isdefined(F, :instance) ? nameof(F.instance) : nameof(F)
argsexprs = [
:rt,
Expand Down

0 comments on commit 795eeea

Please sign in to comment.