# Performance

**URL:** https://discourse.julialang.org/c/usage/perf/37.md?page=69

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

**Page:** 70

---

## [Why does BenchmarkTools \`@belapsed\` make so many allocations?](https://discourse.julialang.org/t/why-does-benchmarktools-belapsed-make-so-many-allocations/78433)

<div class="topic-metadata">

**Author:** [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Replies:** 2\
**Last updated:** [March 25, 2022, 5:07am UTC](https://discourse.julialang.org/t/why-does-benchmarktools-belapsed-make-so-many-allocations/78433 "2022-03-25T05:07:24Z")

</div>

For a long time, I have been hard-coding my own benchmarks using expressions like minimum(@elapsed f() for \_ in 1:samples). It was brought to my attention that BenchmarkTools.jl does this kind of repeated sampling automa…

---

## [Advice to make getfield(::NamedTuple, ::Symbol) typestable](https://discourse.julialang.org/t/advice-to-make-getfield-namedtuple-symbol-typestable/78340)

<div class="topic-metadata">

**Author:** [@ianfiske](https://discourse.julialang.org/u/ianfiske)\
**Replies:** 19\
**Last updated:** [March 25, 2022, 12:29am UTC](https://discourse.julialang.org/t/advice-to-make-getfield-namedtuple-symbol-typestable/78340 "2022-03-25T00:29:54Z")

</div>

I have a complicated nested NamedTuple, where profiling shows that getindex on the NamedTuple is a significant source of slowness. @code\_warntype shows a type instability from getindex on that NamedTuple in the slow cal…

---

## [Avoid runtime dispatch when overloading \`isless()\`](https://discourse.julialang.org/t/avoid-runtime-dispatch-when-overloading-isless/78366)

<div class="topic-metadata">

**Author:** [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Replies:** 2\
**Last updated:** [March 24, 2022, 8:22am UTC](https://discourse.julialang.org/t/avoid-runtime-dispatch-when-overloading-isless/78366 "2022-03-24T08:22:28Z")

</div>

I have been learning to use JET.jl to improve the performance of my code. I am still getting familiar with its output. I would appreciate some help understanding why the function below produces a runtime dispatch warning…

---

## [Differentialequations.jl - Solving ODE with time dependent parameter allocation friendly](https://discourse.julialang.org/t/differentialequations-jl-solving-ode-with-time-dependent-parameter-allocation-friendly/78284)

<div class="topic-metadata">

**Author:** [@mrVeng](https://discourse.julialang.org/u/mrVeng)\
**Replies:** 2\
**Last updated:** [March 23, 2022, 4:08pm UTC](https://discourse.julialang.org/t/differentialequations-jl-solving-ode-with-time-dependent-parameter-allocation-friendly/78284 "2022-03-23T16:08:14Z")

</div>

Dear all, I am using DifferentialEquations.jl to solve a standard SEIR Model. The ODE looks like this: using DifferentialEquations using BenchmarkTools, UnPack function seir\_ode!(du,u,p,t) (S,E,I,R,C) = u (β,γ…

---

## [Updated CSV reader benchmarks?](https://discourse.julialang.org/t/updated-csv-reader-benchmarks/78331)

<div class="topic-metadata">

**Author:** [@Philogicatician](https://discourse.julialang.org/u/Philogicatician)\
**Replies:** 4\
**Last updated:** [March 23, 2022, 1:32pm UTC](https://discourse.julialang.org/t/updated-csv-reader-benchmarks/78331 "2022-03-23T13:32:30Z")

</div>

An update for Julia 1.7.2 on Jupyter notebooks:

---

## [Faster zeros with calloc](https://discourse.julialang.org/t/faster-zeros-with-calloc/69860)

<div class="topic-metadata">

**Author:** [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Replies:** 26\
**Last updated:** [March 23, 2022, 9:47am UTC](https://discourse.julialang.org/t/faster-zeros-with-calloc/69860 "2022-03-23T09:47:20Z")

</div>

Abstract TL; DR zeros\_via\_calloc is a potentially faster version of zeros that is comparable to Array{T}(undef, ...) and numpy.zeros. function zeros\_via\_calloc(::Type{T}, dims::Integer...) where T ptr = Ptr{T}(Libc.c…

---

## [Rowwise compuation in \`InMemoryDatasets.jl\` vs \`DataFrames.jl\`](https://discourse.julialang.org/t/rowwise-compuation-in-inmemorydatasets-jl-vs-dataframes-jl/78314)

<div class="topic-metadata">

**Author:** [@monopolynomial](https://discourse.julialang.org/u/monopolynomial)\
**Replies:** 2\
**Last updated:** [March 23, 2022, 4:31am UTC](https://discourse.julialang.org/t/rowwise-compuation-in-inmemorydatasets-jl-vs-dataframes-jl/78314 "2022-03-23T04:31:05Z")

</div>

byrow function in InMemoryDatasets is fantastic :+1: , I have done a small benchmark to compare its performance against DataFrames.jl for relatively wide tables. argmax in DataFrames.jl takes long! InMemoryDatasets jul…

---

## [StructArrays (for Complex arrays) and DifferentialEquations not working together](https://discourse.julialang.org/t/structarrays-for-complex-arrays-and-differentialequations-not-working-together/78274)

<div class="topic-metadata">

**Author:** [@Elyco](https://discourse.julialang.org/u/Elyco)\
**Replies:** 4\
**Last updated:** [March 22, 2022, 7:12pm UTC](https://discourse.julialang.org/t/structarrays-for-complex-arrays-and-differentialequations-not-working-together/78274 "2022-03-22T19:12:01Z")

</div>

Hi everyone, I’m trying to solve some differential equations. But I can’t make it works together with StructArrays.jl :frowning: From the stacktrace I understand that when the differential equation package tries to se…

---

## [Large allocations for imported text files](https://discourse.julialang.org/t/large-allocations-for-imported-text-files/78239)

<div class="topic-metadata">

**Author:** [@Jdbeck66](https://discourse.julialang.org/u/Jdbeck66)\
**Replies:** 2\
**Last updated:** [March 22, 2022, 12:17pm UTC](https://discourse.julialang.org/t/large-allocations-for-imported-text-files/78239 "2022-03-22T12:17:46Z")

</div>

I’m importing 6 text files that are each between 5 and 8 GB each using BioJulia’s FASTX. I’m using the code below to read in the data I want to an array for further analysis and processing. function getsequences(file,W…

---

## [Large Garbage Collection in for loop if slicing vector](https://discourse.julialang.org/t/large-garbage-collection-in-for-loop-if-slicing-vector/78229)

<div class="topic-metadata">

**Author:** [@junder873](https://discourse.julialang.org/u/junder873)\
**Replies:** 10\
**Last updated:** [March 22, 2022, 1:00am UTC](https://discourse.julialang.org/t/large-garbage-collection-in-for-loop-if-slicing-vector/78229 "2022-03-22T01:00:13Z")

</div>

When creating a slice of a vector in a for loop, it seems like Julia creates a new vector each time which then needs to be dealt with by the garbage collector. In my setting, sometimes the GC can significantly slow down …

---

## [\`log\` performance regression and JET failures](https://discourse.julialang.org/t/log-performance-regression-and-jet-failures/78146)

<div class="topic-metadata">

**Author:** [@cscherrer](https://discourse.julialang.org/u/cscherrer)\
**Replies:** 3\
**Last updated:** [March 20, 2022, 12:33am UTC](https://discourse.julialang.org/t/log-performance-regression-and-jet-failures/78146 "2022-03-20T00:33:32Z")

</div>

Hi, I’m seeing some surprising results for log in 1.8.0-beta1. First, 1.7: julia\> versioninfo() Julia Version 1.7.2 Commit bf53498635 (2022-02-06 15:21 UTC) Platform Info: OS: Linux (x86\_64-pc-linux-gnu) CPU: Intel(…

---

## [Why is \`collect()\` faster than a for loop in this numerical scheme? (corrected!)](https://discourse.julialang.org/t/why-is-collect-faster-than-a-for-loop-in-this-numerical-scheme-corrected/78003)

<div class="topic-metadata">

**Author:** [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Replies:** 25\
**Last updated:** [March 19, 2022, 10:33am UTC](https://discourse.julialang.org/t/why-is-collect-faster-than-a-for-loop-in-this-numerical-scheme-corrected/78003 "2022-03-19T10:33:54Z")

</div>

Consider a toy algorithm that finds the maximum of a vector, then removes it and alters the other entries of the vector in a way that depends on whether they are located at a lower or higher index. (N.B. I posted a simp…

---

## [Trying to add kernels for Gaussian Process](https://discourse.julialang.org/t/trying-to-add-kernels-for-gaussian-process/78117)

<div class="topic-metadata">

**Author:** [@mirror63](https://discourse.julialang.org/u/mirror63)\
**Replies:** 0\
**Last updated:** [March 19, 2022, 1:54am UTC](https://discourse.julialang.org/t/trying-to-add-kernels-for-gaussian-process/78117 "2022-03-19T01:54:40Z")

</div>

I want to add two kernels for my Gaussian Process, I am using GaussianProcesses.jl . Can somebody give me an example of adding two kernels for a GP. The two kernels I am trying to add are: Periodic + Noise using Gauss…

---

## [Can this be made faster?](https://discourse.julialang.org/t/can-this-be-made-faster/78064)

<div class="topic-metadata">

**Author:** [@r0b0ty](https://discourse.julialang.org/u/r0b0ty)\
**Replies:** 5\
**Last updated:** [March 19, 2022, 1:00am UTC](https://discourse.julialang.org/t/can-this-be-made-faster/78064 "2022-03-19T01:00:39Z")

</div>

I have two DataFrames. The size of the first is (7390, 2), represented below by a small (3, 2) array. The size of the second is quite a bit larger, at (482244, 8), represented below by a larger (7, 4) array. I need to…

---

## [Buffer in running external program in loops](https://discourse.julialang.org/t/buffer-in-running-external-program-in-loops/78087)

<div class="topic-metadata">

**Author:** [@ValentinChb](https://discourse.julialang.org/u/ValentinChb)\
**Replies:** 24\
**Last updated:** [March 18, 2022, 3:39pm UTC](https://discourse.julialang.org/t/buffer-in-running-external-program-in-loops/78087 "2022-03-18T15:39:37Z")

</div>

I’d like to run system calls sequentially in a for loop, waiting for last call to complete before running the next one. The run(command) call is nested in a function (run\_system\_call in the example under) which is part …

---

## [Improving type inference for \`x\` where \`Meta.isexpr(x, ...)\`](https://discourse.julialang.org/t/improving-type-inference-for-x-where-meta-isexpr-x/77993)

<div class="topic-metadata">

**Author:** [@rikh](https://discourse.julialang.org/u/rikh)\
**Replies:** 4\
**Last updated:** [March 18, 2022, 6:56am UTC](https://discourse.julialang.org/t/improving-type-inference-for-x-where-meta-isexpr-x/77993 "2022-03-18T06:56:12Z")

</div>

Type inference struggles a bit with the following: julia\> a = :(x = y = 1); julia\> a.args\[2\] :(y = 1) julia\> function f(a::Expr) ex = a.args\[2\] if Meta.isexpr(ex, :(=)) return ex …

---

## [Why is Julia's graphics system so slow?](https://discourse.julialang.org/t/why-is-julias-graphics-system-so-slow/68750)

<div class="topic-metadata">

**Author:** [@aachener](https://discourse.julialang.org/u/aachener)\
**Replies:** 32\
**Last updated:** [March 17, 2022, 8:59am UTC](https://discourse.julialang.org/t/why-is-julias-graphics-system-so-slow/68750 "2022-03-17T08:59:14Z")

</div>

Hi, all, I am relatively new to Julia, and am using Julia 1.6.2 as well as newest Plots.jl, pyplot.jl and Gadfly.jl. I am programming Julia using vs code extension. I find that drawing charts and plots in Julia is par…

---

## [Why is this numerical scheme so much faster when using \`collect()\` than a for loop?](https://discourse.julialang.org/t/why-is-this-numerical-scheme-so-much-faster-when-using-collect-than-a-for-loop/77949)

<div class="topic-metadata">

**Author:** [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Replies:** 4\
**Last updated:** [March 17, 2022, 2:34am UTC](https://discourse.julialang.org/t/why-is-this-numerical-scheme-so-much-faster-when-using-collect-than-a-for-loop/77949 "2022-03-17T02:34:38Z")

</div>

Consider a toy algorithm that finds the maximum of a vector, then removes it and alters the other entries of the vector in a way that depends on whether they are located at a lower or higher index. In the code below, wh…

---

## [Define mul! for DiffEqArrayOperator](https://discourse.julialang.org/t/define-mul-for-diffeqarrayoperator/77911)

<div class="topic-metadata">

**Author:** [@Elyco](https://discourse.julialang.org/u/Elyco)\
**Replies:** 4\
**Last updated:** [March 16, 2022, 11:27am UTC](https://discourse.julialang.org/t/define-mul-for-diffeqarrayoperator/77911 "2022-03-16T11:27:17Z")

</div>

Hi, I’m trying to use the SplitODEProblem interface in order to improve the performance of my differential equation solver. The problem has a linear part which can sum into matrix multiplication, and a non linear part. …

---

## [Why is the splat operator slow?](https://discourse.julialang.org/t/why-is-the-splat-operator-slow/77928)

<div class="topic-metadata">

**Author:** [@eliascarv](https://discourse.julialang.org/u/eliascarv)\
**Replies:** 3\
**Last updated:** [March 15, 2022, 9:50pm UTC](https://discourse.julialang.org/t/why-is-the-splat-operator-slow/77928 "2022-03-15T21:50:34Z")

</div>

I was doing some benchmarks and got these results: julia\> using BenchmarkTools julia\> f1(itr) = collect(itr) f1 (generic function with 1 method) julia\> f2(itr) = \[itr...\] f2 (generic function with 1 method) julia\> ge…

---

## [getindex(A::AbstractArray, I...) slows down computations with array of type Array{Float64,2}](https://discourse.julialang.org/t/getindex-a-abstractarray-i-slows-down-computations-with-array-of-type-array-float64-2/77927)

<div class="topic-metadata">

**Author:** [@Geometh](https://discourse.julialang.org/u/Geometh)\
**Replies:** 2\
**Last updated:** [March 15, 2022, 8:33pm UTC](https://discourse.julialang.org/t/getindex-a-abstractarray-i-slows-down-computations-with-array-of-type-array-float64-2/77927 "2022-03-15T20:33:28Z")

</div>

Hi there, while optimizing some code of mine I run into sum behavior that I don’t fully understand. I have an array of point coordinates, which I need to access. I stored the coordinates in column-major order as it is …

---

## [Slower summation of a series in Julia than in Python](https://discourse.julialang.org/t/slower-summation-of-a-series-in-julia-than-in-python/77912)

<div class="topic-metadata">

**Author:** [@RayleighLord](https://discourse.julialang.org/u/RayleighLord)\
**Replies:** 10\
**Last updated:** [March 15, 2022, 4:44pm UTC](https://discourse.julialang.org/t/slower-summation-of-a-series-in-julia-than-in-python/77912 "2022-03-15T16:44:06Z")

</div>

Hello, I was doing some tests in Julia and Python and I found that the following code was much slower in Julia and I do not see why this would be the case harmonic(k) = (-1)^k / (k + 1) function sₙ(an, n) S = 0.0 …

---

## [RemoteChannel for multiple-producer multiple-consumer](https://discourse.julialang.org/t/remotechannel-for-multiple-producer-multiple-consumer/41366)

<div class="topic-metadata">

**Author:** [@orenbenkiki](https://discourse.julialang.org/u/orenbenkiki)\
**Replies:** 3\
**Last updated:** [March 15, 2022, 1:07pm UTC](https://discourse.julialang.org/t/remotechannel-for-multiple-producer-multiple-consumer/41366 "2022-03-15T13:07:52Z")

</div>

Suppose I have multiple processes writing into a single RemoteChannel, and multiple processes reading from it. Is that an expected “reasonable” use of a RemoteChannel? If not, is there a better approach? If yes, is it…

---

## [Performance of array of arrays vs. dictionaries when accessing and manipulating data structures](https://discourse.julialang.org/t/performance-of-array-of-arrays-vs-dictionaries-when-accessing-and-manipulating-data-structures/77860)

<div class="topic-metadata">

**Author:** [@Christian\_Brunbjerg](https://discourse.julialang.org/u/Christian_Brunbjerg)\
**Replies:** 5\
**Last updated:** [March 14, 2022, 9:36pm UTC](https://discourse.julialang.org/t/performance-of-array-of-arrays-vs-dictionaries-when-accessing-and-manipulating-data-structures/77860 "2022-03-14T21:36:12Z")

</div>

I here have two different structs that represent the same data. The main objective is to achieve as fast as possible performance. #Using array of arrays representation struct Route\_array Station::Vector{Int64} T…

---

## [How to best handle these exceptions in FOC of maximization?](https://discourse.julialang.org/t/how-to-best-handle-these-exceptions-in-foc-of-maximization/77575)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 1\
**Last updated:** [March 14, 2022, 10:03pm UTC](https://discourse.julialang.org/t/how-to-best-handle-these-exceptions-in-foc-of-maximization/77575 "2022-03-14T22:03:19Z")

</div>

I’m trying to maximize a function f(t\_1, t\_2) for which the first order conditions yield 2 equations depending on some conditions. The FOCs divide the plane into 3 regions, where t\_1 \> t\_2, where t\_1 \< t\_2, and where t\_1…

---

## [Does locally compiled Julia emit faster code?](https://discourse.julialang.org/t/does-locally-compiled-julia-emit-faster-code/77838)

<div class="topic-metadata">

**Author:** [@Lewis\_Hein](https://discourse.julialang.org/u/Lewis_Hein)\
**Replies:** 1\
**Last updated:** [March 14, 2022, 3:06pm UTC](https://discourse.julialang.org/t/does-locally-compiled-julia-emit-faster-code/77838 "2022-03-14T15:06:27Z")

</div>

I’m working on a reasonably high-end platform (Intel Xeon E5). Will a generic binary of julia be able to leverage all the various optimizations of this CPU when compiling Julia code? Or do I need to compile from source l…

---

## [AMD Rome vs Intel Xeon shows bad scaling with threads for AMD](https://discourse.julialang.org/t/amd-rome-vs-intel-xeon-shows-bad-scaling-with-threads-for-amd/77683)

<div class="topic-metadata">

**Author:** [@Chiil](https://discourse.julialang.org/u/Chiil)\
**Replies:** 20\
**Last updated:** [March 13, 2022, 6:53pm UTC](https://discourse.julialang.org/t/amd-rome-vs-intel-xeon-shows-bad-scaling-with-threads-for-amd/77683 "2022-03-13T18:53:17Z")

</div>

I ran my 3D finite difference stencil benchmark https://github.com/Chiil/MicroHH.jl/blob/main/test/dynamics\_kernel.jl on AMD Rome 7H12 and Intel Xeon Platinum 8360Y with grid spacing (itot = 256; jtot = 256; ktot = 1024)…

---

## [Weights and indices for linear interpolation/extrapolation](https://discourse.julialang.org/t/weights-and-indices-for-linear-interpolation-extrapolation/77580)

<div class="topic-metadata">

**Author:** [@fredrikpaues](https://discourse.julialang.org/u/fredrikpaues)\
**Replies:** 15\
**Last updated:** [March 12, 2022, 7:29pm UTC](https://discourse.julialang.org/t/weights-and-indices-for-linear-interpolation-extrapolation/77580 "2022-03-12T19:29:10Z")

</div>

A performance-critical function of a bigger program that I’m writing consists of locating points on a grid. It amounts to finding the indices and weights needed for a linear interpolation/extrapolation—without doing the …

---

## [Struct of Arrays (SoA) vs Array of Structs (AoS)](https://discourse.julialang.org/t/struct-of-arrays-soa-vs-array-of-structs-aos/30015)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 30\
**Last updated:** [March 12, 2022, 10:47pm UTC](https://discourse.julialang.org/t/struct-of-arrays-soa-vs-array-of-structs-aos/30015 "2022-03-12T22:47:43Z")

</div>

There are two ways to arrange data in memory. SoA means Struct of Arrays and AoS means Array of Structs. I’m trying to understand when one is better than the other in Julia. I was reading @ChrisRackauckas fantastic lect…

---

## [Possible threading bug on M1 Max (only ARM build)](https://discourse.julialang.org/t/possible-threading-bug-on-m1-max-only-arm-build/77779)

<div class="topic-metadata">

**Author:** [@robertfeldt](https://discourse.julialang.org/u/robertfeldt)\
**Replies:** 19\
**Last updated:** [March 12, 2022, 10:01pm UTC](https://discourse.julialang.org/t/possible-threading-bug-on-m1-max-only-arm-build/77779 "2022-03-12T22:01:01Z")

</div>

Got a new MacBook Pro 16" M1 Max with 64GB mem and installed both the 1.7.2 ARM build and the 1.6.5 macOS (so non-ARM) build. The simple Threads.@threads example from the doc pages behaves as expected on the non-arm buil…

[Previous page](https://discourse.julialang.org/c/usage/perf/37.md?page=68)

[Next page](https://discourse.julialang.org/c/usage/perf/37.md?page=70)
