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

Create preallocation utility functions for expressions #114

Merged
merged 11 commits into from
Dec 13, 2024

Conversation

MilesCranmer
Copy link
Member

@MilesCranmer MilesCranmer commented Dec 13, 2024

This creates allocate_container and copy_into! for preallocating storage for an expression or tree:

container = allocate_container(ex)

# The following code will result in zero allocations
for _ = 1:100
    ex2 = copy_into!(container, ex)
end

The allocate_container takes an n argument if you want to set a specific size. Otherwise it just takes it from ex.

Copy link
Contributor

github-actions bot commented Dec 13, 2024

Pull Request Test Coverage Report for Build 12322510485

Details

  • 70 of 70 (100.0%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.2%) to 95.533%

Totals Coverage Status
Change from base Build 12289055804: 0.2%
Covered Lines: 2545
Relevant Lines: 2664

💛 - Coveralls

Copy link
Contributor

github-actions bot commented Dec 13, 2024

Benchmark Results

master 16c5ef0... master/16c5ef08b12d27...
eval/ComplexF32/evaluation 7.23 ± 0.51 ms 7.24 ± 0.53 ms 0.999
eval/ComplexF64/evaluation 10.8 ± 0.83 ms 10.7 ± 0.86 ms 1.01
eval/Float32/derivative 12.5 ± 1.4 ms 11.6 ± 1.2 ms 1.07
eval/Float32/derivative_turbo 12.3 ± 1.6 ms 11.6 ± 1.3 ms 1.05
eval/Float32/evaluation 2.76 ± 0.24 ms 2.72 ± 0.25 ms 1.01
eval/Float32/evaluation_bumper 0.583 ± 0.014 ms 0.601 ± 0.013 ms 0.97
eval/Float32/evaluation_turbo 0.567 ± 0.031 ms 0.552 ± 0.034 ms 1.03
eval/Float32/evaluation_turbo_bumper 0.581 ± 0.014 ms 0.6 ± 0.013 ms 0.968
eval/Float64/derivative 16 ± 1.1 ms 15 ± 0.83 ms 1.06
eval/Float64/derivative_turbo 15.7 ± 1.1 ms 14.9 ± 0.71 ms 1.05
eval/Float64/evaluation 3.2 ± 0.3 ms 3.14 ± 0.32 ms 1.02
eval/Float64/evaluation_bumper 1.19 ± 0.043 ms 1.25 ± 0.044 ms 0.954
eval/Float64/evaluation_turbo 1.07 ± 0.068 ms 1.03 ± 0.068 ms 1.04
eval/Float64/evaluation_turbo_bumper 1.2 ± 0.042 ms 1.25 ± 0.045 ms 0.958
utils/combine_operators/break_sharing 0.0388 ± 0.00065 ms 0.0386 ± 0.00083 ms 1
utils/convert/break_sharing 27.9 ± 2.6 μs 27.2 ± 2.5 μs 1.02
utils/convert/preserve_sharing 0.0982 ± 0.0041 ms 0.099 ± 0.0044 ms 0.992
utils/copy/break_sharing 28.3 ± 2.5 μs 27.3 ± 2.3 μs 1.04
utils/copy/preserve_sharing 0.0992 ± 0.0039 ms 0.0985 ± 0.004 ms 1.01
utils/count_constant_nodes/break_sharing 8.87 ± 0.18 μs 8.81 ± 0.2 μs 1.01
utils/count_constant_nodes/preserve_sharing 0.0864 ± 0.0032 ms 0.0863 ± 0.0034 ms 1
utils/count_depth/break_sharing 9.66 ± 0.2 μs 9.68 ± 0.27 μs 0.999
utils/count_nodes/break_sharing 8.46 ± 0.18 μs 8.09 ± 0.22 μs 1.05
utils/count_nodes/preserve_sharing 0.087 ± 0.0032 ms 0.086 ± 0.0032 ms 1.01
utils/get_set_constants!/break_sharing 0.0336 ± 0.0022 ms 0.0332 ± 0.0021 ms 1.01
utils/get_set_constants!/preserve_sharing 0.178 ± 0.0056 ms 0.178 ± 0.0063 ms 1
utils/get_set_constants_parametric 0.0449 ± 0.0024 ms 0.0443 ± 0.0021 ms 1.01
utils/has_constants/break_sharing 4.1 ± 0.14 μs 4.07 ± 0.15 μs 1.01
utils/has_operators/break_sharing 1.97 ± 0.084 μs 2 ± 0.08 μs 0.986
utils/hash/break_sharing 23 ± 0.54 μs 22.7 ± 1.1 μs 1.01
utils/hash/preserve_sharing 0.0982 ± 0.0035 ms 0.0964 ± 0.0033 ms 1.02
utils/index_constant_nodes/break_sharing 25.4 ± 0.98 μs 25.3 ± 0.89 μs 1.01
utils/index_constant_nodes/preserve_sharing 0.0987 ± 0.0035 ms 0.0985 ± 0.0041 ms 1
utils/is_constant/break_sharing 4.45 ± 0.16 μs 4.42 ± 0.16 μs 1.01
utils/simplify_tree/break_sharing 0.187 ± 0.0037 ms 0.165 ± 0.0032 ms 1.13
utils/simplify_tree/preserve_sharing 0.233 ± 0.005 ms 0.216 ± 0.0047 ms 1.08
utils/string_tree/break_sharing 0.47 ± 0.017 ms 0.468 ± 0.019 ms 1
utils/string_tree/preserve_sharing 0.572 ± 0.021 ms 0.582 ± 0.025 ms 0.983
time_to_load 0.235 ± 0.0031 s 0.232 ± 0.011 s 1.01

@MilesCranmer MilesCranmer merged commit 46eb0de into master Dec 13, 2024
14 checks passed
@MilesCranmer MilesCranmer deleted the allocs-functions branch December 13, 2024 20:54
MilesCranmer added a commit that referenced this pull request Dec 15, 2024
[Diff since v1.7.0](v1.7.0...v1.8.0)

**Merged pull requests:**
- Create preallocation utility functions for expressions (#114) (@MilesCranmer)
MilesCranmer added a commit that referenced this pull request Dec 15, 2024
[Diff since v1.7.0](v1.7.0...v1.8.0)

**Merged pull requests:**
- Create preallocation utility functions for expressions (#114) (@MilesCranmer)
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