Skip to content

TTFX allocation and time blowup with Automa 1.2.0, PythonCall and GLMakie #147

Closed

Description

@jaakkor2

Running Julia 1.12.6 with environment

(debugAutoma) pkg> st
Status `/tmp/debugAutoma/Project.toml`
⌃ [67c07d97] Automa v1.1.0 ⚲
  [e9467ef8] GLMakie v0.13.12
  [6099a3de] PythonCall v0.9.35
Info Packages marked with ⌃ have new versions available and may be upgradable.
julia-1.12 --startup-file=no --project=. -e  "@show VERSION; @time using PythonCall, GLMakie; @time display(plot(rand(10)))"

Automa 1.1.0

VERSION = v"1.12.6"
  7.344142 seconds (5.16 M allocations: 318.104 MiB, 13.62% gc time, 32.17% compilation time: 25% of which was recompilation)
  5.022463 seconds (5.57 M allocations: 276.834 MiB, 13.13% gc time, 93.77% compilation time: 53% of which was recompilation)

Automa 1.2.0

  7.082217 seconds (5.05 M allocations: 308.689 MiB, 13.61% gc time, 33.34% compilation time: 25% of which was recompilation)
 23.471874 seconds (40.89 M allocations: 1.951 GiB, 6.36% gc time, 98.57% compilation time: 59% of which was recompilation)

Bisect points to #146

Activity

  1. jakobnissen commented on Jul 1, 2026

    @jakobnissen
    Member

    Some cursory investigation with SnoopCompile indicates that this is a problem in dependents of Automa, not in Automa itself:

    • None of the inference time is spent in Automa methods or MathTexEngine methods (the only direct dep of Automa in that environment)
    • Simply adding using SIMD to Automa fixes the regression, indicating this is an invalidation issue
    • Invalidations are rampant with 4000+ invalidations. None of these are in Automa.

    The probable cause is that loading SIMD invalidates some code, which is then repaired during precompilation of some dependents of Automa. Without the loading of SIMD in Automa, SIMD is loaded later in the pipeline, which then causes widespread invalidation.

    The proximal sinner are the invalidated code, which needs to be written to be type stable. With 4000+ methods, that might be a bit of an issue.
    The true, underlying cause is in the design of Julia, which is built in such a way that small, innocent changes can completely trash compilation time. Specifically in this case, speculative compilation through the world splitting mechanism.

    I'm closing this, as this is not an issue with Automa. Good luck hunting the invalidations down in the rest of the stack.
    Please let me know, and re-open this issue, if you think there is something wrong with my analysis.

  2. jaakkor2 commented on Jul 2, 2026

    @jaakkor2
    Author

    This is not about SIMD.jl. If I kick out TiffImages.jl from ImageIO.jl, SIMD.jl is not in the project, but excessive allocations remain with Automa.jl 1.2.0.

    (debugAutoma) pkg> st
    Status `/tmp/debugAutoma/Project.toml`
      [67c07d97] Automa v1.2.0
      [e9467ef8] GLMakie v0.13.12
      [82e4d734] ImageIO v0.6.9 `~/.julia/dev/ImageIO`
      [6099a3de] PythonCall v0.9.35
    
    (debugAutoma) pkg> why SIMD
    ERROR: The following package names could not be resolved:
     * SIMD (not found in project or manifest)
    
    
    VERSION = v"1.12.6"
      7.097936 seconds (5.04 M allocations: 308.530 MiB, 13.69% gc time, 33.28% compilation time: 25% of which was recompilation)
     22.896431 seconds (40.89 M allocations: 1.951 GiB, 4.12% gc time, 98.51% compilation time: 61% of which was recompilation)
    

    I do not have permissions to reopen this issue.

  3. jakobnissen commented on Jul 2, 2026

    @jakobnissen
    Member

    It must be about loading SIMD, because modifying Automa 1.2.0 to load SIMD fixes the issue.
    Probably the cause is the invalidations caused by PyCall adding new methods for comparison operations. At least these invalidations show op prominently in the invalidations list, but the list is huge, so it’s hard to tell. SIMD also adds these methods.

  4. jaakkor2 commented on Jul 2, 2026

    @jaakkor2
    Author

    WIll be fixed by JuliaLang/julia#61880, tested with julia +pr62003 VERSION = v"1.12.7-DEV.37"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions