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

Allow Cassette (et al.) to participate in backedge system #32237

Merged
merged 1 commit into from
Jun 10, 2019

Conversation

Keno
Copy link
Member

@Keno Keno commented Jun 3, 2019

I'm looking into solving the long-standing backedge issue for Cassette
(where the overdubbed functions don't get invalidated if the function
they are transforming gets invalidated). I figured the best place to start
would a test that shows the issue and a minimal attempt at a fix. I may
very well be using the wrong object to attach the backedge here, but it's
a working starting point.

@vtjnash still needs to tell me what the correct way to do this is.

@Keno Keno requested a review from vtjnash June 3, 2019 21:57
Core.println(edges === nothing)
Core.println(edges)
Core.println(typeof(edges))
edges = edges::Vector{MethodInstance}
Copy link
Member

Choose a reason for hiding this comment

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

should be a Vector{Any}, since edges only sometimes end at a MethodInstance

Copy link
Member Author

Choose a reason for hiding this comment

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

In the Cassette use case, don't they always end at a MethodInstance (because Cassette by nature gets concrete values from the generated function)?

@assert isa(edge, MethodInstance)
ccall(:jl_method_instance_add_backedge, Cvoid, (Any, Any), edge, caller)
end
empty!(edges)
Copy link
Member

Choose a reason for hiding this comment

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

should be non-destructive

Copy link
Member Author

Choose a reason for hiding this comment

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

Do we ever look at this twice? I figure after this the CodeInfo holds the inferred result and we don't ever come back here again (and nobody caches the CodeInfo after it comes out of the generated function).

Copy link
Member

Choose a reason for hiding this comment

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

mutating it here though just means we had to make a copy of it earlier though, so it's strictly worse. the memory won't be reclaimed until gc regardless

Copy link
Member Author

Choose a reason for hiding this comment

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

fair. Perhaps what I meant here was frame.src.edges = nothing?

@Keno Keno force-pushed the kf/cassetteedges branch 2 times, most recently from eafcd93 to 851d9c0 Compare June 3, 2019 23:25
@Keno
Copy link
Member Author

Keno commented Jun 3, 2019

@vtjnash says this is the right way to do it, so removing the WIP

@Keno Keno changed the title WIP: Towards backedges for Cassette Allow Cassette (et al.) to participate in backedge system Jun 3, 2019
src/jltypes.c Outdated
jl_bool_type),
0, 1, 17);
jl_perm_symsvec(18,
"code",
Copy link
Member

Choose a reason for hiding this comment

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

code editor seems to be auto-reindenting this block unnecessarily? The intent of the current alignment is to prevent these sorts of excess diff noise, so that adding removing fields and or changing variable names doesn't require excess conflict regions and an indent-aware find-replace editor.

Copy link
Member Author

Choose a reason for hiding this comment

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

should be fixed

src/jltypes.c Outdated
jl_any_type,
jl_any_type,
jl_ulong_type,
jl_ulong_type,
Copy link
Member

Choose a reason for hiding this comment

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

👍 I don't think we used to have the ulong type available here previously. Can we change all of the other similar slots too now?

@vtjnash
Copy link
Member

vtjnash commented Jun 4, 2019

Also, looks like this could be a breaking change, per #32028

@Keno Keno force-pushed the kf/cassetteedges branch from 851d9c0 to 4309e03 Compare June 4, 2019 20:14
@Keno
Copy link
Member Author

Keno commented Jun 4, 2019

Separated out the long->ulong change into #32241.

Adds an extra field in `CodeInfo` that allows users (Cassette, et al.)
to specify dependencies (as forward edges to `MethodInstance`s) that should
be turned into backedges once the CodeInfo is passed over by inference.

The test includes a minimal implementation of the Cassette mechansim to
exercise this code path.
@Keno Keno force-pushed the kf/cassetteedges branch from 4309e03 to 1d3cdec Compare June 7, 2019 22:35
@Keno
Copy link
Member Author

Keno commented Jun 7, 2019

Rebased and squashed. @vtjnash good to go?

@Keno Keno merged commit 1a859d6 into master Jun 10, 2019
@StefanKarpinski StefanKarpinski deleted the kf/cassetteedges branch June 10, 2019 19:35
@vchuravy
Copy link
Member

dance party in the JuliaLab, thanks Keno and Jameson!

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