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

Switch from a mutation loop to a generator in a make_idx path #242

Merged
merged 1 commit into from
Feb 16, 2024

Conversation

LilithHafner
Copy link
Member

The new version is 1.5x faster for constructing a ComponentArray with 100 fields each with a 10 element vector.

Benchmarks:

julia> using ComponentArrays, Chairmarks
Precompiling ComponentArrays
  1 dependency successfully precompiled in 1 seconds. 36 already precompiled.

julia> s(i) = Symbol("x"*string(i))
s (generic function with 1 method)

julia> const NT = (;(s(i) => randn(10) for i in 1:100)...);

julia> f() = ComponentArray(NT)
f (generic function with 1 method)

julia> @b f() # PR
28.292 μs (246 allocs: 63.703 KiB)

shell> git checkout main
Switched to branch 'main'
Your branch is up to date with 'upstream/main'.

julia> @b f() # main
42.834 μs (849 allocs: 84.344 KiB)

This is part of a journey to make ComponentArray(x = [1,2,3]) not use mutation so that it is compatible with Zygote.jl which is motivated in part by DARPA-ASKEM/sciml-service#141.

@jonniedie
Copy link
Collaborator

Oh awesome. Thanks for this. This has been a long-standing issue that I've wanted to fix, but haven't really had the time to dive into.

@codecov-commenter
Copy link

codecov-commenter commented Feb 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (94ab225) 73.99% compared to head (f2d9983) 73.92%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #242      +/-   ##
==========================================
- Coverage   73.99%   73.92%   -0.07%     
==========================================
  Files          23       23              
  Lines         746      744       -2     
==========================================
- Hits          552      550       -2     
  Misses        194      194              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jonniedie jonniedie merged commit d12aa28 into SciML:main Feb 16, 2024
8 checks passed
@LilithHafner LilithHafner deleted the lh/make_idx-gen branch February 16, 2024 23:47
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