# Performance

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

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

**Page:** 12

---

## [Type instability in nested quadgk calls](https://discourse.julialang.org/t/type-instability-in-nested-quadgk-calls/126667)

<div class="topic-metadata">

**Author:** [@mbasquens](https://discourse.julialang.org/u/mbasquens)\
**Replies:** 26\
**Last updated:** [March 10, 2025, 6:44pm UTC](https://discourse.julialang.org/t/type-instability-in-nested-quadgk-calls/126667 "2025-03-10T18:44:52Z")

</div>

Hi! I am having trouble with the type stability of quadgk when the integrand function is using quadgk itself. Here is the MWE: using QuadGK f(x) = quadgk(y -\> x\*y, 0., 1.)\[1\] quadgk(f, 0., 1.) Using code\_warntype on t…

---

## [C implementation of function being ~4 times faster even absence of allocs](https://discourse.julialang.org/t/c-implementation-of-function-being-4-times-faster-even-absence-of-allocs/126495)

<div class="topic-metadata">

**Author:** [@miguelborrero](https://discourse.julialang.org/u/miguelborrero)\
**Replies:** 28\
**Last updated:** [March 5, 2025, 10:42pm UTC](https://discourse.julialang.org/t/c-implementation-of-function-being-4-times-faster-even-absence-of-allocs/126495 "2025-03-05T22:42:57Z")

</div>

Hi there, I am in need to optimize as much as possible the function I will present here. I moved it from C to Julia for convenience since the operations around it become much easier but I am getting significantly worst …

---

## [My Julia code is slower than Python and Matlab](https://discourse.julialang.org/t/my-julia-code-is-slower-than-python-and-matlab/126476)

<div class="topic-metadata">

**Author:** [@Yuntian\_Zhao](https://discourse.julialang.org/u/Yuntian_Zhao)\
**Replies:** 26\
**Last updated:** [March 4, 2025, 7:40pm UTC](https://discourse.julialang.org/t/my-julia-code-is-slower-than-python-and-matlab/126476 "2025-03-04T19:40:15Z")

</div>

I am solving an HJB equation in economics using Julia, but I am experiencing performance issues. My Julia implementation takes about 90 seconds, slower than Python (~76s) and significantly slower than MATLAB (~39s). I’m …

---

## [Investigate long compile times](https://discourse.julialang.org/t/investigate-long-compile-times/119019)

<div class="topic-metadata">

**Author:** [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Replies:** 12\
**Last updated:** [March 4, 2025, 11:44am UTC](https://discourse.julialang.org/t/investigate-long-compile-times/119019 "2025-03-04T11:44:13Z")

</div>

Hi, Can someone give me hint on why the following call takes ~2mn to compile please? If you have an idea of the culprit and suggestions, I’d be very happy to hear them :smiley: Thanks a lot for your help, fold\_po\_coll…

---

## [Sorting in-place several Vector's simultaneously](https://discourse.julialang.org/t/sorting-in-place-several-vectors-simultaneously/125665)

<div class="topic-metadata">

**Author:** [@Leo\_I](https://discourse.julialang.org/u/Leo_I)\
**Replies:** 21\
**Last updated:** [March 3, 2025, 1:26pm UTC](https://discourse.julialang.org/t/sorting-in-place-several-vectors-simultaneously/125665 "2025-03-03T13:26:53Z")

</div>

I have several vectors (with different types of elements and lengths) whose entries I wish to sort in-place according to some function, like first or identity (lexicographical sort). For example: n=10^7; x=rand(1:n,n);…

---

## [Avoiding allocations in jacobian system](https://discourse.julialang.org/t/avoiding-allocations-in-jacobian-system/126376)

<div class="topic-metadata">

**Author:** [@AP9](https://discourse.julialang.org/u/AP9)\
**Replies:** 2\
**Last updated:** [February 27, 2025, 10:26am UTC](https://discourse.julialang.org/t/avoiding-allocations-in-jacobian-system/126376 "2025-02-27T10:26:06Z")

</div>

Why is the below function allocating, and how can I optimize it so it does not allocate? β = 100 S(x) = 1/(1+exp(-β\*x)) S\_prime(x) = β\*S(x)\*(1-S(x)) function jacobian\_system(u, p, n) ω, ω\_A, A = p x, y, s = u …

---

## [Franklin.jl for engineering content](https://discourse.julialang.org/t/franklin-jl-for-engineering-content/126263)

<div class="topic-metadata">

**Author:** [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)\
**Replies:** 3\
**Last updated:** [February 26, 2025, 4:30am UTC](https://discourse.julialang.org/t/franklin-jl-for-engineering-content/126263 "2025-02-26T04:30:41Z")

</div>

I am coming to my limits while trying to port this Quarto document to Franklin.jl. I have little knowledge of HTML and CSS. From reading the documentations and the GitHub issues, I did not find a way to generate a figur…

---

## [Interpolations.jl interpolation evaluation causes allocation](https://discourse.julialang.org/t/interpolations-jl-interpolation-evaluation-causes-allocation/126279)

<div class="topic-metadata">

**Author:** [@Bart\_van\_de\_Lint](https://discourse.julialang.org/u/Bart_van_de_Lint)\
**Replies:** 3\
**Last updated:** [February 25, 2025, 6:07am UTC](https://discourse.julialang.org/t/interpolations-jl-interpolation-evaluation-causes-allocation/126279 "2025-02-25T06:07:23Z")

</div>

In the following MWE, all interpolation evaluations cause 1 allocation. I want to get rid of this allocation for optimal performance. What should I do to achieve this? using Interpolations, BenchmarkTools # Create test…

---

## [Precompilation keeps repeating](https://discourse.julialang.org/t/precompilation-keeps-repeating/126250)

<div class="topic-metadata">

**Author:** [@natgeo-wong](https://discourse.julialang.org/u/natgeo-wong)\
**Replies:** 13\
**Last updated:** [February 24, 2025, 7:21pm UTC](https://discourse.julialang.org/t/precompilation-keeps-repeating/126250 "2025-02-24T19:21:23Z")

</div>

Hi! When I’m using Julia on my Slurm HPC, it keeps redoing the precompilation. For example, if I’m running a julia script in terminal, and then running a pluto notebook under the same project (though under a different no…

---

## [@tturbo on function call](https://discourse.julialang.org/t/tturbo-on-function-call/126224)

<div class="topic-metadata">

**Author:** [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Replies:** 4\
**Last updated:** [February 24, 2025, 3:15pm UTC](https://discourse.julialang.org/t/tturbo-on-function-call/126224 "2025-02-24T15:15:28Z")

</div>

a=randn(5\*10^7) b=randn(5\*10^7) f(a::Float64,b::Float64)::Float64 = sin(a) + cos(b) @time @tturbo @. sin(a) + cos(b) # .05 seconds @time @tturbo @. f(a,b) # 1 second Is it possible to get the @tturbo speedu…

---

## [Performance in broadcasting vs function preallocation?](https://discourse.julialang.org/t/performance-in-broadcasting-vs-function-preallocation/126211)

<div class="topic-metadata">

**Author:** [@lepton01](https://discourse.julialang.org/u/lepton01)\
**Replies:** 6\
**Last updated:** [February 23, 2025, 2:00pm UTC](https://discourse.julialang.org/t/performance-in-broadcasting-vs-function-preallocation/126211 "2025-02-23T14:00:28Z")

</div>

Hello there. I have created a couple of functions with the same purpose, evaluating: f(x, y) = (x - 3)^2 + (y + 15)^2 over a matrix (really two vectors), the first column for x and the second one for y. The first func…

---

## [Memory \`isbits\` Union Optimization](https://discourse.julialang.org/t/memory-isbits-union-optimization/126175)

<div class="topic-metadata">

**Author:** [@PatrickHaecker](https://discourse.julialang.org/u/PatrickHaecker)\
**Replies:** 5\
**Last updated:** [February 23, 2025, 8:23am UTC](https://discourse.julialang.org/t/memory-isbits-union-optimization/126175 "2025-02-23T08:23:03Z")

</div>

Citing from isbits union memory optimization (emphasis mine) The optimization is accomplished by storing an extra “type tag memory” of bytes, one byte per element, alongside the bytes of the actual data. However, I s…

---

## [Mul! allocates for custom struct which is a subtype of AbstractMatrix](https://discourse.julialang.org/t/mul-allocates-for-custom-struct-which-is-a-subtype-of-abstractmatrix/126078)

<div class="topic-metadata">

**Author:** [@Giorgos\_Vretinaris](https://discourse.julialang.org/u/Giorgos_Vretinaris)\
**Replies:** 2\
**Last updated:** [February 19, 2025, 6:35pm UTC](https://discourse.julialang.org/t/mul-allocates-for-custom-struct-which-is-a-subtype-of-abstractmatrix/126078 "2025-02-19T18:35:08Z")

</div>

I am trying to write an efficient matricization function following Kolda’s and Bader’s work on “Tensor Decompositions and Applications”. The struct I have is non-allocating when initialized as it is basically a lazy view…

---

## [Julia VSC extension not loading](https://discourse.julialang.org/t/julia-vsc-extension-not-loading/126084)

<div class="topic-metadata">

**Author:** [@martin\_sanchez](https://discourse.julialang.org/u/martin_sanchez)\
**Replies:** 1\
**Last updated:** [February 19, 2025, 5:21pm UTC](https://discourse.julialang.org/t/julia-vsc-extension-not-loading/126084 "2025-02-19T17:21:46Z")

</div>

Hi, I had used before VSC for Julia and the notebooks aswell. I was wondering if its this is just happening to me or a general thing, but very often for very vey simple tasks the notebook gets stuck, as in the following …

---

## [Multithreading doesn't improve the performance](https://discourse.julialang.org/t/multithreading-doesnt-improve-the-performance/126020)

<div class="topic-metadata">

**Author:** [@wq-123](https://discourse.julialang.org/u/wq-123)\
**Replies:** 6\
**Last updated:** [February 18, 2025, 10:27am UTC](https://discourse.julialang.org/t/multithreading-doesnt-improve-the-performance/126020 "2025-02-18T10:27:48Z")

</div>

Hello, I’m trying to calculate my for-loop with multithreading. But there’s no increase in computing speed. Here’s the struct of my code. B = \[\[\[zeros(ComplexF64,1,6) for a in 1:3\] for \_ in 1:Nw\] for z in 1:Threads.nthr…

---

## [How to spawn persistent threads and reuse them?](https://discourse.julialang.org/t/how-to-spawn-persistent-threads-and-reuse-them/126002)

<div class="topic-metadata">

**Author:** [@Leo\_I](https://discourse.julialang.org/u/Leo_I)\
**Replies:** 16\
**Last updated:** [February 17, 2025, 9:50pm UTC](https://discourse.julialang.org/t/how-to-spawn-persistent-threads-and-reuse-them/126002 "2025-02-17T21:50:25Z")

</div>

Let nt=nthreads(). I have a loop for k=1:n compute!(k, ...) end that I wish to parallelize. I did so as for k0=1:nt:n k1 = min(k0+nt-1,n); @threads for k=k0:k1 compute!(k, ...) end compress\_results!(k0…

---

## [Elapsed + allocated?](https://discourse.julialang.org/t/elapsed-allocated/125910)

<div class="topic-metadata">

**Author:** [@Sarah\_Groves](https://discourse.julialang.org/u/Sarah_Groves)\
**Replies:** 4\
**Last updated:** [February 14, 2025, 5:08pm UTC](https://discourse.julialang.org/t/elapsed-allocated/125910 "2025-02-14T17:08:53Z")

</div>

I am familiar with the @elapsed and @allocated functions that allow me to save as a variable either the elapsed time and allocated memory during a function run (respectively). Is there a method that will return both vari…

---

## [Why is the NamedTuple slower? When/How would it be faster? Is it still allocated on the stack?](https://discourse.julialang.org/t/why-is-the-namedtuple-slower-when-how-would-it-be-faster-is-it-still-allocated-on-the-stack/125902)

<div class="topic-metadata">

**Author:** [@Vik1](https://discourse.julialang.org/u/Vik1)\
**Replies:** 6\
**Last updated:** [February 14, 2025, 4:54pm UTC](https://discourse.julialang.org/t/why-is-the-namedtuple-slower-when-how-would-it-be-faster-is-it-still-allocated-on-the-stack/125902 "2025-02-14T16:54:48Z")

</div>

In the following case, the Dict beats the NamedTuple in the creation and in the lookup? Why is this the case? Am I missing something? using BenchmarkTools tup1 = NamedTuple(k =\> v for (k, v) in \[(:a, 5), (:b, 10)\]) tup…

---

## [When does @inbounds increase performance?](https://discourse.julialang.org/t/when-does-inbounds-increase-performance/123827)

<div class="topic-metadata">

**Author:** [@leespen1](https://discourse.julialang.org/u/leespen1)\
**Replies:** 14\
**Last updated:** [February 14, 2025, 1:00am UTC](https://discourse.julialang.org/t/when-does-inbounds-increase-performance/123827 "2025-02-14T01:00:44Z")

</div>

I am interested in making some optimizations in my software. I noticed many packages make use of the @inbounds macro, and the Julia manual mentions @inbounds in its performance tips section (Performance Tips · The Julia …

---

## [Can this performance be improved?](https://discourse.julialang.org/t/can-this-performance-be-improved/125768)

<div class="topic-metadata">

**Author:** [@ilanggear](https://discourse.julialang.org/u/ilanggear)\
**Replies:** 10\
**Last updated:** [February 13, 2025, 5:05pm UTC](https://discourse.julialang.org/t/can-this-performance-be-improved/125768 "2025-02-13T17:05:59Z")

</div>

I have used ProfileView.@profview to generate the attached flame graph. I have read and re-read the documentation, but I’m still not confident of my interpretation, or whether there is something I can improve. The top l…

---

## [Help understand allocation in small custom struct](https://discourse.julialang.org/t/help-understand-allocation-in-small-custom-struct/125865)

<div class="topic-metadata">

**Author:** [@Giorgos\_Vretinaris](https://discourse.julialang.org/u/Giorgos_Vretinaris)\
**Replies:** 4\
**Last updated:** [February 13, 2025, 2:19pm UTC](https://discourse.julialang.org/t/help-understand-allocation-in-small-custom-struct/125865 "2025-02-13T14:19:05Z")

</div>

I have the following small custom structs that one of which is recursive in nature abstract type TTNNode{T} end struct LeafNode{T,A\<:AbstractMatrix{T}} \<: TTNNode{T} U::A # Basis matrix U\_ℓ ∈ ℝ^{n\_ℓ × r\_ℓ} …

---

## [StructArrays.jl getindex cost memory](https://discourse.julialang.org/t/structarrays-jl-getindex-cost-memory/125853)

<div class="topic-metadata">

**Author:** [@kongdd](https://discourse.julialang.org/u/kongdd)\
**Replies:** 4\
**Last updated:** [February 13, 2025, 10:12am UTC](https://discourse.julialang.org/t/structarrays-jl-getindex-cost-memory/125853 "2025-02-13T10:12:04Z")

</div>

using StructArrays using BenchmarkTools abstract type AbstractSoilParam{T} end @kwdef mutable struct ParamCampbell{T} \<: AbstractSoilParam{T} θ\_sat::T = 0.287 # \[m3 m-3\] # θ\_res::T = 0.075 # \[m3 m-3\] ψ\_…

---

## [Compiler performance regression](https://discourse.julialang.org/t/compiler-performance-regression/125729)

<div class="topic-metadata">

**Author:** [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Replies:** 4\
**Last updated:** [February 10, 2025, 2:36pm UTC](https://discourse.julialang.org/t/compiler-performance-regression/125729 "2025-02-10T14:36:55Z")

</div>

Hi, We are currently developing a Julia package. Running this demo script (branch “dev”) results in 10x longer compilation in Julia 1.11.3, compared to 1.10.x. The package relies heavily on automatic differentiation, …

---

## [Reduce allocations & lock conflicts and speed up when using multithreads](https://discourse.julialang.org/t/reduce-allocations-lock-conflicts-and-speed-up-when-using-multithreads/125749)

<div class="topic-metadata">

**Author:** [@Stephen](https://discourse.julialang.org/u/Stephen)\
**Replies:** 1\
**Last updated:** [February 10, 2025, 2:11pm UTC](https://discourse.julialang.org/t/reduce-allocations-lock-conflicts-and-speed-up-when-using-multithreads/125749 "2025-02-10T14:11:41Z")

</div>

Hello there, performance enhancement help wanted: ▶ Initial function which gives 309.934138 seconds (5.00 M allocations: 1.982 GiB, 0.23% gc time, 2007 lock conflicts, 0.52% compilation time) 48-element Vector{String}: …

---

## [Performance Difference in Matrix Multiplication with Symmetric Matrices](https://discourse.julialang.org/t/performance-difference-in-matrix-multiplication-with-symmetric-matrices/125727)

<div class="topic-metadata">

**Author:** [@swanchristmas](https://discourse.julialang.org/u/swanchristmas)\
**Replies:** 3\
**Last updated:** [February 10, 2025, 10:09am UTC](https://discourse.julialang.org/t/performance-difference-in-matrix-multiplication-with-symmetric-matrices/125727 "2025-02-10T10:09:29Z")

</div>

Hi everyone, I have a question regarding the performance of matrix multiplication involving symmetric matrices in Julia. Here’s my code and the results: let N = 1000 λ, Γp = \[randn(N, N) for \_ in 1:2\] Γp\_symm =…

---

## [Speed of ldiv! for banded matrices in BandedMatrices.jl](https://discourse.julialang.org/t/speed-of-ldiv-for-banded-matrices-in-bandedmatrices-jl/125647)

<div class="topic-metadata">

**Author:** [@Ouyuan](https://discourse.julialang.org/u/Ouyuan)\
**Replies:** 2\
**Last updated:** [February 9, 2025, 4:11am UTC](https://discourse.julialang.org/t/speed-of-ldiv-for-banded-matrices-in-bandedmatrices-jl/125647 "2025-02-09T04:11:45Z")

</div>

Theoretically, solving banded matrix stored in Float32 should be twice faster than that stored in Float64. But this is not verified in my codes using BandedMatrices.jl. (Note that creating a random vector costs far less …

---

## [How to make splat, map and tuples be efficient](https://discourse.julialang.org/t/how-to-make-splat-map-and-tuples-be-efficient/125653)

<div class="topic-metadata">

**Author:** [@garazha-ilya](https://discourse.julialang.org/u/garazha-ilya)\
**Replies:** 3\
**Last updated:** [February 7, 2025, 7:08pm UTC](https://discourse.julialang.org/t/how-to-make-splat-map-and-tuples-be-efficient/125653 "2025-02-07T19:08:29Z")

</div>

Generally I want to make f(g("a"), g("c"), g("k")) with f(map(g, \["a","c","k"\])...) be efficient and don’t generate allocations. And I started experimenting, by creating 3 functions: function foo\_tuple(a,b,c) …

---

## [Reducing RAM usage when solving large set of differential equations](https://discourse.julialang.org/t/reducing-ram-usage-when-solving-large-set-of-differential-equations/125610)

<div class="topic-metadata">

**Author:** [@diffeqslvr](https://discourse.julialang.org/u/diffeqslvr)\
**Replies:** 5\
**Last updated:** [February 6, 2025, 3:27pm UTC](https://discourse.julialang.org/t/reducing-ram-usage-when-solving-large-set-of-differential-equations/125610 "2025-02-06T15:27:57Z")

</div>

I am solving a large system of differential equations (O(500 000) equations). Unsurprisingly, I run into RAM issues. I already tried to only save a subset of O(13 000) variables using a SavingCallback saved\_values = Sav…

---

## [How to quantitatively analyze the impact of memory bandwidth on multithreading](https://discourse.julialang.org/t/how-to-quantitatively-analyze-the-impact-of-memory-bandwidth-on-multithreading/125059)

<div class="topic-metadata">

**Author:** [@quantumdreamer](https://discourse.julialang.org/u/quantumdreamer)\
**Replies:** 10\
**Last updated:** [February 6, 2025, 3:20am UTC](https://discourse.julialang.org/t/how-to-quantitatively-analyze-the-impact-of-memory-bandwidth-on-multithreading/125059 "2025-02-06T03:20:15Z")

</div>

When I increased the number of threads in my Julia project, I noticed that the performance of the project did not scale linearly with the number of threads. Currently, the multi-threaded performance is twice that of the …

---

## [FFTW scales pretty well (some @btime benchmarks)](https://discourse.julialang.org/t/fftw-scales-pretty-well-some-btime-benchmarks/28341)

<div class="topic-metadata">

**Author:** [@xzackli](https://discourse.julialang.org/u/xzackli)\
**Replies:** 1\
**Last updated:** [February 4, 2025, 2:30pm UTC](https://discourse.julialang.org/t/fftw-scales-pretty-well-some-btime-benchmarks/28341 "2025-02-04T14:30:43Z")

</div>

I was misled into thinking that FFTW scales poorly in parallel after reading this discourse thread, so I wanted to post some numbers for someone trying to do fast FFTs in the future. My use case requires repeatedly perfo…

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

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