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

fix performance problem in bootstrapping #4

Merged
merged 1 commit into from
Aug 5, 2021

Conversation

aviatesk
Copy link

@aviatesk aviatesk commented Aug 4, 2021

So EscapeAnalysis.jl has a serious performance problem, which appears
only in bootstrapping.

I made some inspections using the following print debug:

within find_escapes!

if length(argtypes) > 0
    Core.println("analyzing... ", argtypes[1], " ", length(argtypes), " ", nstmts)
end

... and it seems like the performance of find_escapes! will be really
awful when there is a large number of statements, say, nstmts > 100.

The worse case I confirmed so far happens when analyzing
construct_ssa!(::CodeInfo, ::IRCode, ::DomTree, ::Any, ::Vector{Any}),
where I got the print analyzing... Core.Const(val=Core.Compiler.construct_ssa!) 182 4262,
and it took more than 100 sec on my machine (!!!).
Note that find_escapes! works on after-inlining IR, so we often such
many statements.

The interesting property is, this performance problem seems really
specific to bootstrapping. I confirmed that find_escapes! runs in
0.34 sec when I enabled it later using Revise.

julia> @time code_typed(Core.Compiler.construct_ssa!, (Core.Compiler.CodeInfo, Core.Compiler.IRCode,
Core.Compiler.DomTree, Any, Vector{Any}));
...
Core.Const(val=Core.Compiler.setindex!) 4 5
Core.Const(val=Core.Compiler.construct_ssa!) 182 4262
0.342626 seconds (723.68 k allocations: 177.828 MiB, 15.69% gc time, 99.94% compilation time)

@jpsamaroo
Copy link

Could it just be that during bootstrapping we're interpreting instead of executing compiled code?

@aviatesk
Copy link
Author

aviatesk commented Aug 4, 2021

I'm still trying to learn the limitations that happen in boostrapping, but if we're interpreting other high-cost computations like inference should also be slow ?

So EscapeAnalysis.jl has a serious performance problem, which appears
only in bootstrapping.

I made some inspections using the following `print` debug:
> within `find_escapes!`
```julia
if length(argtypes) > 0
    Core.println(argtypes[1], " ", length(argtypes), " ", nstmts)
end
```
... and it seems like the performance of `find_escapes!` will be really
awful when there is a large number of statements, say, `nstmts > 100`.

The worse case I confirmed so far happens when analyzing
`construct_ssa!(::CodeInfo, ::IRCode, ::DomTree, ::Any, ::Vector{Any})`,
where I got the print `Core.Const(val=Core.Compiler.construct_ssa!) 182 
4262`,
and it took more than 100 sec on my machine (!!!).
Note that `find_escapes!` works on after-inlining IR, so we often such
many statements.

The interesting property is, this performance problem seems really
specific to bootstrapping. I confirmed that `find_escapes!` runs in
0.34 sec when I enabled it later using Revise.
```julia
julia> @time code_typed(Core.Compiler.construct_ssa!, 
(Core.Compiler.CodeInfo, Core.Compiler.IRCode,
Core.Compiler.DomTree, Any, Vector{Any}));
...
Core.Const(val=Core.Compiler.setindex!) 4 5
Core.Const(val=Core.Compiler.construct_ssa!) 182 4262
0.342626 seconds (723.68 k allocations: 177.828 MiB, 15.69% gc time, 
99.94% compilation time)
```
@aviatesk
Copy link
Author

aviatesk commented Aug 5, 2021

Escape analysis should run much faster now, thanks @jpsamaroo and @vtjnash

@aviatesk aviatesk changed the title wip: fix performance problem in bootstrapping fix performance problem in bootstrapping Aug 5, 2021
@TH3CHARLie
Copy link
Owner

Cool, I'd like to merge this into my branch, what do you think?

@aviatesk
Copy link
Author

aviatesk commented Aug 5, 2021

Go ahead

@TH3CHARLie TH3CHARLie merged commit 3521979 into TH3CHARLie:th3/port-to-core-compiler Aug 5, 2021
@aviatesk aviatesk deleted the avi/port branch August 5, 2021 14:21
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