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

update for 1.8 #516

Merged
merged 1 commit into from
Feb 19, 2022
Merged

update for 1.8 #516

merged 1 commit into from
Feb 19, 2022

Conversation

aviatesk
Copy link
Member

Comment on lines -282 to +289
cconvert_stmt = unsafe_convert_expr.args[3]::SSAValue
push!(delete_idx, cconvert_stmt.id) # delete the cconvert
cconvert_expr = code.code[cconvert_stmt.id]::Expr
push!(args, cconvert_expr.args[3])
cconvert_val = unsafe_convert_expr.args[3]
if isa(cconvert_val, SSAValue)
push!(delete_idx, cconvert_val.id) # delete the cconvert
newarg = (code.code[cconvert_val.id]::Expr).args[3]
push!(args, newarg)
else
@assert isa(cconvert_val, SlotNumber)
push!(args, cconvert_val)
end
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'm actually not too sure why we need this dead code elimination of unsafe_converts. Maybe could @KristofferC clarify the reason?

Copy link
Member

Choose a reason for hiding this comment

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

Not sure. Maybe it didn't get eliminated all the time. Or I was trying to be smart.

Copy link
Member Author

Choose a reason for hiding this comment

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

If we remove those conversions, the same conversion will be applied anyway within a generated compiled call. I'd like to just delete these DCE because of its maintenance cost.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you do any benchmarks whether removing them might hurt performance? Or does it just always get removed by the optimizer anyways?

Copy link
Member Author

Choose a reason for hiding this comment

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

The following simple benchmark shows that this DCE is certainly useful to optimize performance:

~/julia/packages/JuliaInterpreter master
❯ julia -e 'using JuliaInterpreter, BenchmarkTools; display(@benchmark @interpret joinpath("/home/julia/base", "sysimg.jl"))'
BenchmarkTools.Trial: 2025 samples with 1 evaluation.
 Range (min … max):  2.045 ms …  15.942 ms  ┊ GC (min … max): 0.00% … 80.39%
 Time  (median):     2.274 ms               ┊ GC (median):    0.00%
 Time  (mean ± σ):   2.463 ms ± 677.894 μs  ┊ GC (mean ± σ):  2.99% ±  7.99%

  ▅█▇▃▂                                                        
  ██████▇▆▅▄▄▄▃▄▄▄▃▄▃▃▃▃▃▂▂▂▂▂▂▂▂▂▁▁▁▁▁▁▁▂▁▁▁▁▁▁▁▂▂▂▂▂▂▂▂▂▂▁▂ ▃
  2.05 ms         Histogram: frequency by time        5.32 ms <

 Memory estimate: 1.18 MiB, allocs estimate: 23941.

~/julia/packages/JuliaInterpreter avi/update 20s
❯ julia -e 'using JuliaInterpreter, BenchmarkTools; display(@benchmark @interpret joinpath("/home/julia/base", "sysimg.jl"))' 
BenchmarkTools.Trial: 1890 samples with 1 evaluation.
 Range (min … max):  2.200 ms …   9.467 ms  ┊ GC (min … max): 0.00% … 68.55%
 Time  (median):     2.459 ms               ┊ GC (median):    0.00%
 Time  (mean ± σ):   2.640 ms ± 585.427 μs  ┊ GC (mean ± σ):  2.60% ±  7.68%

  ▂██▄▄▁                                                       
  ██████▇█▇▆▅▅▄▄▃▃▄▄▄▃▃▃▃▃▃▃▂▂▂▂▂▂▂▂▂▂▁▂▁▁▁▁▁▁▁▁▂▁▂▂▂▂▂▂▂▂▂▂▂ ▃
  2.2 ms          Histogram: frequency by time        5.15 ms <

 Memory estimate: 1.27 MiB, allocs estimate: 25811.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, now the performance is recovered:

❯ julia -e 'using JuliaInterpreter, BenchmarkTools; display(@benchmark @interpret joinpath("/home/julia/base", "sysimg.jl"))' 
BenchmarkTools.Trial: 1909 samples with 1 evaluation.
 Range (min … max):  2.040 ms …  18.711 ms  ┊ GC (min … max): 0.00% … 85.75%
 Time  (median):     2.426 ms               ┊ GC (median):    0.00%
 Time  (mean ± σ):   2.612 ms ± 749.552 μs  ┊ GC (mean ± σ):  2.75% ±  7.63%

   ▇██▇▅▄▂▁▁                                                   
  ██████████▇█▇█▇▆▅▆▅▅▅▄▃▃▃▃▃▂▃▂▂▂▂▂▁▂▂▂▂▁▂▂▂▂▁▂▂▂▁▂▁▂▂▂▂▂▂▂▂ ▄
  2.04 ms         Histogram: frequency by time        5.17 ms <

 Memory estimate: 1.18 MiB, allocs estimate: 23942.

Thanks @simeonschaub for pointing this out!

@codecov
Copy link

codecov bot commented Feb 18, 2022

Codecov Report

Merging #516 (1c6e578) into master (d172be1) will decrease coverage by 0.88%.
The diff coverage is 100.00%.

❗ Current head 1c6e578 differs from pull request most recent head 82b7584. Consider uploading reports for the commit 82b7584 to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #516      +/-   ##
==========================================
- Coverage   86.70%   85.81%   -0.89%     
==========================================
  Files          12       12              
  Lines        2376     2355      -21     
==========================================
- Hits         2060     2021      -39     
- Misses        316      334      +18     
Impacted Files Coverage Δ
src/optimize.jl 91.74% <100.00%> (-6.10%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d172be1...82b7584. Read the comment docs.

- it seems like `:ccall` preserves may now include `SlotNumber` objects,
  and so we need to update `build_compiled_call!` accordingly
- JuliaLang/julia#43671 increased the number of
  statements of code that involves assignment to a global variable
@aviatesk aviatesk merged commit 936f349 into master Feb 19, 2022
@aviatesk aviatesk deleted the avi/update branch February 19, 2022 02:09
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.

None yet

3 participants