Skip to content

.ipynb files in v1.12 re-JIT-compiling already precompiled code #1192

@mattsignorelli

Description

@mattsignorelli

This issue does NOT appear with Julia v1.11. First develop the package:

import Pkg; Pkg.develop("SciBmad")

Then, using Julia v1.12, run the following script in both a fresh terminal and in an .ipynb file (I use Jupyter lab) with a fresh kernel:

using SciBmad 

K1 = 0.36;
K2 = 0.1;
qf = Quadrupole(Kn1=DefExpr(() -> +K1), L=0.5);
sf = Sextupole(Kn2=DefExpr(() -> +K2), L=0.2);
d  = Drift(L=0.6);
b  = SBend(L=6.0, angle=pi/132);
qd = Quadrupole(Kn1=DefExpr(() -> -K1), L=0.5);
sd = Sextupole(Kn2=DefExpr(() -> -K2), L=0.2);
fodo_line = [qf, sf, d, b, d, qd, sd, d, b, d];
fodo = Beamline(fodo_line, species_ref=Species("electron"), E_ref=18e9);

@time t = twiss(fodo); # This function has been precompiled using PrecompileTools.jl

In the .ipynb, the output is:

1.936909 seconds (4.12 M allocations: 207.496 MiB, 1.92% gc time, 99.41% compilation time: 68% of which was recompilation)

In the terminal, the output is:

0.378638 seconds (455.82 k allocations: 23.735 MiB, 96.82% compilation time: <1% of which was recompilation)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions