SciML / SciML/ComponentArrays.jl

Slow creation of CAs

Open
#48 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
375
Forks
42
Avg merge
7h 25m
Merged PRs (30d)
17

Description

It seems the slow (as per v0.50 release notes) kwargs constructor is being used for all CA creation and not just for the CA(...; x=y) syntax.

I'm not sure if this was the result of a recent change or if it has always been like this.

julia> @btime ComponentArray(a=5, b=[1, 2])
  23.316 μs (45 allocations: 2.14 KiB)
ComponentVector{Int64}(a = 5, b = [1, 2])
julia> @code_warntype ComponentArray(a=5, b=[1, 2])
Variables
  #unused#::Core.Compiler.Const(Core.var"#Type##kw"(), false)
  @_2::NamedTuple{(:a, :b),Tuple{Int64,Array{Int64,1}}}
  @_3::Type{ComponentArray}
  kwargs...::Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol},NamedTuple{(:a, :b),Tuple{Int64,Array{Int64,1}}}}

Body::Any
1 ─      (kwargs... = Base.pairs(@_2))
│   %2 = ComponentArrays.:(var"#ComponentArray#13")(kwargs..., @_3)::Any
└──      return %2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the ComponentArray constructor dispatch used by the named-argument example, then compare it with the kwargs path using the provided @btime and @code_warntype commands. Done means determining whether ordinary CA creation is incorrectly using the slow kwargs constructor and demonstrating the resulting performance difference.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.