JuliaCollections / JuliaCollections/AbstractTrees.jl
collecting a tree iterator is horribly type unstable, with lots of run time dispatch, even when the element type is provided explicitly
Open
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 243
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
using JET, AbstractTrees
struct S
c::Int
end
function AbstractTrees.children(s::S)
c = s.c
Iterators.map(Returns(S(c - 1)), Base.OneTo(c))
end
it = Leaves(S(3))
@report_opt collect(S, it) # ═════ 15 possible errors found ═════
it = PreOrderDFS(S(3))
@report_opt collect(S, it) # ═════ 9 possible errors found ═════
it = PostOrderDFS(S(3))
@report_opt collect(S, it) # ═════ 16 possible errors found ═════
For comparison, Base.Generator collects fine without run time dispatch:
using JET
struct S
c::Int
end
it = Iterators.map(S, 1:5)
@report_opt collect(S, it)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the JET examples for collect(S, it) with Leaves, PreOrderDFS, and PostOrderDFS, then compare their reports with the Iterators.map example. Trace the iterator implementations behind those three entry points and determine what keeps explicit element-type collection type unstable. Done means the reported runtime dispatch is addressed for the shown cases.
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
- Mostly clear
- Newbie friendliness
- 35/100