<p dir="auto">Pulling <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="345798181" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/28356" data-hovercard-type="issue" data-hovercard-url="/JuliaLang/julia/issues/28356/hovercard?comment_id=409297092&amp;comment_type=issue_comment" href="https://github.com/JuliaLang/julia/issues/28356#issuecomment-409297092">#28356 (comment)</a> out to a new issue since this second example doesn't seem to be exactly the same as the previous fix. In this case, a code which compiles a function call in the global scope is okay, but when the same function call is compiled in a local scope then compilation hangs. Using a recent nightly with the fix for <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="345798181" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/28356" data-hovercard-type="issue" data-hovercard-url="/JuliaLang/julia/issues/28356/hovercard" href="https://github.com/JuliaLang/julia/issues/28356">#28356</a></p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type &quot;?&quot; for help, &quot;]?&quot; for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.7.0-rc1.18 (2018-08-02 13:13 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit 34b0dd097f (0 days old master)
|__/                   |  x86_64-w64-mingw32"><pre class="notranslate">   _       _ <span class="pl-c1">_</span>(_)_     <span class="pl-k">|</span>  A fresh approach to technical computing
  (_)     <span class="pl-k">|</span> (_) (_)    <span class="pl-k">|</span>  Documentation<span class="pl-k">:</span> https<span class="pl-k">:</span><span class="pl-k">//</span>docs<span class="pl-k">.</span>julialang<span class="pl-k">.</span>org
   _ _   _<span class="pl-k">|</span> <span class="pl-k">|</span>_  __ _   <span class="pl-k">|</span>  Type <span class="pl-s"><span class="pl-pds">"</span>?<span class="pl-pds">"</span></span> <span class="pl-k">for</span> help, <span class="pl-s"><span class="pl-pds">"</span>]?<span class="pl-pds">"</span></span> <span class="pl-k">for</span> Pkg help.
  <span class="pl-k">|</span> <span class="pl-k">|</span> <span class="pl-k">|</span> <span class="pl-k">|</span> <span class="pl-k">|</span> <span class="pl-k">|</span> <span class="pl-k">|</span><span class="pl-k">/</span> <span class="pl-s"><span class="pl-pds"><span class="pl-c1">_</span>`</span> |  |</span>
<span class="pl-s">  | | |_| | | | (_| |  |  Version 0.7.0-rc1.18 (2018-08-02 13:13 UTC)</span>
<span class="pl-s"> _/ |<span class="pl-cce">\_</span>_'_|_|_|<span class="pl-cce">\_</span>_'_|  |  Commit 34b0dd097f (0 days old master)</span>
<span class="pl-s">|__/                   |  x86_64-w64-mingw32</span></pre></div>
<p dir="auto">I run the code:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="using DiffEqBiological, StochasticDiffEq

model = @reaction_network rn begin
    (d,1000), X ↔ 0
end d

i = 1.0
prob = SDEProblem(model,[1000.0+i],(0.,200.),[i])
sol = solve(prob, EM(), dt = 0.01)

for i in [1., 2., 3., 4., 5.]
    prob = SDEProblem(model,[1000.0+i],(0.,200.),[i])
    sol = solve(prob, EM(), dt = 0.01)
end"><pre class="notranslate"><span class="pl-k">using</span> DiffEqBiological, StochasticDiffEq

model <span class="pl-k">=</span> <span class="pl-c1">@reaction_network</span> rn <span class="pl-k">begin</span>
    (d,<span class="pl-c1">1000</span>), X ↔ <span class="pl-c1">0</span>
<span class="pl-k">end</span> d

i <span class="pl-k">=</span> <span class="pl-c1">1.0</span>
prob <span class="pl-k">=</span> <span class="pl-c1">SDEProblem</span>(model,[<span class="pl-c1">1000.0</span><span class="pl-k">+</span>i],(<span class="pl-c1">0.</span>,<span class="pl-c1">200.</span>),[i])
sol <span class="pl-k">=</span> <span class="pl-c1">solve</span>(prob, <span class="pl-c1">EM</span>(), dt <span class="pl-k">=</span> <span class="pl-c1">0.01</span>)

<span class="pl-k">for</span> i <span class="pl-k">in</span> [<span class="pl-c1">1.</span>, <span class="pl-c1">2.</span>, <span class="pl-c1">3.</span>, <span class="pl-c1">4.</span>, <span class="pl-c1">5.</span>]
    prob <span class="pl-k">=</span> <span class="pl-c1">SDEProblem</span>(model,[<span class="pl-c1">1000.0</span><span class="pl-k">+</span>i],(<span class="pl-c1">0.</span>,<span class="pl-c1">200.</span>),[i])
    sol <span class="pl-k">=</span> <span class="pl-c1">solve</span>(prob, <span class="pl-c1">EM</span>(), dt <span class="pl-k">=</span> <span class="pl-c1">0.01</span>)
<span class="pl-k">end</span></pre></div>
<p dir="auto">and it's just fine. However, when I do not allow it to compile the <code class="notranslate">solve</code> call in the global scope first, it hangs at compilation.</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="using DiffEqBiological, StochasticDiffEq

model = @reaction_network rn begin
    (d,1000), X ↔ 0
end d

for i in [1., 2., 3., 4., 5.]
    prob = SDEProblem(model,[1000.0+i],(0.,200.),[i])
    sol = solve(prob, EM(), dt = 0.01)
end"><pre class="notranslate"><span class="pl-k">using</span> DiffEqBiological, StochasticDiffEq

model <span class="pl-k">=</span> <span class="pl-c1">@reaction_network</span> rn <span class="pl-k">begin</span>
    (d,<span class="pl-c1">1000</span>), X ↔ <span class="pl-c1">0</span>
<span class="pl-k">end</span> d

<span class="pl-k">for</span> i <span class="pl-k">in</span> [<span class="pl-c1">1.</span>, <span class="pl-c1">2.</span>, <span class="pl-c1">3.</span>, <span class="pl-c1">4.</span>, <span class="pl-c1">5.</span>]
    prob <span class="pl-k">=</span> <span class="pl-c1">SDEProblem</span>(model,[<span class="pl-c1">1000.0</span><span class="pl-k">+</span>i],(<span class="pl-c1">0.</span>,<span class="pl-c1">200.</span>),[i])
    sol <span class="pl-k">=</span> <span class="pl-c1">solve</span>(prob, <span class="pl-c1">EM</span>(), dt <span class="pl-k">=</span> <span class="pl-c1">0.01</span>)
<span class="pl-k">end</span></pre></div>
<p dir="auto">Given my working knowledge of the Julia compiler, both <code class="notranslate">solve</code> calls are compiling the same thing so <g-emoji class="g-emoji" alias="man_shrugging" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f937-2642.png">🤷‍♂️</g-emoji> I don't get it.</p>
<p dir="auto">Note that the example from <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="345798181" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/28356" data-hovercard-type="issue" data-hovercard-url="/JuliaLang/julia/issues/28356/hovercard" href="https://github.com/JuliaLang/julia/issues/28356">#28356</a> displayed some of this behavior too, since the original example only ran into the issue when the <code class="notranslate">function integrator(...)</code> was involved. If you refactor it so that way it does the same commands in the REPL, then even before the <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="345798181" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/28356" data-hovercard-type="issue" data-hovercard-url="/JuliaLang/julia/issues/28356/hovercard" href="https://github.com/JuliaLang/julia/issues/28356">#28356</a> fix there was no issue. Given <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/JeffBezanson/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/JeffBezanson">@JeffBezanson</a> 's comments about how the hang was due to inference generating unions, my guess is that somehow a difference in inference could be involved, but I'm of course not the expert on this so that could be totally wrong.</p>
<p dir="auto">How the heck does anyone get anything done in Julia 0.6.2 on 64-bit linux (ubuntu 16.04). It takes 22 seconds to load the plotting package <code class="notranslate">Gadfly</code> ??? It's not precompilation time, since it happens even after the package has been precompiled once. If I restart Julia, I <em>still</em> have to wait, sometimes even <em>longer</em> the second time.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type &quot;?help&quot; for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.6.2 (2017-12-13 18:08 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-pc-linux-gnu

julia&gt; tic(); using Gadfly; toc()
elapsed time: 22.640510854 seconds
22.640510854

julia&gt; [ctl-D to exit]
# julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type &quot;?help&quot; for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.6.2 (2017-12-13 18:08 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-pc-linux-gnu

julia&gt; tic(); using Gadfly; toc()
elapsed time: 28.402201721 seconds
28.402201721

julia&gt; "><pre class="notranslate"><code class="notranslate"># julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.6.2 (2017-12-13 18:08 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-pc-linux-gnu

julia&gt; tic(); using Gadfly; toc()
elapsed time: 22.640510854 seconds
22.640510854

julia&gt; [ctl-D to exit]
# julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.6.2 (2017-12-13 18:08 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-pc-linux-gnu

julia&gt; tic(); using Gadfly; toc()
elapsed time: 28.402201721 seconds
28.402201721

julia&gt; 
</code></pre></div>