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

inference: represent callers_in_cycle with view slices of a stack instead of separate lists #55364

Merged
merged 2 commits into from
Aug 20, 2024

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented Aug 3, 2024

Inspired by Tarjan's SCC, this changes the recursion representation to use a single list instead of a linked-list + merged array of cycles. I have wanted to do this refactoring (from linked list to array) for a while.

@nanosoldier runbenchmarks(!"scalar", vs=":master")

@vtjnash vtjnash added the compiler:inference Type inference label Aug 3, 2024
@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here.

@vtjnash vtjnash force-pushed the jn/callers-in-cycle-stack branch 2 times, most recently from a9463b1 to 94310a3 Compare August 7, 2024 13:38
@vtjnash vtjnash requested a review from aviatesk August 7, 2024 18:02
@vtjnash vtjnash force-pushed the jn/callers-in-cycle-stack branch 2 times, most recently from ec605ec to c4b0b77 Compare August 20, 2024 02:04
Inspired by Tarjan's SCC, this changes the recursion representation to
use a single list instead of a linked-list + merged array of cycles.

Fix a doopt boolean that got apparently incorrectly flipped as long ago
as 5f10eb9, and then further
mis-propagated by later PRs until we were attempting to return objects
that were also being put into the cache, which is unsafe if the user
decides to mutate them later.
@aviatesk
Copy link
Member

@nanosoldier runbenchmarks("inference", vs=":master")

base/compiler/typeinfer.jl Outdated Show resolved Hide resolved
base/compiler/inferencestate.jl Outdated Show resolved Hide resolved
frame_parent(sv::IRInterpretationState) = sv.parentid == 0 ? nothing : (sv.callstack::Vector{AbsIntState})[sv.parentid]

# add the orphan child to the parent and the parent to the child
function assign_parentchild!(child::InferenceState, parent::AbsIntState)
Copy link
Member

Choose a reason for hiding this comment

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

Would it be safer to create a new constructor InferenceState(..., parent::AbsIntState) that internally calls assign_parentchild! and use it in IPO inference situations, rather than using assign_parentchild! individually in each case?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think eventually we may like to move this state into the AbstractInterpreter, since it doesn't properly belong to this InferenceState frame, but rather to the process as a whole. But some of it depends on whether and how we want to parallelize this process. For now, this was a more minimal change to eventually permit pause-able inference on a single thread.

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here.

@vtjnash vtjnash added the merge me PR is reviewed. Merge when all tests are passing label Aug 20, 2024
@vtjnash vtjnash merged commit 7b8dd90 into master Aug 20, 2024
5 of 8 checks passed
@vtjnash vtjnash deleted the jn/callers-in-cycle-stack branch August 20, 2024 20:07
@giordano giordano removed the merge me PR is reviewed. Merge when all tests are passing label Aug 23, 2024
KristofferC pushed a commit that referenced this pull request Sep 12, 2024
…tead of separate lists (#55364)

Inspired by Tarjan's SCC, this changes the recursion representation to
use a single list instead of a linked-list + merged array of cycles.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:inference Type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants