Sienna-Platform / Sienna-Platform/InfrastructureOptimizationModels.jl

Type-unstable hot loops

Open
#79 2 comments 0 reactions 1 assignee View on GitHub

@luke-kiernan is already working on this.

Since Aug 21, 2026.

performance
Dominant language
Julia
Stars
1
Forks
0
Avg merge
8h 51m
Merged PRs (30d)
9

Description

Address type-unstable hot loops. Things worth trying, or order of invasiveness:

  1. Introduce a function barrier. Replace
for d in devices # typeof(d) varies: loop body is type unstable.
    # code here won't specialize.
end

with

for d in devices
    _inner!(container, d, ...)
end

function _inner!(contrainer, d::D, ...) where {D}
    # compiled per concrete D: code here will specialize
    # (still a runtime dispatch, though)
end

If the loop body is sufficiently complex, and devices contains a couple different concrete types, the 2nd should win out. This may increase compile-time, though, so it's worth measuring.

  1. Add a replacement for FlattenedIterator that unrolls across the different types. See IS #505. Requires interface work in IS (prototyped in that PR) plus rewriting the loops to use map and similar.

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.