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

Effects-tune PersitentDict #52954

Merged
merged 1 commit into from
Jan 19, 2024
Merged

Effects-tune PersitentDict #52954

merged 1 commit into from
Jan 19, 2024

Conversation

Keno
Copy link
Member

@Keno Keno commented Jan 18, 2024

To in particular allow elimination of dead PersistentDict constructions.

@Keno Keno requested review from vchuravy and aviatesk January 18, 2024 07:05
@staticfloat
Copy link
Member

Looks like this has a legitimate test failure:

Error in testset arrayops:
Error During Test at /cache/build/tester-amdci5-9/julialang/julia-master/julia-3450b734e0/share/julia/test/arrayops.jl:444
  Got exception outside of a @test
  BoundsError: attempt to access 3-element Vector{Int64} at index [0]

@Keno
Copy link
Member Author

Keno commented Jan 18, 2024

Yeah, that's an embarrassing copy-paste-typo in the _noub_meta, which accidentally turned on nothrow.

To in particular allow elimination of dead PersistentDict constructions.
@Keno Keno merged commit 63188d5 into master Jan 19, 2024
6 of 7 checks passed
@Keno Keno deleted the kf/tunepd branch January 19, 2024 23:30
trie = dict.trie
h = HAMT.HashState(key)
found, present, trie, i, bi, top, hs = HAMT.path(trie, key, h, #=persistent=# true)
HAMT.insert!(found, present, trie, i, bi, hs, val)
return new{K, V}(top)
end
@noinline function KeyValue.set(dict::PersistentDict{K, V}, key) where {K, V}
@noinline @Base.assume_effects :nothrow :effect_free function KeyValue.set(dict::PersistentDict{K, V}, key::K, val::V) where {K, V}
Copy link
Member

Choose a reason for hiding this comment

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

Upon further investigation, it appears that modifying this single line is enough to remove the call to the dead PersistentDict constructor. But, this seems to stem from an inference bug, where we're deleting statements without actually proving terminates.

julia> @noinline Base.@assume_effects :effect_free :nothrow function foo(n)
           s = 0
           while true
               if n - rand(1:10) > 0
                   s += 1
               else
                   break
               end
           end
           return s
       end^C

julia> code_typed((Int,)) do n
           foo(n)
           nothing
       end
1-element Vector{Any}:
 CodeInfo(
1return Main.nothing
) => Nothing

So, I'd like to address this bug first and then revisit this PR.

topolarity pushed a commit that referenced this pull request Jan 31, 2024
To in particular allow elimination of dead PersistentDict constructions.
aviatesk added a commit that referenced this pull request Apr 15, 2024
Fixes #52991.
Currently this commit marks the test case added in #52954 as `broken`
since it has relied on the behavior of #52991.
I'm planning to add followup changes in a separate commit.
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.

3 participants