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

Increase purity of @generated functions during tests with DispatchDoctor #97

Merged
merged 12 commits into from
Aug 1, 2024

Conversation

MilesCranmer
Copy link
Member

@MilesCranmer MilesCranmer commented Aug 1, 2024

There are some bugs in Julia itself related to Core.Compiler.return_type, especially the interaction with @generated functions: JuliaLang/julia#55147 JuliaLang/julia#55332.

While the changes in this PR do not get around the issue originally reported in that thread, they seem to be good ideas anyway, as they increase purity of the generated functions.

I also tried disabling the @generated functions and using JuliaLang/julia#55093 but sadly it hurts inference, the original @generated functions are much better. In the future it seems like we should avoid @generated functions whenever we can though. Only for things like Base.Cartesian.@nif here are they necessary.

@MilesCranmer MilesCranmer changed the title Prevent segfault from @generated Increase purity of @generated functions during tests with DispatchDoctor Aug 1, 2024
Copy link
Contributor

github-actions bot commented Aug 1, 2024

Benchmark Results

master 54acd34... master/54acd346b328e9...
eval/ComplexF32/evaluation 7.37 ± 0.47 ms 7.34 ± 0.51 ms 1
eval/ComplexF64/evaluation 9.64 ± 0.74 ms 9.57 ± 0.73 ms 1.01
eval/Float32/derivative 11.3 ± 2.6 ms 11.1 ± 2.1 ms 1.02
eval/Float32/derivative_turbo 11.3 ± 2.6 ms 11 ± 2.1 ms 1.03
eval/Float32/evaluation 2.68 ± 0.24 ms 2.62 ± 0.23 ms 1.02
eval/Float32/evaluation_bumper 0.561 ± 0.014 ms 0.536 ± 0.013 ms 1.05
eval/Float32/evaluation_turbo 0.598 ± 0.035 ms 0.566 ± 0.025 ms 1.06
eval/Float32/evaluation_turbo_bumper 0.559 ± 0.014 ms 0.53 ± 0.013 ms 1.05
eval/Float64/derivative 15.6 ± 0.63 ms 14.9 ± 0.64 ms 1.04
eval/Float64/derivative_turbo 15.6 ± 0.66 ms 14.8 ± 0.62 ms 1.05
eval/Float64/evaluation 2.85 ± 0.25 ms 2.82 ± 0.24 ms 1.01
eval/Float64/evaluation_bumper 1.21 ± 0.044 ms 1.2 ± 0.043 ms 1.01
eval/Float64/evaluation_turbo 1.08 ± 0.056 ms 1.05 ± 0.058 ms 1.02
eval/Float64/evaluation_turbo_bumper 1.21 ± 0.044 ms 1.2 ± 0.044 ms 1.01
utils/combine_operators/break_sharing 0.0443 ± 0.00099 ms 0.0389 ± 0.0009 ms 1.14
utils/convert/break_sharing 23.3 ± 1.2 μs 23.5 ± 1.3 μs 0.992
utils/convert/preserve_sharing 0.127 ± 0.0035 ms 0.128 ± 0.0045 ms 0.995
utils/copy/break_sharing 23.9 ± 1.2 μs 24.3 ± 1.4 μs 0.985
utils/copy/preserve_sharing 0.13 ± 0.0045 ms 0.129 ± 0.0047 ms 1.01
utils/count_constant_nodes/break_sharing 8.94 ± 0.17 μs 9.55 ± 0.23 μs 0.936
utils/count_constant_nodes/preserve_sharing 0.113 ± 0.0035 ms 0.113 ± 0.0033 ms 0.994
utils/count_depth/break_sharing 12.7 ± 0.28 μs 12.9 ± 0.34 μs 0.985
utils/count_nodes/break_sharing 8.63 ± 0.14 μs 8.46 ± 0.16 μs 1.02
utils/count_nodes/preserve_sharing 0.115 ± 0.0035 ms 0.115 ± 0.004 ms 1
utils/get_set_constants!/break_sharing 0.0345 ± 0.0012 ms 0.0347 ± 0.0013 ms 0.995
utils/get_set_constants!/preserve_sharing 0.231 ± 0.0063 ms 0.235 ± 0.0075 ms 0.986
utils/get_set_constants_parametric 0.0495 ± 0.002 ms 0.0497 ± 0.0022 ms 0.997
utils/has_constants/break_sharing 4.36 ± 0.071 μs 4.16 ± 0.076 μs 1.05
utils/has_operators/break_sharing 2.07 ± 0.023 μs 1.91 ± 0.031 μs 1.08
utils/hash/break_sharing 25.6 ± 0.51 μs 25.1 ± 0.47 μs 1.02
utils/hash/preserve_sharing 0.135 ± 0.004 ms 0.134 ± 0.0036 ms 1.01
utils/index_constant_nodes/break_sharing 22.7 ± 0.84 μs 22.9 ± 1.2 μs 0.993
utils/index_constant_nodes/preserve_sharing 0.128 ± 0.0036 ms 0.129 ± 0.0047 ms 0.995
utils/is_constant/break_sharing 3.61 ± 0.068 μs 4.1 ± 0.058 μs 0.881
utils/simplify_tree/break_sharing 0.167 ± 0.0017 ms 0.168 ± 0.0015 ms 0.992
utils/simplify_tree/preserve_sharing 0.287 ± 0.0069 ms 0.3 ± 0.0077 ms 0.956
utils/string_tree/break_sharing 0.419 ± 0.017 ms 0.568 ± 0.012 ms 0.738
utils/string_tree/preserve_sharing 0.552 ± 0.015 ms 0.713 ± 0.03 ms 0.775
time_to_load 0.254 ± 0.0034 s 0.264 ± 0.0044 s 0.964

@MilesCranmer
Copy link
Member Author

Hm, the string_tree benchmark fell quite a bit... Is it just from lack of specialization to the operator?

Copy link
Contributor

github-actions bot commented Aug 1, 2024

Pull Request Test Coverage Report for Build 10206194772

Details

  • 18 of 22 (81.82%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.03%) to 95.975%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/Strings.jl 13 17 76.47%
Totals Coverage Status
Change from base Build 10128244785: -0.03%
Covered Lines: 2432
Relevant Lines: 2534

💛 - Coveralls

@MilesCranmer
Copy link
Member Author

Yep, it's from no specialization. Fixed.

@MilesCranmer MilesCranmer merged commit e3aa296 into master Aug 1, 2024
18 checks passed
@MilesCranmer MilesCranmer deleted the prevent-julia-bugs branch August 1, 2024 22:51
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.

1 participant