# Version 1.7 much faster than 1.6 in a script that calls wrapped external libraries

**URL:** <https://discourse.julialang.org/t/version-1-7-much-faster-than-1-6-in-a-script-that-calls-wrapped-external-libraries/64872>\
**Category:** General Usage\
**Created:** [July 18, 2021, 7:16pm UTC](https://discourse.julialang.org/t/version-1-7-much-faster-than-1-6-in-a-script-that-calls-wrapped-external-libraries/64872 "2021-07-18T19:16:56Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [July 18, 2021, 7:16pm UTC](https://discourse.julialang.org/t/version-1-7-much-faster-than-1-6-in-a-script-that-calls-wrapped-external-libraries/64872/1 "2021-07-18T19:16:56Z")

</div>

Hi,

This is not really a question but an amazing fact that I wanted to share.  
The code below is the main part of a script where all heavy work is done by external libraries (GMT, GDAl & PROJ). However, version 1.7beta is nearly 6 times faster than 1.6 or 1.5. How’s that possible?

```julia
	...
	for n = 1:np-1
		tic()
		for k = -n_beams:n_beams
			endpt = geod(coast[n,:], az1[n] - 90 + k*2, 350000)[1] # Compute end point coords at azim and distance 350 km
			o = orthodrome([coast[n:n,:]; endpt], step=2000) # Interpolate line at step increments
			Di = grdtrack(o, G, s=true, V=:q)
			Dd = mapproject(Di, G="+a+ue", o=3) # Compute the accumulated distances in meters
			dist_T = [Dd[1].data Di[1].data[:,3]] # Matrix with [lon lat accumdist]
			Dt = trend1d(dist_T, F="xm", N="p1+r", V=:q) # Fit a straight line to the tracked Ts
			if (!all(isnan.(Dt[1].data[:,2])))
				D = intersection(Dt[1].data, dist_T) # Compute intersections between fit and track
				ind = argmin(abs.(Dd[1].data .- D[1].data[1, 1]))[1]
				front[m += 1, 1:2] = Di[1].data[ind, 1:2] # Retain only the first intersection
			end
		end
		toc()
	end

```

with version v1.6 and 1.5

```julia
elapsed time: 2.5549329 seconds
elapsed time: 2.544714 seconds
elapsed time: 2.6814375 seconds
elapsed time: 2.7668562 seconds
elapsed time: 2.8290057 seconds
...

```

with 1.7.0-beta2

```julia
elapsed time: 0.4300048 seconds
elapsed time: 0.4277238 seconds
elapsed time: 0.4435151 seconds
elapsed time: 0.4234343 seconds
elapsed time: 0.4340528 seconds
...

```

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [July 18, 2021, 7:37pm UTC](https://discourse.julialang.org/t/version-1-7-much-faster-than-1-6-in-a-script-that-calls-wrapped-external-libraries/64872/2 "2021-07-18T19:37:46Z")

</div>

This is really cool. For a hint, I would examine `@code_native` or `@code_llvm` and see where the compiled code diverges. I would pay particular attention to references to out of bounds (oob) checks.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [July 18, 2021, 7:48pm UTC](https://discourse.julialang.org/t/version-1-7-much-faster-than-1-6-in-a-script-that-calls-wrapped-external-libraries/64872/3 "2021-07-18T19:48:16Z")

</div>

Suspiciously short, but anyway exactly equal between 1.6 & 1.7

```julia
julia> @code_native find_apueles(week=30);
        .text
; ┌ @ find_apueles.jl:1 within `find_apueles##kw`
        pushq %rbp
        movq %rsp, %rbp
        subq $32, %rsp
; │ @ find_apueles.jl:3 within `find_apueles##kw`
        movq (%rcx), %rcx
        movabsq $"#find_apueles#4", %rax
        callq *%rax
        addq $32, %rsp
        popq %rbp
        retq
        nopl (%rax)
; └

julia> @code_llvm find_apueles(week=30);
; @ C:\j\jls\find_apueles.jl:1 within `find_apueles##kw`
; Function Attrs: uwtable
define nonnull {}* @"julia_find_apueles##kw_1663"([1 x i64]* nocapture nonnull readonly align 8 dereferenceable(8) %0) #0 {
top:
; @ C:\j\jls\find_apueles.jl:3 within `find_apueles##kw`
; ┌ @ namedtuple.jl:127 within `getindex`
   %1 = getelementptr inbounds [1 x i64], [1 x i64]* %0, i64 0, i64 0
; └
  %2 = load i64, i64* %1, align 8
  %3 = call nonnull {}* @"j_#find_apueles#4_1666"(i64 signext %2) #0
  ret {}* %3
}

julia> versioninfo()
Julia Version 1.7.0-beta2
Commit b570546b68 (2021-06-20 06:31 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.0 (ORCJIT, skylake)
Environment:
  JULIA_NUM_THREADS = 6

```

```julia
julia> @code_native find_apueles(week=1);
        .text
; ┌ @ find_apueles.jl:1 within `find_apueles##kw'
        pushq %rbp
        movq %rsp, %rbp
        subq $32, %rsp
; │ @ find_apueles.jl:3 within `find_apueles##kw'
        movq (%rcx), %rcx
        movabsq $"#find_apueles#4", %rax
        callq *%rax
        addq $32, %rsp
        popq %rbp
        retq
        nopl (%rax)
; └

julia> @code_llvm find_apueles(week=30);
; @ C:\j\jls\find_apueles.jl:1 within `find_apueles##kw'
; Function Attrs: uwtable
define nonnull {}* @"julia_find_apueles##kw_1760"([1 x i64]* nocapture nonnull readonly align 8 dereferenceable(8) %0) #0 {
top:
; @ C:\j\jls\find_apueles.jl:3 within `find_apueles##kw'
; ┌ @ namedtuple.jl:118 within `getindex'
   %1 = getelementptr inbounds [1 x i64], [1 x i64]* %0, i64 0, i64 0
; └
  %2 = load i64, i64* %1, align 8
  %3 = call nonnull {}* @"j_#find_apueles#4_1763"(i64 signext %2) #0
  ret {}* %3
}

julia> versioninfo()
Julia Version 1.6.0
Commit f9720dc2eb (2021-03-24 12:55 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
Environment:
  JULIA_NUM_THREADS = 6

```

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [July 18, 2021, 7:59pm UTC](https://discourse.julialang.org/t/version-1-7-much-faster-than-1-6-in-a-script-that-calls-wrapped-external-libraries/64872/4 "2021-07-18T19:59:00Z")

</div>

I see zero differences in the [benchmarks](https://github.com/giordano/Cuba.jl/tree/285ec44ab2337adbf843d6f20309e8062b45863b/benchmarks) of `Cuba.jl` for julia v1.6 vs master:

```nohighlight
% CUBACORES=0 julia benchmark.jl
[ Info: Performance of Cuba.jl:
  0.251215 seconds (Vegas)
  0.647562 seconds (Suave)
  0.303899 seconds (Divonne)
  0.230467 seconds (Cuhre)
[ Info: Performance of Cuba Library in C:
  0.190322 seconds (Vegas)
  0.620006 seconds (Suave)
  0.248154 seconds (Divonne)
  0.175083 seconds (Cuhre)
[ Info: Performance of Cuba Library in Fortran:
  0.184770 seconds (Vegas)
  0.596291 seconds (Suave)
  0.226675 seconds (Divonne)
  0.155555 seconds (Cuhre)
% CUBACORES=0 julia-master benchmark.jl 
[ Info: Performance of Cuba.jl:
  0.255095 seconds (Vegas)
  0.646028 seconds (Suave)
  0.312925 seconds (Divonne)
  0.227860 seconds (Cuhre)
[ Info: Performance of Cuba Library in C:
  0.195879 seconds (Vegas)
  0.629609 seconds (Suave)
  0.247174 seconds (Divonne)
  0.173440 seconds (Cuhre)
[ Info: Performance of Cuba Library in Fortran:
  0.178327 seconds (Vegas)
  0.587523 seconds (Suave)
  0.226824 seconds (Divonne)
  0.155499 seconds (Cuhre)

```

A 6x difference in FFI overhead is quite large, to not say unrealistic

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [July 18, 2021, 8:48pm UTC](https://discourse.julialang.org/t/version-1-7-much-faster-than-1-6-in-a-script-that-calls-wrapped-external-libraries/64872/5 "2021-07-18T20:48:29Z")

</div>

I agree it’s unrealistic, but what ever is the cause, it exists … and allocates a lot of memory.

```julia
# V1.7
julia> @time find_apueles(week=30);
183.546047 seconds (47.71 M allocations: 2.168 GiB, 0.12% gc time)

```

and

```julia
# V1.6
julia> @time find_apueles(week=30);
1089.193155 seconds (48.76 G allocations: 728.116 GiB, 1.51% gc time, 0.08% compilation time)

```

There is wrapper code before calling the C & C++ libs and the cause likely lies there but still the difference exists and is huge.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [July 18, 2021, 8:54pm UTC](https://discourse.julialang.org/t/version-1-7-much-faster-than-1-6-in-a-script-that-calls-wrapped-external-libraries/64872/6 "2021-07-18T20:54:10Z")

</div>

Have you tried to remove the calls to external libraries? It’s next to impossible the difference you’re seeing has to do with FFI overhead

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [July 18, 2021, 9:25pm UTC](https://discourse.julialang.org/t/version-1-7-much-faster-than-1-6-in-a-script-that-calls-wrapped-external-libraries/64872/7 "2021-07-18T21:25:34Z")

</div>

I’m not sticking to the hypothesis that the speed up comes from FFI improvements. I first thought on it because almost all lines in the script call wrapper code, but after seeing the amount of allocated memory I know nothing anymore.

Can’t remove the calls to external libraries because that would broke the program. I might be able to change one call to one wrapper to another but no more.

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [July 19, 2021, 7:58pm UTC](https://discourse.julialang.org/t/version-1-7-much-faster-than-1-6-in-a-script-that-calls-wrapped-external-libraries/64872/8 "2021-07-19T19:58:48Z")

</div>

I have a suspicion that this is Windows specific.

It may be related to this:

> <https://github.com/JuliaLang/julia/issues/40570>
>
> \# Introduction
> 
> Code loading is 10x slower under Windows versus Windows Subsys…tem for Linux 2 (WSL 2) on the same machine for large binary packages such as \`GR\_jll\`:
> \`\`\`julia
> julia\> @time using GR\_jll # Windows, Julia 1.6.0
> 0.734392 seconds (361.12 k allocations: 24.173 MiB, 0.53% compilation time)
> 
> julia\> @time using GR\_jll # WSL, Julia 1.6.0
> 0.066454 seconds (192.13 k allocations: 14.770 MiB, 4.94% compilation time)
> \`\`\`
> 
> The difference is not as much with smaller packages:
> \`\`\`julia
> julia\> @time using ImarisWriter\_jll # Windows, Julia 1.6.0
> 0.274513 seconds (111.25 k allocations: 8.249 MiB, 1.31% compilation time)
> 
> julia\> @time using ImarisWriter\_jll
> 0.052826 seconds (64.77 k allocations: 5.350 MiB, 6.94% compilation time)
> \`\`\`
> 
> \# Windows
> \`\`\`
> julia\> versioninfo()
> Julia Version 1.6.0
> Commit f9720dc2eb (2021-03-24 12:55 UTC)
> Platform Info:
> OS: Windows (x86\_64-w64-mingw32)
> CPU: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
> WORD\_SIZE: 64
> LIBM: libopenlibm
> LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
> \`\`\`
> 
> \# Windows Subsystem for Linux
> \`\`\`
> julia\> versioninfo()
> Julia Version 1.6.0
> Commit f9720dc2eb (2021-03-24 12:55 UTC)
> Platform Info:
> OS: Linux (x86\_64-pc-linux-gnu)
> CPU: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
> WORD\_SIZE: 64
> LIBM: libopenlibm
> LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
> \`\`\`
> 
> \# Profiling
> 
> \## Protocol
> 
> \`\`\`
> julia\> using Profile
> julia\> Profile.clear()
> julia\> @profile using GR\_jll
> \`\`\`
> 
> \## Windows Profile
> 
> \`\`\`
> julia\> Profile.print(; maxdepth = 16)
> Overhead ╎ \[+additional indent\] Count File:Line; Function
> =========================================================
> ╎306 @Base\\client.jl:485; \_start()
> ╎ 306 @Base\\client.jl:302; exec\_options(opts::Base.JLOptions)
> ╎ 306 @Base\\client.jl:372; run\_main\_repl(interactive::Bool, quiet::Bool, banner::B...
> ╎ 306 @Base\\essentials.jl:706; invokelatest
> ╎ 306 @Base\\essentials.jl:708; #invokelatest#2
> ╎ 306 @Base\\client.jl:387; (::Base.var"#874#876"{Bool, Bool, Bool})(REPL::Module)
> ╎ ╎ 306 ...julia\\stdlib\\v1.6\\REPL\\src\\REPL.jl:305; run\_repl(repl::REPL.AbstractREPL, consumer::Any)
> ╎ ╎ 306 ...julia\\stdlib\\v1.6\\REPL\\src\\REPL.jl:317; run\_repl(repl::REPL.AbstractREPL, consumer::Any; bac...
> ╎ ╎ 306 ...ulia\\stdlib\\v1.6\\REPL\\src\\REPL.jl:185; start\_repl\_backend(backend::REPL.REPLBackend, consum...
> ╎ ╎ 306 ...ulia\\stdlib\\v1.6\\REPL\\src\\REPL.jl:200; repl\_backend\_loop(backend::REPL.REPLBackend)
> ╎ ╎ 306 ...ulia\\stdlib\\v1.6\\REPL\\src\\REPL.jl:139; eval\_user\_input(ast::Any, backend::REPL.REPLBackend)
> 1╎ ╎ ╎ 306 @Base\\boot.jl:360; eval
> ╎ ╎ ╎ 305 @Base\\loading.jl:901; require(into::Module, mod::Symbol)
> ╎ ╎ ╎ 305 @Base\\loading.jl:914; require(uuidkey::Base.PkgId)
> ╎ ╎ ╎ 1 @Base\\loading.jl:987; \_require(pkg::Base.PkgId)
> ╎ ╎ ╎ 1 @Base\\loading.jl:290; locate\_package(pkg::Base.PkgId)
> ╎ ╎ ╎ ╎ 1 @Base\\loading.jl:396; manifest\_uuid\_path(env::String, pkg::Base.PkgId)
> ╎ ╎ ╎ 304 @Base\\loading.jl:998; \_require(pkg::Base.PkgId)
> ╎ ╎ ╎ 1 @Base\\loading.jl:734; \_require\_search\_from\_serialized(pkg::Base.PkgId,...
> ╎ ╎ ╎ ╎ 1 @Base\\loading.jl:641; find\_all\_in\_cache\_path(pkg::Base.PkgId)
> ╎ ╎ ╎ 63 @Base\\loading.jl:736; \_require\_search\_from\_serialized(pkg::Base.PkgId,...
> ╎ ╎ ╎ ╎ 55 @Base\\loading.jl:1716; stale\_cachefile(modpath::String, cachefile::St...
> ╎ ╎ ╎ ╎ 8 @Base\\loading.jl:1750; stale\_cachefile(modpath::String, cachefile::St...
> ╎ ╎ ╎ 2 @Base\\loading.jl:741; \_require\_search\_from\_serialized(pkg::Base.PkgId,...
> ╎ ╎ ╎ ╎ 2 @Base\\file.jl:426; touch(path::String)
> ╎ ╎ ╎ 228 @Base\\loading.jl:749; \_require\_search\_from\_serialized(pkg::Base.PkgId,...
> ╎ ╎ ╎ ╎ 228 @Base\\loading.jl:689; \_tryrequire\_from\_serialized(modkey::Base.PkgId,...
> ╎ ╎ ╎ 10 @Base\\loading.jl:760; \_require\_search\_from\_serialized(pkg::Base.PkgId,...
> ╎ ╎ ╎ ╎ 10 @Base\\loading.jl:674; \_include\_from\_serialized(path::String, depmods:...
> Total snapshots: 314
> \`\`\`
> 
> \### Expansion of \`@Base/loading:998\` (maxdepth = 18)
> 
> \`\`\`
> ╎ ╎ ╎ 304 @Base\\loading.jl:998; \_require(pkg::Base.PkgId)
> ╎ ╎ ╎ 1 @Base\\loading.jl:734; \_require\_search\_from\_serialized(pkg::Base.PkgId, sourcepath::String)
> ╎ ╎ ╎ ╎ 1 @Base\\loading.jl:641; find\_all\_in\_cache\_path(pkg::Base.PkgId)
> ╎ ╎ ╎ ╎ 1 @Base\\loading.jl:14; isfile\_casesensitive(path::String)
> 1╎ ╎ ╎ ╎ 1 @Base\\path.jl:406; longpath(path::String)
> ╎ ╎ ╎ 63 @Base\\loading.jl:736; \_require\_search\_from\_serialized(pkg::Base.PkgId, sourcepath::String)
> ╎ ╎ ╎ ╎ 55 @Base\\loading.jl:1716; stale\_cachefile(modpath::String, cachefile::String)
> ╎ ╎ ╎ ╎ 9 @Base\\loading.jl:0; locate\_package(pkg::Base.PkgId)
> ╎ ╎ ╎ ╎ 9 @Base\\initdefs.jl:313; load\_path()
> ╎ ╎ ╎ ╎ 32 @Base\\loading.jl:290; locate\_package(pkg::Base.PkgId)
> ╎ ╎ ╎ ╎ 8 @Base\\loading.jl:388; manifest\_uuid\_path(env::String, pkg::Base.PkgId)
> ╎ ╎ ╎ ╎ 5 @Base\\loading.jl:390; manifest\_uuid\_path(env::String, pkg::Base.PkgId)
> ╎ ╎ ╎ ╎ 17 @Base\\loading.jl:396; manifest\_uuid\_path(env::String, pkg::Base.PkgId)
> ╎ ╎ ╎ ╎ 2 @Base\\loading.jl:399; manifest\_uuid\_path(env::String, pkg::Base.PkgId)
> ╎ ╎ ╎ ╎ 14 @Base\\loading.jl:291; locate\_package(pkg::Base.PkgId)
> ╎ ╎ ╎ ╎ 3 @Base\\loading.jl:464; entry\_path(path::String, name::String)
> ╎ ╎ ╎ ╎ 11 @Base\\loading.jl:466; entry\_path(path::String, name::String)
> ╎ ╎ ╎ ╎ 8 @Base\\loading.jl:1750; stale\_cachefile(modpath::String, cachefile::String)
> ╎ ╎ ╎ ╎ 1 @Base\\loading.jl:253; identify\_package(where::Base.PkgId, name::String)
> ╎ ╎ ╎ ╎ 1 @Base\\initdefs.jl:313; load\_path()
> ╎ ╎ ╎ ╎ 7 @Base\\loading.jl:254; identify\_package(where::Base.PkgId, name::String)
> ╎ ╎ ╎ ╎ 1 @Base\\loading.jl:369; manifest\_deps\_get(env::String, where::Base.PkgId, name::String)
> ╎ ╎ ╎ ╎ 2 @Base\\loading.jl:372; manifest\_deps\_get(env::String, where::Base.PkgId, name::String)
> ╎ ╎ ╎ ╎ 4 @Base\\loading.jl:379; manifest\_deps\_get(env::String, where::Base.PkgId, name::String)
> ╎ ╎ ╎ 2 @Base\\loading.jl:741; \_require\_search\_from\_serialized(pkg::Base.PkgId, sourcepath::String)
> ╎ ╎ ╎ ╎ 2 @Base\\file.jl:426; touch(path::String)
> ╎ ╎ ╎ ╎ 2 @Base\\filesystem.jl:87; open(path::String, flags::UInt16, mode::UInt16)
> ╎ ╎ ╎ ╎ 2 @Base\\strings\\io.jl:174; string
> ╎ ╎ ╎ 228 @Base\\loading.jl:749; \_require\_search\_from\_serialized(pkg::Base.PkgId, sourcepath::String)
> ╎ ╎ ╎ ╎ 228 @Base\\loading.jl:689; \_tryrequire\_from\_serialized(modkey::Base.PkgId, build\_id::UInt64, modpath::String)
> ╎ ╎ ╎ ╎ 16 @Base\\loading.jl:734; \_require\_search\_from\_serialized(pkg::Base.PkgId, sourcepath::String)
> ╎ ╎ ╎ ╎ 2 @Base\\loading.jl:634; find\_all\_in\_cache\_path(pkg::Base.PkgId)
> ╎ ╎ ╎ ╎ 1 @Base\\loading.jl:635; find\_all\_in\_cache\_path(pkg::Base.PkgId)
> ╎ ╎ ╎ ╎ 11 @Base\\loading.jl:641; find\_all\_in\_cache\_path(pkg::Base.PkgId)
> ╎ ╎ ╎ ╎ 2 @Base\\loading.jl:647; find\_all\_in\_cache\_path(pkg::Base.PkgId)
> ╎ ╎ ╎ ╎ 124 @Base\\loading.jl:736; \_require\_search\_from\_serialized(pkg::Base.PkgId, sourcepath::String)
> ╎ ╎ ╎ ╎ 2 @Base\\loading.jl:1691; stale\_cachefile(modpath::String, cachefile::String)
> ╎ ╎ ╎ ╎ 2 @Base\\loading.jl:1693; stale\_cachefile(modpath::String, cachefile::String)
> ╎ ╎ ╎ ╎ 3 @Base\\loading.jl:1697; stale\_cachefile(modpath::String, cachefile::String)
> ╎ ╎ ╎ ╎ 29 @Base\\loading.jl:1716; stale\_cachefile(modpath::String, cachefile::String)
> ╎ ╎ ╎ ╎ 4 @Base\\loading.jl:1744; stale\_cachefile(modpath::String, cachefile::String)
> ╎ ╎ ╎ ╎ 71 @Base\\loading.jl:1750; stale\_cachefile(modpath::String, cachefile::String)
> ╎ ╎ ╎ ╎ 1 @Base\\loading.jl:1759; stale\_cachefile(modpath::String, cachefile::String)
> ╎ ╎ ╎ ╎ 1 @Base\\loading.jl:1767; stale\_cachefile(modpath::String, cachefile::String)
> ╎ ╎ ╎ ╎ 10 @Base\\loading.jl:1773; stale\_cachefile(modpath::String, cachefile::String)
> ╎ ╎ ╎ ╎ 1 @Base\\loading.jl:1784; stale\_cachefile(modpath::String, cachefile::String)
> ╎ ╎ ╎ ╎ 51 @Base\\loading.jl:749; \_require\_search\_from\_serialized(pkg::Base.PkgId, sourcepath::String)
> ╎ ╎ ╎ ╎ 51 @Base\\loading.jl:689; \_tryrequire\_from\_serialized(modkey::Base.PkgId, build\_id::UInt64, modpath::String)
> ╎ ╎ ╎ ╎ 37 @Base\\loading.jl:760; \_require\_search\_from\_serialized(pkg::Base.PkgId, sourcepath::String)
> 6╎ ╎ ╎ ╎ 6 @Base\\loading.jl:658; \_include\_from\_serialized(path::String, depmods::Vector{Any})
> 4╎ ╎ ╎ ╎ 31 @Base\\loading.jl:674; \_include\_from\_serialized(path::String, depmods::Vector{Any})
> ╎ ╎ ╎ 10 @Base\\loading.jl:760; \_require\_search\_from\_serialized(pkg::Base.PkgId, sourcepath::String)
> ╎ ╎ ╎ ╎ 10 @Base\\loading.jl:674; \_include\_from\_serialized(path::String, depmods::Vector{Any})
> ╎ ╎ ╎ ╎ 10 @Base\\libdl.jl:114; dlopen(s::String, flags::UInt32)
> 10╎ ╎ ╎ ╎ 10 @Base\\libdl.jl:114; dlopen(s::String, flags::UInt32; throw\_error::Bool)
> \`\`\`
> 
> \## Windows Subsystem for Linux Profile
> 
> \`\`\`
> julia\> Profile.print(; maxdepth = 16)
> Overhead ╎ \[+additional indent\] Count File:Line; Function
> =========================================================
> ╎61 @Base/client.jl:485; \_start()
> ╎ 61 @Base/client.jl:302; exec\_options(opts::Base.JLOptions)
> ╎ 61 @Base/client.jl:372; run\_main\_repl(interactive::Bool, quiet::Bool, banner::Boo...
> ╎ 61 @Base/essentials.jl:706; invokelatest
> ╎ 61 @Base/essentials.jl:708; #invokelatest#2
> ╎ 61 @Base/client.jl:387; (::Base.var"#874#876"{Bool, Bool, Bool})(REPL::Module)
> ╎ ╎ 61 .../julia/stdlib/v1.6/REPL/src/REPL.jl:305; run\_repl(repl::REPL.AbstractREPL, consumer::Any)
> ╎ ╎ 61 .../julia/stdlib/v1.6/REPL/src/REPL.jl:317; run\_repl(repl::REPL.AbstractREPL, consumer::Any; backe...
> ╎ ╎ 61 ...julia/stdlib/v1.6/REPL/src/REPL.jl:185; start\_repl\_backend(backend::REPL.REPLBackend, consume...
> ╎ ╎ 61 ...julia/stdlib/v1.6/REPL/src/REPL.jl:200; repl\_backend\_loop(backend::REPL.REPLBackend)
> ╎ ╎ 61 ...ulia/stdlib/v1.6/REPL/src/REPL.jl:139; eval\_user\_input(ast::Any, backend::REPL.REPLBackend)
> 1╎ ╎ ╎ 61 @Base/boot.jl:360; eval
> ╎ ╎ ╎ 60 @Base/loading.jl:901; require(into::Module, mod::Symbol)
> ╎ ╎ ╎ 60 @Base/loading.jl:914; require(uuidkey::Base.PkgId)
> ╎ ╎ ╎ 60 @Base/loading.jl:998; \_require(pkg::Base.PkgId)
> ╎ ╎ ╎ 3 @Base/loading.jl:736; \_require\_search\_from\_serialized(pkg::Base.PkgId, ...
> ╎ ╎ ╎ ╎ 3 @Base/loading.jl:1716; stale\_cachefile(modpath::String, cachefile::String)
> ╎ ╎ ╎ 2 @Base/loading.jl:741; \_require\_search\_from\_serialized(pkg::Base.PkgId, ...
> ╎ ╎ ╎ ╎ 2 @Base/file.jl:426; touch(path::String)
> ╎ ╎ ╎ 54 @Base/loading.jl:749; \_require\_search\_from\_serialized(pkg::Base.PkgId, ...
> ╎ ╎ ╎ ╎ 54 @Base/loading.jl:689; \_tryrequire\_from\_serialized(modkey::Base.PkgId, ...
> ╎ ╎ ╎ 1 @Base/loading.jl:760; \_require\_search\_from\_serialized(pkg::Base.PkgId, ...
> ╎ ╎ ╎ ╎ 1 @Base/loading.jl:674; \_include\_from\_serialized(path::String, depmods::...
> Total snapshots: 68
> \`\`\`
> 
> \### Expansion of \`@Base/loading:998\` (maxdepth = 18)
> \`\`\`
> ╎ ╎ ╎ 57 @Base/loading.jl:998; \_require(pkg::Base.PkgId)
> ╎ ╎ ╎ 3 @Base/loading.jl:736; \_require\_search\_from\_serialized(pkg::Base.PkgId, ...
> ╎ ╎ ╎ ╎ 3 @Base/loading.jl:1716; stale\_cachefile(modpath::String, cachefile::String)
> ╎ ╎ ╎ ╎ 1 @Base/loading.jl:0; locate\_package(pkg::Base.PkgId)
> ╎ ╎ ╎ ╎ 1 @Base/initdefs.jl:313; load\_path()
> ╎ ╎ ╎ ╎ 2 @Base/loading.jl:290; locate\_package(pkg::Base.PkgId)
> ╎ ╎ ╎ ╎ 2 @Base/loading.jl:396; manifest\_uuid\_path(env::String, pkg::Base.PkgId)
> ╎ ╎ ╎ 2 @Base/loading.jl:741; \_require\_search\_from\_serialized(pkg::Base.PkgId, ...
> ╎ ╎ ╎ ╎ 2 @Base/file.jl:426; touch(path::String)
> ╎ ╎ ╎ ╎ 2 @Base/filesystem.jl:87; open(path::String, flags::UInt16, mode::UInt16)
> ╎ ╎ ╎ ╎ 2 @Base/strings/io.jl:174; string
> ╎ ╎ ╎ 52 @Base/loading.jl:749; \_require\_search\_from\_serialized(pkg::Base.PkgId, ...
> ╎ ╎ ╎ ╎ 52 @Base/loading.jl:689; \_tryrequire\_from\_serialized(modkey::Base.PkgId, ...
> ╎ ╎ ╎ ╎ 9 @Base/loading.jl:736; \_require\_search\_from\_serialized(pkg::Base.PkgId,...
> ╎ ╎ ╎ ╎ 4 @Base/loading.jl:1716; stale\_cachefile(modpath::String, cachefile::St...
> ╎ ╎ ╎ ╎ 4 @Base/loading.jl:1750; stale\_cachefile(modpath::String, cachefile::St...
> ╎ ╎ ╎ ╎ 1 @Base/loading.jl:1773; stale\_cachefile(modpath::String, cachefile::St...
> ╎ ╎ ╎ ╎ 1 @Base/loading.jl:741; \_require\_search\_from\_serialized(pkg::Base.PkgId,...
> ╎ ╎ ╎ ╎ 1 @Base/file.jl:426; touch(path::String)
> ╎ ╎ ╎ ╎ 27 @Base/loading.jl:749; \_require\_search\_from\_serialized(pkg::Base.PkgId,...
> ╎ ╎ ╎ ╎ 27 @Base/loading.jl:689; \_tryrequire\_from\_serialized(modkey::Base.PkgId,...
> ╎ ╎ ╎ ╎ 15 @Base/loading.jl:760; \_require\_search\_from\_serialized(pkg::Base.PkgId,...
> 4╎ ╎ ╎ ╎ 4 @Base/loading.jl:658; \_include\_from\_serialized(path::String, depmods:...
> 5╎ ╎ ╎ ╎ 11 @Base/loading.jl:674; \_include\_from\_serialized(path::String, depmods:...
> \`\`\`

> <https://github.com/JuliaLang/julia/pull/40890>
>
> Ref https://github.com/JuliaLang/julia/issues/40570
> 
> Some background on the co…de loading code:
> 
> The parsing of TOML files used to be implemented completely stateless. When asking for example what UUID a package the TOML parsing system would look through the TOML files line by line until it found it. Asking for another package, it would start from scratch again. This caused these files to have to be opened and closed a large number of times https://github.com/JuliaLang/julia/issues/27414#issuecomment-555037342.
> 
> In https://github.com/JuliaLang/julia/pull/36018 code loading was made to use a real TOML parser and in https://github.com/JuliaLang/julia/pull/37906 a cache was introduced to avoid having to reparse the same TOML file over and over.
> 
> However, a lot of the "statelessness" from the old code loading still exists. For example, every time \`load\_path\` is called, Julia goes through the file system and looks around for project files. This is called many many times for a single \`using\` call. One way to measure how much julia hits the file system is by running with \`strace\` and looking for different \`stat\` calls:
> 
> \`\`\`
> ❯ strace -o stat\_master julia -e 'using GR\_jll'
> 
> ❯ cat stat\_master | grep -c statx
> 9322
> \`\`\`
> 
> Looking in the file we can for example see
> 
> \`\`\`
> lstat("/home", {st\_mode=S\_IFDIR|0755, st\_size=4096, ...}) = 0
> lstat("/home/kc", {st\_mode=S\_IFDIR|0755, st\_size=4096, ...}) = 0
> lstat("/home/kc/.julia", {st\_mode=S\_IFDIR|0775, st\_size=4096, ...}) = 0
> lstat("/home/kc/.julia/environments", {st\_mode=S\_IFDIR|0775, st\_size=4096, ...}) = 0
> lstat("/home/kc/.julia/environments/v1.6", {st\_mode=S\_IFDIR|0775, st\_size=4096, ...}) = 0
> lstat("/home/kc/.julia/environments/v1.6/Project.toml", {st\_mode=S\_IFREG|0664, st\_size=3711, ...}) = 0
> \`\`\`
> 
> being called over and over (corresponding to https://github.com/JuliaLang/julia/blob/27066a7ad2eb2950ac02281cb3dfc0c8eb1733f4/base/loading.jl#L133).
> 
> This PR assumes that within a single \`require\` calls, things like the load path, the content of Project files, etc will not change. This is a bit similar to the restriction we have on "world age".
> 
> With this PR we get:
> 
> \`\`\`
> ❯ strace -o stat\_pr ./julia -e 'using GR\_jll'
> 
> ❯ cat stat\_pr | grep -c stat
> 2252
> \`\`\`
> 
> which is a quite significant reduction.
> 
> I admit that the implementation here is ugly but I consider this just as an ephemeral state of things for 1.7. For 1.8 I want to do a proper update of the code loading and do something similar that was started in https://github.com/JuliaLang/julia/pull/37632 to propagate path info to precompile workers so that only the main worker has to do any package location lookups.
> 
> @mkitti perhaps you could do some measurements on Windows and see if this improves https://github.com/JuliaLang/julia/issues/40570?

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [July 19, 2021, 8:56pm UTC](https://discourse.julialang.org/t/version-1-7-much-faster-than-1-6-in-a-script-that-calls-wrapped-external-libraries/64872/9 "2021-07-19T20:56:23Z")

</div>

> [@mkitti](#):
>
> It may be related to this:

Isn’t the pull request you linked specific to package loading and what is timed here is _not_ package loading?

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [July 20, 2021, 12:33am UTC](https://discourse.julialang.org/t/version-1-7-much-faster-than-1-6-in-a-script-that-calls-wrapped-external-libraries/64872/10 "2021-07-20T00:33:14Z")

</div>

> [@giordano](#):
>
> Isn’t the pull request you linked specific to package loading and what is timed here is _not_ package loading?

Yes, you are probably right. However, joa-quim also mentioned “wrapper code” which might be code loading related:

> [@joa-quim](#):
>
> There is wrapper code before calling the C & C++ libs and the cause likely lies there but still the difference exists and is huge.

More generally my thought is that this has something to do with slow file system operations on Windows and Julia 1.7 reducing its dependence on those file system operations.

Another example might be reducing the use of `realpath`:

> <https://github.com/JuliaLang/julia/pull/40233>
>
> As \[discussed recently on discourse\](https://discourse.julialang.org/t/weird-sys…-which-function/58070), some programs require a certain executable name to function correctly, and behave badly if you call \`realpath\` to expand symbolic links (potentially changing the program name).
> 
> \#26559 by @staticfloat implemented \`Sys.which\`, but there doesn't seem to have been any discussion about whether \`realpath\` was a good idea.

Some of the eternal library use cited above is done by running external processes.

Anyways, I’m speculating wildly since we have very few leads.

Let’s do some [profiling](https://docs.julialang.org/en/v1/manual/profile/) to narrow down the possibilities of where the speedup is happening. It would also be great if we could produce a minimum working example showing the speedup. Is it a particular external library or process that is faster?

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [July 20, 2021, 1:16am UTC](https://discourse.julialang.org/t/version-1-7-much-faster-than-1-6-in-a-script-that-calls-wrapped-external-libraries/64872/11 "2021-07-20T01:16:41Z")

</div>

> [@joa-quim](#):
>
> `Di = grdtrack(o, G, s=true, V=:q)`

I’ve done some more investigation and I think the above line is the one where the large time difference occurs. What it does in current case is to take an in memory grid G (basically a 2D array) and a Mx2 array, send them to the GMT lib that will interpolate the grid `G` at locations of the `lon, lat` positions `o` and return a Mx3 matrix with the result. Now, given the Julia column-major vs C row-major nature it normally has make a copy and transpose, though I try to avoid it when I can. However, nothing of this is specific of the `grdtrack` module. Many of the array operations in GMT go trough the same function.

This will need further investigation to find out where the culprit hides but I don’t have much time in the next days. I’ve also no idea on how to make a MWE of this that does not involve the use of that GMT module.

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [July 20, 2021, 1:44am UTC](https://discourse.julialang.org/t/version-1-7-much-faster-than-1-6-in-a-script-that-calls-wrapped-external-libraries/64872/12 "2021-07-20T01:44:48Z")

</div>

Could you build an example around `grdtrack`? Setup a small self-contained example where you load the required modules and initialize `o` and `G` for us. Demonstrate the disparate timings on 1.6 and 1.7.

We can then run the same small example and see if we see the same timings.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [July 20, 2021, 2:16am UTC](https://discourse.julialang.org/t/version-1-7-much-faster-than-1-6-in-a-script-that-calls-wrapped-external-libraries/64872/13 "2021-07-20T02:16:58Z")

</div>

Ok, this simple one shows the difference. It builds a dumb grid of 1001x1001 Float32 with a constant value of 1 and interpolates at at single location (lon=-10, lat=35)

v1.6

```julia
julia> G = gmt("grdmath -R-20/0/25/45 -I0.02 1");

julia> using BenchmarkTools

julia> @btime grdtrack([-10 35], G);
  58.958 ms (3007132 allocations: 45.94 MiB)

julia> versioninfo()
Julia Version 1.6.0
Commit f9720dc2eb (2021-03-24 12:55 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
Environment:
  JULIA_NUM_THREADS = 6

```

Now v1.7

```julia
julia> G = gmt("grdmath -R-20/0/25/45 -I0.02 1");

julia> using BenchmarkTools

julia> @btime grdtrack([-10 35], G);
  7.638 ms (1142 allocations: 73.59 KiB)

julia> versioninfo()
Julia Version 1.7.0-beta2
Commit b570546b68 (2021-06-20 06:31 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.0 (ORCJIT, skylake)
Environment:
  JULIA_NUM_THREADS = 6

```

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [July 20, 2021, 4:54am UTC](https://discourse.julialang.org/t/version-1-7-much-faster-than-1-6-in-a-script-that-calls-wrapped-external-libraries/64872/14 "2021-07-20T04:54:48Z")

</div>

I was able to replicate your example:

Julia 1.6.0

```julia
julia> using GMT

julia> G = gmt("grdmath -R-20/0/25/45 -I0.02 1");

julia> using BenchmarkTools

julia> @btime grdtrack([-10 35], G);
  58.716 ms (3007131 allocations: 45.94 MiB)

julia> versioninfo()
Julia Version 1.6.0
Commit f9720dc2eb (2021-03-24 12:55 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, skylake)

```

Julia 1.7.01.7.0-DEV.1129 (1172c6b129)

```julia
julia> using GMT

julia> G = gmt("grdmath -R-20/0/25/45 -I0.02 1");

julia> using BenchmarkTools

julia> @btime grdtrack([-10 35], G);
  5.983 ms (1116 allocations: 72.25 KiB)

julia> versioninfo()
Julia Version 1.7.0-DEV.1129
Commit 1172c6b129* (2021-05-24 11:41 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, skylake)

```

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [July 20, 2021, 5:05am UTC](https://discourse.julialang.org/t/version-1-7-much-faster-than-1-6-in-a-script-that-calls-wrapped-external-libraries/64872/15 "2021-07-20T05:05:25Z")

</div>

Here’s what I was able to profile via the following commands

```julia
julia> using Profile

julia> @profile grdtrack([-10 35], G)
Vector{GMT.GMTdataset} with 1 segments
First segment DATA
1×3 Matrix{Float64}:
 -10.0 35.0 1.0

julia> Profile.print(; C = true)  

```

Julia 1.6.0

```julia
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ 68 /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1703; jl_apply
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ 68 @GMT\src\grdtrack.jl:121; grdtrack(arg1::Matrix{Int64}, arg2::GMT.GMTgrid{Float32, 2})
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ 68 @GMT\src\grdtrack.jl:121; grdtrack
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ 68 @GMT\src\grdtrack.jl:121; #grdtrack#237
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ 68 @GMT\src\grdtrack.jl:64; grdtrack
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 68 @GMT\src\grdtrack.jl:94; grdtrack(cmd0::String, arg1::Matrix{Int64}, arg2::GMT.GMTgrid{Float32, 2}; kwargs::Base.Iterators.Pairs{Uni...
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 68 @GMT\src\common_options.jl:3062; common_grd(::Dict{Symbol, Any}, ::String, ::Matrix{Int64}, ::GMT.GMTgrid{Float32, 2})
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 66 @GMT\src\gmt_main.jl:272; gmt(::String, ::Matrix{Int64}, ::Vararg{Any, N} where N)
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 66 [unknown stackframe]
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 66 @GMT\src\gmt_main.jl:759; GMTJL_Set_Object(API::Ptr{Nothing}, X::GMT.GMT_RESOURCE, ptr::GMT.GMTgrid{Float32, 2}, pad::Int64)
2╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 66 @GMT\src\gmt_main.jl:866; grid_init(API::Ptr{Nothing}, X::GMT.GMT_RESOURCE, Grid::GMT.GMTgrid{Float32, 2}, pad::Int64, cube::Bool)
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 @Base\array.jl:801; getindex
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 33 @Base\operators.jl:560; +
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 14 /cygdrive/c/buildbot/worker/package_win64/build/src\datatype.c:841; jl_box_int64
2╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 8 /cygdrive/c/buildbot/worker/package_win64/build/src\julia_internal.h:285; jl_gc_alloc_
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:1206; jl_gc_pool_alloc
2╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 2 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:1223; jl_gc_pool_alloc
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 2 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:1240; jl_gc_pool_alloc
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 2 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:1183; add_page
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 2 /cygdrive/c/buildbot/worker/package_win64/build/src\gc-pages.c:250; jl_gc_alloc_page
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 2 C:\WINDOWS\System32\KERNELBASE.dll:?; VirtualAlloc
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 2 C:\WINDOWS\System32\umppc13702.dll:?;
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 2 C:\WINDOWS\System32\umppc13702.dll:?;
2╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 2 C:\WINDOWS\SYSTEM32\ntdll.dll:?; NtAllocateVirtualMemory
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:1245; jl_gc_pool_alloc
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 2 /cygdrive/c/buildbot/worker/package_win64/build/src\threading.c:117; jl_get_ptls_states
2╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 2 /usr/x86_64-w64-mingw32/sys-root/mingw/include/psdk_inc\intrin-impl.h:790; __readgsqword
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\threading.c:125; jl_get_ptls_states
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 C:\WINDOWS\System32\KERNEL32.DLL:?; BaseDumpAppcompatCacheWorker
2╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 2 /cygdrive/c/buildbot/worker/package_win64/build/src\threading.c:127; jl_get_ptls_states
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2413; jl_apply_generic
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2414; jl_apply_generic
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 10 /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2415; jl_apply_generic
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2288; jl_lookup_generic_
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2314; jl_lookup_generic_
2╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 4 /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2336; jl_lookup_generic_
2╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 2 /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2250; sig_match_fast
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 3 /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2337; jl_lookup_generic_
2╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 2 /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2250; sig_match_fast
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2410; jl_lookup_generic_
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2420; jl_apply_generic
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 6 [unknown stackframe]
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 @Base\int.jl:923; +(a::Int64, b::UInt64)
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 4 /cygdrive/c/buildbot/worker/package_win64/build/src\datatype.c:842; jl_box_uint64
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 4 /cygdrive/c/buildbot/worker/package_win64/build/src\julia_internal.h:285; jl_gc_alloc_
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:1195; jl_gc_pool_alloc
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:1204; jl_gc_pool_alloc
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\julia_threads.h:306; maybe_collect
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\julia_threads.h:313; jl_gc_state_set
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:1244; jl_gc_pool_alloc
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 @Base\range.jl:674; iterate
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 @Base\promotion.jl:410; ==
3╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 10 /cygdrive/c/buildbot/worker/package_win64/build/src\datatype.c:798; jl_box_float32
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 7 /cygdrive/c/buildbot/worker/package_win64/build/src\julia_internal.h:285; jl_gc_alloc_
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 3 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:1204; jl_gc_pool_alloc
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 3 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:880; maybe_collect
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 3 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:3241; jl_gc_collect
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:3034; _jl_gc_collect
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:2207; gc_mark_loop
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:1816; gc_mark_scan_objarray
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:1705; gc_try_setmark
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 2 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:3148; _jl_gc_collect
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 2 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:1530; gc_sweep_pool
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 2 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:1455; sweep_pool_pagetable
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 2 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:1425; sweep_pool_pagetable1
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 2 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:1405; sweep_pool_pagetable0
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 2 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:1385; sweep_pool_page
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:1317; sweep_page
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:1337; sweep_page
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:1223; jl_gc_pool_alloc
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:1224; jl_gc_pool_alloc
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:1228; jl_gc_pool_alloc
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\gc.c:1243; jl_gc_pool_alloc
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 3 /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2414; jl_apply_generic
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\threading.c:115; jl_get_ptls_states
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 2 /cygdrive/c/buildbot/worker/package_win64/build/src\threading.c:125; jl_get_ptls_states
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 C:\WINDOWS\System32\KERNEL32.DLL:?; BaseDumpAppcompatCacheWorker
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 10 /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2415; jl_apply_generic
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2288; jl_lookup_generic_
4╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 4 /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2336; jl_lookup_generic_
3╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 5 /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2337; jl_lookup_generic_
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 2 /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2247; sig_match_fast
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2253; sig_match_fast
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2256; sig_match_fast
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 /cygdrive/c/buildbot/worker/package_win64/build/src\gf.c:2420; jl_apply_generic
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 5 [unknown stackframe]
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 4 @Base\multidimensional.jl:639; setindex!(::Vector{Float32}, ::Float32, ::UInt64)
4╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 4 @Base\array.jl:839; setindex!
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 @GMT\src\gmt_main.jl:276; gmt(::String, ::Matrix{Int64}, ::Vararg{Any, N} where N)
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 @GMT\src\libgmt.jl:147; GMT_Call_Module
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 c:\programs\gmt6\bin\gmt_w64.dll:?; GMT_Call_Module
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 c:\programs\gmt6\bin\gmt_w64.dll:?; GMT_grdtrack
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 c:\programs\gmt6\bin\gmt_w64.dll:?; gmt_end_module
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 c:\programs\gmt6\bin\gmt_w64.dll:?; gmtlib_free_tmp_arrays
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 c:\programs\gmt6\bin\gmt_w64.dll:?; gmt_free_func
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 C:\WINDOWS\System32\ucrtbase.dll:?; free_base
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 C:\WINDOWS\SYSTEM32\ntdll.dll:?; RtlFreeHeap
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 C:\WINDOWS\SYSTEM32\ntdll.dll:?; RtlGetCurrentServiceSessionId
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 C:\WINDOWS\SYSTEM32\ntdll.dll:?; RtlGetCurrentServiceSessionId
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 C:\WINDOWS\SYSTEM32\ntdll.dll:?; RtlTryAcquirePebLock
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 C:\WINDOWS\SYSTEM32\ntdll.dll:?; NtFreeVirtualMemory
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 @GMT\src\gmt_main.jl:313; gmt(::String, ::Matrix{Int64}, ::Vararg{Any, N} where N)
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 @GMT\src\libgmt.jl:86; GMT_Destroy_Data
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 c:\programs\gmt6\bin\gmt_w64.dll:?; GMT_Destroy_Data
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 c:\programs\gmt6\bin\gmt_w64.dll:?; gmt_whole_earth
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 c:\programs\gmt6\bin\gmt_w64.dll:?; gmt_free_grid
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 c:\programs\gmt6\bin\gmt_w64.dll:?; gmtlib_free_grid_ptr
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 c:\programs\gmt6\bin\gmt_w64.dll:?; gmt_free_func
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 C:\WINDOWS\System32\ucrtbase.dll:?; free_base
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 C:\WINDOWS\SYSTEM32\ntdll.dll:?; RtlFreeHeap
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 C:\WINDOWS\SYSTEM32\ntdll.dll:?; RtlGetCurrentServiceSessionId
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 C:\WINDOWS\SYSTEM32\ntdll.dll:?; RtlGetCurrentServiceSessionId
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 C:\WINDOWS\SYSTEM32\ntdll.dll:?; RtlTryAcquirePebLock
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 C:\WINDOWS\SYSTEM32\ntdll.dll:?; NtFreeVirtualMemory

```

Julia 1.7.0-DEV.1129

```julia
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ 5 /cygdrive/c/Users/kittisopikulm/source/repos/julia/src\julia.h:1760; jl_apply
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ 5 @GMT\src\grdtrack.jl:121; grdtrack(arg1::Matrix{Int64}, arg2::GMT.GMTgrid{Float32, 2})
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ 5 @GMT\src\grdtrack.jl:121; grdtrack
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ 5 @GMT\src\grdtrack.jl:121; #grdtrack#237
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ 5 @GMT\src\grdtrack.jl:64; grdtrack
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 5 @GMT\src\grdtrack.jl:94; grdtrack(cmd0::String, arg1::Matrix{Int64}, arg2::GMT.GMTgrid{Float32, 2}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTup...
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 5 @GMT\src\common_options.jl:3062; common_grd(::Dict{Symbol, Any}, ::String, ::Matrix{Int64}, ::GMT.GMTgrid{Float32, 2})
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 4 @GMT\src\gmt_main.jl:272; gmt(::String, ::Matrix{Int64}, ::Vararg{Any})
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 4 [unknown stackframe]
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 4 @GMT\src\gmt_main.jl:759; GMTJL_Set_Object(API::Ptr{Nothing}, X::GMT.GMT_RESOURCE, ptr::GMT.GMTgrid{Float32, 2}, pad::Int64)
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 4 @GMT\src\gmt_main.jl:866; grid_init(API::Ptr{Nothing}, X::GMT.GMT_RESOURCE, Grid::GMT.GMTgrid{Float32, 2}, pad::Int64, cube::Bool)
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 @Base\int.jl:87; +
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 3 @Base\multidimensional.jl:646; setindex!
3╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 3 @Base\array.jl:875; setindex!
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 @GMT\src\gmt_main.jl:276; gmt(::String, ::Matrix{Int64}, ::Vararg{Any})
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 @GMT\src\libgmt.jl:147; GMT_Call_Module
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 C:\programs\gmt6\bin\gmt_w64.dll:?; GMT_Call_Module
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 C:\programs\gmt6\bin\gmt_w64.dll:?; GMT_grdtrack
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 C:\programs\gmt6\bin\gmt_w64.dll:?; GMT_Read_Data
 ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 C:\programs\gmt6\bin\gmt_w64.dll:?; gmt_whole_earth
1╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ ╎ 1 C:\programs\gmt6\bin\gmt_w64.dll:?; gmt_grd_BC_set

```

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [July 20, 2021, 5:39am UTC](https://discourse.julialang.org/t/version-1-7-much-faster-than-1-6-in-a-script-that-calls-wrapped-external-libraries/64872/16 "2021-07-20T05:39:55Z")

</div>

The main difference seems to be in the execution of [gmt\_main.jl:866 at GMT v0.35.0](https://github.com/GenericMappingTools/GMT.jl/blob/cae0a5fa233fae9417ae88d3f264a61e3924c04e/src/gmt_main.jl#L866):

Julia 1.6.0

> [@mkitti](#):
>
> ```julia
> 66 @GMT\src\gmt_main.jl:866; grid_init(API::Ptr{Nothing}, X::GMT.GMT_RESOURCE, Grid::GMT.GMTgrid{Float32, 2}, pad::Int64, cube::Bool)
> ╎ 1 @Base\array.jl:801; getindex
> ╎ 33 @Base\operators.jl:560; +
> 
> ```

Julia 1.7.0-DEV

> [@mkitti](#):
>
> ```julia
> 4 @GMT\src\gmt_main.jl:866; grid_init(API::Ptr{Nothing}, X::GMT.GMT_RESOURCE, Grid::GMT.GMTgrid{Float32, 2}, pad::Int64, cube::Bool)
> 
> ```

Julia 1.6.0 seems to spend much more time on Line 560 of base/operators.jl which involves argument list folding via `afoldl`:

> <https://github.com/JuliaLang/julia/blob/v1.6.0/base/operators.jl#L560>

While that line has not changed in Julia 1.7, `afoldl` has changed:

> <https://github.com/JuliaLang/julia/pull/40468>
>
> Fixes https://github.com/JuliaGPU/GPUArrays.jl/issues/333 and https://github.com…/JuliaGPU/GPUArrays.jl/issues/340 and restores behaviour compatible with https://github.com/JuliaLang/julia/pull/27398
> 
> cc @GiggleLiu, @maleadt

It looks like you have @kslimes to thank for this amazing improvement in speed.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [July 20, 2021, 11:28am UTC](https://discourse.julialang.org/t/version-1-7-much-faster-than-1-6-in-a-script-that-calls-wrapped-external-libraries/64872/17 "2021-07-20T11:28:18Z")

</div>

Thanks for digging this out. A nice example also on how to use the profiler. Big thanks to @kshyatt

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [September 8, 2021, 7:15pm UTC](https://discourse.julialang.org/t/version-1-7-much-faster-than-1-6-in-a-script-that-calls-wrapped-external-libraries/64872/18 "2021-09-08T19:15:10Z")

</div>

I’m beginning to think I may be pointing at the wrong change since redefining `afoldl` before the above change does not result in a significant slow down. It may be this change by @jameson instead:  
[https://github.com/JuliaLang/julia/pull/39414](https://github.com/JuliaLang/julia/pull/39414)
