# Performance

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

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

**Page:** 72

---

## [How to efficiently calculate the Jacobian of the solution of a differential equation with respect to the initial conditions?](https://discourse.julialang.org/t/how-to-efficiently-calculate-the-jacobian-of-the-solution-of-a-differential-equation-with-respect-to-the-initial-conditions/76650)

<div class="topic-metadata">

**Author:** [@marcsgil](https://discourse.julialang.org/u/marcsgil)\
**Replies:** 1\
**Last updated:** [February 21, 2022, 9:44pm UTC](https://discourse.julialang.org/t/how-to-efficiently-calculate-the-jacobian-of-the-solution-of-a-differential-equation-with-respect-to-the-initial-conditions/76650 "2022-02-21T21:44:24Z")

</div>

I need to numerically perform an integral of the form \\int\_{0}^{t\_{max}} F \\left( \\mathbf{u}(t), \\frac{\\partial \\mathbf{u}(t)}{ \\partial \\mathbf{u}(0)} \\right) dt where F is a certain function, \\mathbf{u}(t) is the …

---

## [This post claims that Julia is still 4-5 times slower than cython](https://discourse.julialang.org/t/this-post-claims-that-julia-is-still-4-5-times-slower-than-cython/76735)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 38\
**Last updated:** [February 21, 2022, 1:56am UTC](https://discourse.julialang.org/t/this-post-claims-that-julia-is-still-4-5-times-slower-than-cython/76735 "2022-02-21T01:56:46Z")

</div>

https://jochenschroeder.com/blog/articles/DSP\_with\_Python2/ Just posting here in case anyone’s interested in having a look.

---

## [Why do take! and put! for channels allocate memory?](https://discourse.julialang.org/t/why-do-take-and-put-for-channels-allocate-memory/76513)

<div class="topic-metadata">

**Author:** [@taotree](https://discourse.julialang.org/u/taotree)\
**Replies:** 1\
**Last updated:** [February 18, 2022, 6:00pm UTC](https://discourse.julialang.org/t/why-do-take-and-put-for-channels-allocate-memory/76513 "2022-02-18T18:00:20Z")

</div>

I ran a bunch of floats through some channels across threads to test it out and discovered that memory was being allocated during the process which seems odd. Increasing the count in the for loop increases the allocation…

---

## [Avoiding Vectors of Abstract Types](https://discourse.julialang.org/t/avoiding-vectors-of-abstract-types/61883)

<div class="topic-metadata">

**Author:** [@RobertGregg](https://discourse.julialang.org/u/RobertGregg)\
**Replies:** 22\
**Last updated:** [February 17, 2022, 9:46pm UTC](https://discourse.julialang.org/t/avoiding-vectors-of-abstract-types/61883 "2022-02-17T21:46:36Z")

</div>

I’ve come across a few instances (see 1, 2, 3) where it would be intuitive to create a vector of structs that all fall under the same abstract type (maybe this comes from an OO style of thinking?). Unfortunately, this le…

---

## [String Distance Calculations on GPU](https://discourse.julialang.org/t/string-distance-calculations-on-gpu/57549)

<div class="topic-metadata">

**Author:** [@mthelm85](https://discourse.julialang.org/u/mthelm85)\
**Replies:** 4\
**Last updated:** [February 17, 2022, 3:38pm UTC](https://discourse.julialang.org/t/string-distance-calculations-on-gpu/57549 "2022-02-17T15:38:42Z")

</div>

How difficult would it be to do this in Julia? It looks like it might be possible to do this with PyTorch: And here are some papers on the topic: https://www.researchgate.net/publication/300042590\_Using\_GPUs\_to\_Spee…

---

## [Calculating 2-point correlation of a large 3D array: \`view\` seems to make it worse?](https://discourse.julialang.org/t/calculating-2-point-correlation-of-a-large-3d-array-view-seems-to-make-it-worse/76493)

<div class="topic-metadata">

**Author:** [@Ickaser](https://discourse.julialang.org/u/Ickaser)\
**Replies:** 2\
**Last updated:** [February 17, 2022, 2:46am UTC](https://discourse.julialang.org/t/calculating-2-point-correlation-of-a-large-3d-array-view-seems-to-make-it-worse/76493 "2022-02-17T02:46:53Z")

</div>

I am trying to calculate the 2-point correlation of a large 3D BitArray (the data comes from a micro-CT scan of a porous structure, which I have already thresholded, hence each voxel is either 1 or 0). At the moment, I a…

---

## [How to capture an index in closure without allocating (or workaround)?](https://discourse.julialang.org/t/how-to-capture-an-index-in-closure-without-allocating-or-workaround/76334)

<div class="topic-metadata">

**Author:** [@taotree](https://discourse.julialang.org/u/taotree)\
**Replies:** 4\
**Last updated:** [February 14, 2022, 9:20pm UTC](https://discourse.julialang.org/t/how-to-capture-an-index-in-closure-without-allocating-or-workaround/76334 "2022-02-14T21:20:36Z")

</div>

Sorry the code is a bit long but the middle testIt! function is where the question is. If I run run() as-is, there are ~160k allocations. However, if I comment out the code with i, then there are no allocations. I’m assu…

---

## [Performance of large sparse discrete map problems in DifferentialEquations](https://discourse.julialang.org/t/performance-of-large-sparse-discrete-map-problems-in-differentialequations/76382)

<div class="topic-metadata">

**Author:** [@roryh](https://discourse.julialang.org/u/roryh)\
**Replies:** 8\
**Last updated:** [February 14, 2022, 2:12pm UTC](https://discourse.julialang.org/t/performance-of-large-sparse-discrete-map-problems-in-differentialequations/76382 "2022-02-14T14:12:55Z")

</div>

Hello, I normally deal with dynamics on networks, so I have giant sparse systems of coupled ODE’s. The problem I have at the moment is that for a simple discrete map, a naive implementation is significantly faster than …

---

## [Channel monitoring/statistics](https://discourse.julialang.org/t/channel-monitoring-statistics/53744)

<div class="topic-metadata">

**Author:** [@pmilovanov](https://discourse.julialang.org/u/pmilovanov)\
**Replies:** 3\
**Last updated:** [February 13, 2022, 6:53pm UTC](https://discourse.julialang.org/t/channel-monitoring-statistics/53744 "2022-02-13T18:53:05Z")

</div>

Before I reinvent the wheel, is there any conventional solution to track statistics on the state of channels during execution? E.g what’s the distribution of channel length over time (not size but items in channel) or di…

---

## [Random number iterator?](https://discourse.julialang.org/t/random-number-iterator/76330)

<div class="topic-metadata">

**Author:** [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Replies:** 5\
**Last updated:** [February 13, 2022, 4:48pm UTC](https://discourse.julialang.org/t/random-number-iterator/76330 "2022-02-13T16:48:34Z")

</div>

Is it possible to get a random number iterator that doesn’t allocate? I was hoping I could do something like this: julia\> using Random julia\> sum(Iterators.take(MersenneTwister(0), 4)) ERROR: MethodError: no method mat…

---

## [Benchmarking function (using \`@benchmark\`) for various input sizes](https://discourse.julialang.org/t/benchmarking-function-using-benchmark-for-various-input-sizes/76306)

<div class="topic-metadata">

**Author:** [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Replies:** 2\
**Last updated:** [February 12, 2022, 5:43pm UTC](https://discourse.julialang.org/t/benchmarking-function-using-benchmark-for-various-input-sizes/76306 "2022-02-12T17:43:14Z")

</div>

I have a function. I want to benchmark it for various inputs (originally I am solving a differential equations over various timespans). Naturally I would do something like: using BenchmarkTools bs = for l in \[10,100,10…

---

## [Is there a fast way to evaluate the exp() function in Julia?](https://discourse.julialang.org/t/is-there-a-fast-way-to-evaluate-the-exp-function-in-julia/76287)

<div class="topic-metadata">

**Author:** [@maphdze](https://discourse.julialang.org/u/maphdze)\
**Replies:** 8\
**Last updated:** [February 12, 2022, 12:25pm UTC](https://discourse.julialang.org/t/is-there-a-fast-way-to-evaluate-the-exp-function-in-julia/76287 "2022-02-12T12:25:41Z")

</div>

My code are shown in following using BenchmarkTools using StaticArrays const λ = 1.0E-6 @inline @fastmath function damage\_pair!(f,x,y,i,j,d) new\_d = 0.0 for idim = 1:2 new\_d += (x\[idim\] - y\[idim\]) ^ 2 …

---

## [Accelerate pairwise Lennard-Jones force computation](https://discourse.julialang.org/t/accelerate-pairwise-lennard-jones-force-computation/67321)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 87\
**Last updated:** [February 12, 2022, 10:03am UTC](https://discourse.julialang.org/t/accelerate-pairwise-lennard-jones-force-computation/67321 "2022-02-12T10:03:05Z")

</div>

Someone can see a chance of significantly accelerating this function? julia\> using StaticArrays, FastPow, BenchmarkTools julia\> function forces(x,y,d2,ε,σ,f) r = y - x @fastpow dudr = -12\*ε\*(σ^12/…

---

## [Unexpected allocation when calling Julia function from C++](https://discourse.julialang.org/t/unexpected-allocation-when-calling-julia-function-from-c/76184)

<div class="topic-metadata">

**Author:** [@victor-shepardson](https://discourse.julialang.org/u/victor-shepardson)\
**Replies:** 0\
**Last updated:** [February 10, 2022, 5:17pm UTC](https://discourse.julialang.org/t/unexpected-allocation-when-calling-julia-function-from-c/76184 "2022-02-10T17:17:06Z")

</div>

Hey, I’m using PackageCompiler to make a shared library and calling it from C++ with the Julia GC turned off, allocating all memory on the C++ side. From the Julia side, I see 0 allocations: julia\> using BenchmarkTools…

---

## [In-place multiplication is too much slower for ComplexF64](https://discourse.julialang.org/t/in-place-multiplication-is-too-much-slower-for-complexf64/75887)

<div class="topic-metadata">

**Author:** [@photor](https://discourse.julialang.org/u/photor)\
**Replies:** 19\
**Last updated:** [February 10, 2022, 2:29am UTC](https://discourse.julialang.org/t/in-place-multiplication-is-too-much-slower-for-complexf64/75887 "2022-02-10T02:29:46Z")

</div>

The ordinary version: using BenchmarkTools const p = 60 const dd=randn(p,p) const ψ=randn(p,p\*p)+im\*randn(p,p\*p) function d2x(ψ::Array{ComplexF64,2})::Array{ComplexF64,2} ψr=dd\*ψ return ψr end @btime d2x(ψ); …

---

## [Parallel Reductions with Zygote](https://discourse.julialang.org/t/parallel-reductions-with-zygote/75969)

<div class="topic-metadata">

**Author:** [@SEA](https://discourse.julialang.org/u/SEA)\
**Replies:** 11\
**Last updated:** [February 9, 2022, 1:05pm UTC](https://discourse.julialang.org/t/parallel-reductions-with-zygote/75969 "2022-02-09T13:05:38Z")

</div>

I am trying to speed up the gradient computation of a model of the form sum(m-\>m(x), models), where models is an array of constituent models. This is (supposed to be) easily parallelizable, but I am having trouble maki…

---

## [Unexpected allocations in loops](https://discourse.julialang.org/t/unexpected-allocations-in-loops/74063)

<div class="topic-metadata">

**Author:** [@t-bltg](https://discourse.julialang.org/u/t-bltg)\
**Replies:** 8\
**Last updated:** [February 9, 2022, 12:49pm UTC](https://discourse.julialang.org/t/unexpected-allocations-in-loops/74063 "2022-02-09T12:49:12Z")

</div>

Consider the following reduced example: using BenchmarkTools const F = Float64 struct Species q::F ρ::Array{F} end addCharge!(dst::Array{F}, q::F, ρ::Array{F}) = for I ∈ eachindex(dst) dst\[I\] += q \* ρ\[I\] end a…

---

## [How to find details of the compiler and optimizations used by a specific installed version of Julia](https://discourse.julialang.org/t/how-to-find-details-of-the-compiler-and-optimizations-used-by-a-specific-installed-version-of-julia/75501)

<div class="topic-metadata">

**Author:** [@DavidB](https://discourse.julialang.org/u/DavidB)\
**Replies:** 11\
**Last updated:** [February 9, 2022, 11:23am UTC](https://discourse.julialang.org/t/how-to-find-details-of-the-compiler-and-optimizations-used-by-a-specific-installed-version-of-julia/75501 "2022-02-09T11:23:28Z")

</div>

I’ve noticed that there is a performance significant difference in the execution of a Julia application between “bare metal” and within a container, but only on one specific platform. So want to see if there was a differ…

---

## ["Cat" very slow for relativelly small tasks](https://discourse.julialang.org/t/cat-very-slow-for-relativelly-small-tasks/76067)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 2\
**Last updated:** [February 9, 2022, 10:55am UTC](https://discourse.julialang.org/t/cat-very-slow-for-relativelly-small-tasks/76067 "2022-02-09T10:55:23Z")

</div>

This make my 16GB system hang for a while and eventually crash with a StackOverflowError, even if top doesn’t show all this memory usage (the matrices themselves should be ~ 400 MB) mainM = rand(28,28,60000) toAdd = \[ra…

---

## [Improving performance of recursions by avoiding closures](https://discourse.julialang.org/t/improving-performance-of-recursions-by-avoiding-closures/76026)

<div class="topic-metadata">

**Author:** [@lucifer1004](https://discourse.julialang.org/u/lucifer1004)\
**Replies:** 0\
**Last updated:** [February 8, 2022, 2:15pm UTC](https://discourse.julialang.org/t/improving-performance-of-recursions-by-avoiding-closures/76026 "2022-02-08T14:15:06Z")

</div>

Just implemented Tarjan’s SCC (strongly-connected components) algorithm. In the first version, I created the dfs() function (which is recursive) inside the scc() function, and let it capture the needed variables from the…

---

## [@printf strange performance behavior](https://discourse.julialang.org/t/printf-strange-performance-behavior/76013)

<div class="topic-metadata">

**Author:** [@\_bernhard](https://discourse.julialang.org/u/_bernhard)\
**Replies:** 1\
**Last updated:** [February 8, 2022, 1:52pm UTC](https://discourse.julialang.org/t/printf-strange-performance-behavior/76013 "2022-02-08T13:52:16Z")

</div>

Hello everybody! I recently encountered some strange behavior related to printing numbers as ASCII in Julia. Tested were both Julia 1.6 and 1.7, the following timings are from 1.6. using Printf using BenchmarkTools f…

---

## [What's the optimal setting for JULIA\_NUM\_THREADS on a Macbook Pro M1 Max](https://discourse.julialang.org/t/whats-the-optimal-setting-for-julia-num-threads-on-a-macbook-pro-m1-max/75928)

<div class="topic-metadata">

**Author:** [@navidcy](https://discourse.julialang.org/u/navidcy)\
**Replies:** 4\
**Last updated:** [February 8, 2022, 12:55pm UTC](https://discourse.julialang.org/t/whats-the-optimal-setting-for-julia-num-threads-on-a-macbook-pro-m1-max/75928 "2022-02-08T12:55:19Z")

</div>

with Total Numbers of Cores: 10 (8 performance and 2 efficiency)? Is it 10? 8? 20? 16?

---

## [Efficient way of doing linear regression](https://discourse.julialang.org/t/efficient-way-of-doing-linear-regression/31232)

<div class="topic-metadata">

**Author:** [@Johncowk](https://discourse.julialang.org/u/Johncowk)\
**Replies:** 44\
**Last updated:** [February 7, 2022, 9:35am UTC](https://discourse.julialang.org/t/efficient-way-of-doing-linear-regression/31232 "2022-02-07T09:35:17Z")

</div>

Hello, I need an efficient way to performs linear regression because I have to fit several segments in a big for loops which takes time to achieve. In the past, their was a linreg function which has been depreciated. Cu…

---

## [Speed issue with KahanSummation](https://discourse.julialang.org/t/speed-issue-with-kahansummation/75491)

<div class="topic-metadata">

**Author:** [@HJW019](https://discourse.julialang.org/u/HJW019)\
**Replies:** 12\
**Last updated:** [February 5, 2022, 10:08am UTC](https://discourse.julialang.org/t/speed-issue-with-kahansummation/75491 "2022-02-05T10:08:16Z")

</div>

I am using Julia version 1.7.1. I need to do summations of long series (repeatedly) where accuracy is important. I am looking at KahanSummation’ sum\_kbn (pure Julia), but am puzzled by the very slow speed (with a lot of …

---

## [Generator expression optimization for a known iteration set](https://discourse.julialang.org/t/generator-expression-optimization-for-a-known-iteration-set/75809)

<div class="topic-metadata">

**Author:** [@RGon](https://discourse.julialang.org/u/RGon)\
**Replies:** 0\
**Last updated:** [February 4, 2022, 5:09pm UTC](https://discourse.julialang.org/t/generator-expression-optimization-for-a-known-iteration-set/75809 "2022-02-04T17:09:25Z")

</div>

I tend to run into a lot of situations where I’m iterating over something that is constant based on the input type. One example is a pattern where I want return a modified immutable function function modifyfields(x::T, …

---

## [Sparsity Detection in Jacobian](https://discourse.julialang.org/t/sparsity-detection-in-jacobian/75756)

<div class="topic-metadata">

**Author:** [@ziolai](https://discourse.julialang.org/u/ziolai)\
**Replies:** 1\
**Last updated:** [February 4, 2022, 4:53pm UTC](https://discourse.julialang.org/t/sparsity-detection-in-jacobian/75756 "2022-02-04T16:53:11Z")

</div>

When trying to run https://diffeq.sciml.ai/stable/tutorials/advanced\_ode\_example/#Declaring-a-Sparse-Jacobian-with-Automatic-Sparsity-Detection I obtain MethodError: no method matching jacobian\_sparsity(::var"#7#8", :…

---

## [Trait dispatch causing allocations](https://discourse.julialang.org/t/trait-dispatch-causing-allocations/75742)

<div class="topic-metadata">

**Author:** [@jg-854](https://discourse.julialang.org/u/jg-854)\
**Replies:** 9\
**Last updated:** [February 4, 2022, 2:06pm UTC](https://discourse.julialang.org/t/trait-dispatch-causing-allocations/75742 "2022-02-04T14:06:51Z")

</div>

I am simulating electronic circuits and I have chosen to adopt a modular model which works on objects of type Component. A Component can be a Resistor, Capacitor, or even a Serial/Parallel combination of Components. Th…

---

## [Outperformed by Matlab](https://discourse.julialang.org/t/outperformed-by-matlab/71603)

<div class="topic-metadata">

**Author:** [@Germinator](https://discourse.julialang.org/u/Germinator)\
**Replies:** 54\
**Last updated:** [November 23, 2021, 7:28pm UTC](https://discourse.julialang.org/t/outperformed-by-matlab/71603 "2021-11-23T19:28:46Z")

</div>

Dear Julia users, I am trying to set up the normal equations ( https://en.wikipedia.org/wiki/Linear\_least\_squares ) which means constructing X'X and X'y in (X'X+\\lambda M) w = X'y where M is SPD, and in my case, each…

---

## [Why so large memory allocations?](https://discourse.julialang.org/t/why-so-large-memory-allocations/75662)

<div class="topic-metadata">

**Author:** [@photor](https://discourse.julialang.org/u/photor)\
**Replies:** 6\
**Last updated:** [February 3, 2022, 2:58am UTC](https://discourse.julialang.org/t/why-so-large-memory-allocations/75662 "2022-02-03T02:58:36Z")

</div>

I met a weird problem in the following trivial code: using BenchmarkTools const p=150 dd = randn(p,p) function d2(ψ::Matrix{Float64})::Matrix{Float64} ψr = similar(ψ) ddψ = dd\*ψ @time @inbounds for i in ea…

---

## [Apparent mismatch of run times during summation](https://discourse.julialang.org/t/apparent-mismatch-of-run-times-during-summation/75527)

<div class="topic-metadata">

**Author:** [@lzxnl](https://discourse.julialang.org/u/lzxnl)\
**Replies:** 5\
**Last updated:** [February 2, 2022, 3:21pm UTC](https://discourse.julialang.org/t/apparent-mismatch-of-run-times-during-summation/75527 "2022-02-02T15:21:52Z")

</div>

Hi guys, Julia newbie here. I have a very simple question that I haven’t been able to get my head around. I ultimately want to sum f(n)\*g(n)\*x\[n-1\] where n ranges from 1 to a predetermined integer, where f is some funct…

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

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