# Performance

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

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

**Page:** 10

---

## [Enzyme custom rule alloactions](https://discourse.julialang.org/t/enzyme-custom-rule-alloactions/128491)

<div class="topic-metadata">

**Author:** [@c\_sell](https://discourse.julialang.org/u/c_sell)\
**Replies:** 0\
**Last updated:** [April 28, 2025, 2:11pm UTC](https://discourse.julialang.org/t/enzyme-custom-rule-alloactions/128491 "2025-04-28T14:11:20Z")

</div>

Hello, I got a problem with allocations when using custom rules in Enzyme. The example below is just a toy example but the same problem arises there. In total I get 4 alloactions. 2 by the line primal = func.val(y.va…

---

## [A Brief Study of Memory Bound Application Performance on M3 Ultra and M4 Max in Julia](https://discourse.julialang.org/t/a-brief-study-of-memory-bound-application-performance-on-m3-ultra-and-m4-max-in-julia/128459)

<div class="topic-metadata">

**Author:** [@PetarM](https://discourse.julialang.org/u/PetarM)\
**Replies:** 2\
**Last updated:** [April 27, 2025, 12:07pm UTC](https://discourse.julialang.org/t/a-brief-study-of-memory-bound-application-performance-on-m3-ultra-and-m4-max-in-julia/128459 "2025-04-27T12:07:10Z")

</div>

Hello everybody! I wanted to share my Linear Algebra performance findings in Julia on the M4 Max and M3 Ultra in double precision floating point. As a Julia novice, I was hugely impressed how easy it was for me to brain…

---

## [Struggling to understand how to use PrecompileTools](https://discourse.julialang.org/t/struggling-to-understand-how-to-use-precompiletools/128419)

<div class="topic-metadata">

**Author:** [@freeman](https://discourse.julialang.org/u/freeman)\
**Replies:** 25\
**Last updated:** [April 26, 2025, 10:49pm UTC](https://discourse.julialang.org/t/struggling-to-understand-how-to-use-precompiletools/128419 "2025-04-26T22:49:58Z")

</div>

Hello! I wrote a bunch of libs in Julia that all work together. One lib in particular exists just to read and stream a certain data from HDF5 files. One of the functions in this lib has the job of, given one of these HD…

---

## [Performance of Hermitian eigensolvers](https://discourse.julialang.org/t/performance-of-hermitian-eigensolvers/23142)

<div class="topic-metadata">

**Author:** [@Invarianz](https://discourse.julialang.org/u/Invarianz)\
**Replies:** 2\
**Last updated:** [April 26, 2025, 3:01am UTC](https://discourse.julialang.org/t/performance-of-hermitian-eigensolvers/23142 "2025-04-26T03:01:49Z")

</div>

I usually work with full diagonalisation of Hermitian matrices. After some research I realised that there are two options to retrieve the eigenvalues and eigenvectors of such a matrix. LinearAlgebra.LAPACK.syev!() and e…

---

## [Sub-arrays of static arrays](https://discourse.julialang.org/t/sub-arrays-of-static-arrays/128406)

<div class="topic-metadata">

**Author:** [@TimHargreaves](https://discourse.julialang.org/u/TimHargreaves)\
**Replies:** 6\
**Last updated:** [April 25, 2025, 5:53pm UTC](https://discourse.julialang.org/t/sub-arrays-of-static-arrays/128406 "2025-04-25T17:53:47Z")

</div>

From a previous step in my computations, I have a static array and I would now like to perform an operation, say a QR decomposition, on a sub-array. This is performance critical code so I would like to squeeze as much sp…

---

## [Nextfloat is slower on 2D array than on 1D array](https://discourse.julialang.org/t/nextfloat-is-slower-on-2d-array-than-on-1d-array/128380)

<div class="topic-metadata">

**Author:** [@hawahe](https://discourse.julialang.org/u/hawahe)\
**Replies:** 14\
**Last updated:** [April 25, 2025, 4:27pm UTC](https://discourse.julialang.org/t/nextfloat-is-slower-on-2d-array-than-on-1d-array/128380 "2025-04-25T16:27:36Z")

</div>

Running the following function with a 2D array is much slower than running it with the same array but flattened to a 1D array, and both return the same result. Why is the 2D version slower? function test(data::Array{Flo…

---

## [Pre-allocate intermediate arrays for multi-threading](https://discourse.julialang.org/t/pre-allocate-intermediate-arrays-for-multi-threading/128312)

<div class="topic-metadata">

**Author:** [@pulk\_jain](https://discourse.julialang.org/u/pulk_jain)\
**Replies:** 12\
**Last updated:** [April 24, 2025, 10:37pm UTC](https://discourse.julialang.org/t/pre-allocate-intermediate-arrays-for-multi-threading/128312 "2025-04-24T22:37:45Z")

</div>

Hi, I need help in pre-allocating some inner-variables of a for loop to reduce allocations in a multi-threaded code. I am creating multiple local arrays inside the for loop for intermediate calculations. Here’s a MWE wit…

---

## [Why functions in SpecialFunctions package work on CUDA arrays?](https://discourse.julialang.org/t/why-functions-in-specialfunctions-package-work-on-cuda-arrays/128194)

<div class="topic-metadata">

**Author:** [@singularity](https://discourse.julialang.org/u/singularity)\
**Replies:** 7\
**Last updated:** [April 20, 2025, 7:04am UTC](https://discourse.julialang.org/t/why-functions-in-specialfunctions-package-work-on-cuda-arrays/128194 "2025-04-20T07:04:45Z")

</div>

HI. I am confused how the behavior of functions inside the SpecialFunctions package on CUDA arrays. I am confused why the code below works and doesn’t throw an error at the last line. using CUDA using SpecialFunctions…

---

## [Mutable structs seem cause way more allocations in multithreaded code](https://discourse.julialang.org/t/mutable-structs-seem-cause-way-more-allocations-in-multithreaded-code/128156)

<div class="topic-metadata">

**Author:** [@Salmon](https://discourse.julialang.org/u/Salmon)\
**Replies:** 2\
**Last updated:** [April 17, 2025, 10:10am UTC](https://discourse.julialang.org/t/mutable-structs-seem-cause-way-more-allocations-in-multithreaded-code/128156 "2025-04-17T10:10:34Z")

</div>

Hi everyone, I have encountered a pretty annoying performance bottleneck when using StatsBase.Weights, which is a mutable struct (whatever may be the reason for that :P) , in a multithreaded setting. After going down t…

---

## [Vim LaTeX-to-Unicode substitutions](https://discourse.julialang.org/t/vim-latex-to-unicode-substitutions/128109)

<div class="topic-metadata">

**Author:** [@Doug719](https://discourse.julialang.org/u/Doug719)\
**Replies:** 3\
**Last updated:** [April 16, 2025, 11:09pm UTC](https://discourse.julialang.org/t/vim-latex-to-unicode-substitutions/128109 "2025-04-16T23:09:11Z")

</div>

I am using vim on macos, latest version. I have tried the installation instructions in JuliaEditorSupport/julia-vim. The LaTex-to-Unicode substitutions do not work. I would appreciate some detailed advice on how to ge…

---

## [Fancy LLVM loop transformation pass that deoptimize the code](https://discourse.julialang.org/t/fancy-llvm-loop-transformation-pass-that-deoptimize-the-code/128100)

<div class="topic-metadata">

**Author:** [@JohnnyChen94](https://discourse.julialang.org/u/JohnnyChen94)\
**Replies:** 2\
**Last updated:** [April 16, 2025, 11:27am UTC](https://discourse.julialang.org/t/fancy-llvm-loop-transformation-pass-that-deoptimize-the-code/128100 "2025-04-16T11:27:00Z")

</div>

Recently we’ve seen one strange performance regression report, and the following is a MWE we can get: using BenchmarkTools function rand\_n\_1(a,n) r = Vector{UInt}(undef,n) @inbounds for i in 1:n p = a\[1…

---

## [Possibly mildly faster sign for integers?](https://discourse.julialang.org/t/possibly-mildly-faster-sign-for-integers/128086)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 12\
**Last updated:** [April 15, 2025, 5:22pm UTC](https://discourse.julialang.org/t/possibly-mildly-faster-sign-for-integers/128086 "2025-04-15T17:22:52Z")

</div>

Suggested in a stackoverflow answer on micro optimization - Fast sign of integer in C - Stack Overflow julia\> \_sign(x) = (x \> 0) - (x \< 0) \_sign (generic function with 1 method) Using this, julia\> v = 1:1\_000; w = sim…

---

## [Preserve sparse structure during in-place operations](https://discourse.julialang.org/t/preserve-sparse-structure-during-in-place-operations/127864)

<div class="topic-metadata">

**Author:** [@luke-kiernan](https://discourse.julialang.org/u/luke-kiernan)\
**Replies:** 1\
**Last updated:** [April 15, 2025, 2:00am UTC](https://discourse.julialang.org/t/preserve-sparse-structure-during-in-place-operations/127864 "2025-04-15T02:00:02Z")

</div>

SparseArrays automatically runs dropzeros! after certain operations: for example, using SparseArrays A = spdiagm(ones(3)) println(nnz(A)) # result: 3 A .+= spdiagm(-1 .\* ones(3)) println(nnz(A)) # result: 0 How can I p…

---

## [Repeated Convolutions With Large 1D Arrays](https://discourse.julialang.org/t/repeated-convolutions-with-large-1d-arrays/127194)

<div class="topic-metadata">

**Author:** [@donkeysaddle](https://discourse.julialang.org/u/donkeysaddle)\
**Replies:** 20\
**Last updated:** [April 14, 2025, 7:45pm UTC](https://discourse.julialang.org/t/repeated-convolutions-with-large-1d-arrays/127194 "2025-04-14T19:45:45Z")

</div>

What’s the optimal way to compute repeated convolutions with large 1D arrays? the filters, (g\_x,g\_y, & g\_z) stay the same each iteration, but the “signals” change. To be clear, the computation of the f’s is fast, the co…

---

## [Design of efficient lazy broadcastable operator](https://discourse.julialang.org/t/design-of-efficient-lazy-broadcastable-operator/128049)

<div class="topic-metadata">

**Author:** [@Vitor\_Patricio\_Canta](https://discourse.julialang.org/u/Vitor_Patricio_Canta)\
**Replies:** 11\
**Last updated:** [April 14, 2025, 12:29pm UTC](https://discourse.julialang.org/t/design-of-efficient-lazy-broadcastable-operator/128049 "2025-04-14T12:29:09Z")

</div>

Hi, I am designing a bunch of operators I would like to evaluate lazily on sets of points (grid cells). The problem is that my design pattern still allocates a bit more when broadcasting, and involves me extending the b…

---

## [Type-instability, runtime dispatch, and heap allocations](https://discourse.julialang.org/t/type-instability-runtime-dispatch-and-heap-allocations/127985)

<div class="topic-metadata">

**Author:** [@StevenWhitaker](https://discourse.julialang.org/u/StevenWhitaker)\
**Replies:** 3\
**Last updated:** [April 12, 2025, 5:51am UTC](https://discourse.julialang.org/t/type-instability-runtime-dispatch-and-heap-allocations/127985 "2025-04-12T05:51:45Z")

</div>

I wanted to check/improve my understanding of allocations caused by type-instabilities. Consider the following: function f() x = g() y = h(x) z = b(x) end g() = Any\[1\]\[1\] h(::Int) = 1 h(::Any) = Any\[2\]\[1\]…

---

## [Ref is not a concrete type - poorly documented?](https://discourse.julialang.org/t/ref-is-not-a-concrete-type-poorly-documented/120375)

<div class="topic-metadata">

**Author:** [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Replies:** 17\
**Last updated:** [April 12, 2025, 10:18am UTC](https://discourse.julialang.org/t/ref-is-not-a-concrete-type-poorly-documented/120375 "2025-04-12T10:18:08Z")

</div>

I just learned from Why are ref's in structs type unstable? that Ref is not a concrete type, and so structs containing a Ref are not type-stable, e.g. struct Foo a::Ref end Instead you have to use, for example, RefVa…

---

## [Matrix vector multiplication: impact of column major vs row major (M4 Max)](https://discourse.julialang.org/t/matrix-vector-multiplication-impact-of-column-major-vs-row-major-m4-max/127936)

<div class="topic-metadata">

**Author:** [@PetarM](https://discourse.julialang.org/u/PetarM)\
**Replies:** 6\
**Last updated:** [April 10, 2025, 5:19pm UTC](https://discourse.julialang.org/t/matrix-vector-multiplication-impact-of-column-major-vs-row-major-m4-max/127936 "2025-04-10T17:19:31Z")

</div>

Hello! I recently got a Mac Studio M4 Max, and I am having fun exploring its compute capabilities in Julia. In particular, I wanted to see how well it could take advantage of its substantial memory bandwidth (546 GB/s) …

---

## [Improve performance in Flux.jl](https://discourse.julialang.org/t/improve-performance-in-flux-jl/127939)

<div class="topic-metadata">

**Author:** [@Wuaphi](https://discourse.julialang.org/u/Wuaphi)\
**Replies:** 0\
**Last updated:** [April 10, 2025, 4:42pm UTC](https://discourse.julialang.org/t/improve-performance-in-flux-jl/127939 "2025-04-10T16:42:33Z")

</div>

I tried to train a LSTM model in Flux.jl, but whatever I do, the gpu usage only reaches about 50%. But I can’t make the batchsize bigger, as the vram is nearly full. I would appreciate any kind of help. module Lstm …

---

## [Ref{T} vs Base.RefValue{T}](https://discourse.julialang.org/t/ref-t-vs-base-refvalue-t/127886)

<div class="topic-metadata">

**Author:** [@linwaytin](https://discourse.julialang.org/u/linwaytin)\
**Replies:** 20\
**Last updated:** [April 10, 2025, 1:07pm UTC](https://discourse.julialang.org/t/ref-t-vs-base-refvalue-t/127886 "2025-04-10T13:07:07Z")

</div>

Sometimes I want to make a field in a type mutable, and I do like struct S a::Ref{Float64} end This looks similar to the reference type used in ccall like @ccall f(a::Ref{Int})::Cdouble so I always thought it’s good. …

---

## [About reproducibility of Julia program run times](https://discourse.julialang.org/t/about-reproducibility-of-julia-program-run-times/127613)

<div class="topic-metadata">

**Author:** [@uwestoehr](https://discourse.julialang.org/u/uwestoehr)\
**Replies:** 20\
**Last updated:** [April 9, 2025, 4:12pm UTC](https://discourse.julialang.org/t/about-reproducibility-of-julia-program-run-times/127613 "2025-04-09T16:12:57Z")

</div>

I have a general issue with Julia. I know there is no solution but something should be done because as it is collaborative work is hard: The runtime of Julia programs is not stable. I don’t see fluctuations in the range…

---

## [Why does SMatrix allocate in this case?](https://discourse.julialang.org/t/why-does-smatrix-allocate-in-this-case/127808)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 3\
**Last updated:** [April 8, 2025, 2:12pm UTC](https://discourse.julialang.org/t/why-does-smatrix-allocate-in-this-case/127808 "2025-04-08T14:12:34Z")

</div>

Hello everyone, Suppose I have: using StaticArrays using Chairmarks N = 10 Dimensions = 2 DimensionsPlus = Dimensions + 1 FloatType = Float64 SVectors = rand(SVector{DimensionsPlus, FloatType}, N) MVectors =…

---

## [Tasks from Distributed don't release memory](https://discourse.julialang.org/t/tasks-from-distributed-dont-release-memory/127801)

<div class="topic-metadata">

**Author:** [@alequa](https://discourse.julialang.org/u/alequa)\
**Replies:** 0\
**Last updated:** [April 7, 2025, 2:36pm UTC](https://discourse.julialang.org/t/tasks-from-distributed-dont-release-memory/127801 "2025-04-07T14:36:44Z")

</div>

Hello, I use Julia on a SlurmCluster. I recently encountered several problems with OutOfMemory errors. I run a package for Spiking Neural Network simulations that I co-develop, and in which I have no explicit memory ma…

---

## [LIBSVM call on remote workers requires waiting](https://discourse.julialang.org/t/libsvm-call-on-remote-workers-requires-waiting/127796)

<div class="topic-metadata">

**Author:** [@alequa](https://discourse.julialang.org/u/alequa)\
**Replies:** 1\
**Last updated:** [April 7, 2025, 1:13pm UTC](https://discourse.julialang.org/t/libsvm-call-on-remote-workers-requires-waiting/127796 "2025-04-07T13:13:46Z")

</div>

Hello, I have been getting a bit crazy on this (now solved) problem. I am running a SVM classification on a remote worker, the LIBSVM is imported under the hood of another module, let’s call it ClassifierModule, so th…

---

## [Excessive memory consumption when optimising Gaussian process regression with automatic reverse differentiation](https://discourse.julialang.org/t/excessive-memory-consumption-when-optimising-gaussian-process-regression-with-automatic-reverse-differentiation/127772)

<div class="topic-metadata">

**Author:** [@Nikos\_Gianniotis](https://discourse.julialang.org/u/Nikos_Gianniotis)\
**Replies:** 2\
**Last updated:** [April 7, 2025, 6:27am UTC](https://discourse.julialang.org/t/excessive-memory-consumption-when-optimising-gaussian-process-regression-with-automatic-reverse-differentiation/127772 "2025-04-07T06:27:01Z")

</div>

I am working on a model involving Gaussian processes and I am optimising it using Optim.jl while obtaining gradients via DifferentiationInterface.jl. Unfortunately, when I run the code, the top utility informs me that th…

---

## [Efficiently Read JSON and Create DataFrame](https://discourse.julialang.org/t/efficiently-read-json-and-create-dataframe/41087)

<div class="topic-metadata">

**Author:** [@Dominic\_Pazzula](https://discourse.julialang.org/u/Dominic_Pazzula)\
**Replies:** 23\
**Last updated:** [April 3, 2025, 6:00am UTC](https://discourse.julialang.org/t/efficiently-read-json-and-create-dataframe/41087 "2025-04-03T06:00:28Z")

</div>

I am taking in a simulation from another process written in existing software. It outputs a JSON package of a few tables (stored as array of objects). I am running an optimization in JuMP based on the simulation. The …

---

## [@defined "not working" inside macro](https://discourse.julialang.org/t/defined-not-working-inside-macro/127621)

<div class="topic-metadata">

**Author:** [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Replies:** 8\
**Last updated:** [April 2, 2025, 12:03pm UTC](https://discourse.julialang.org/t/defined-not-working-inside-macro/127621 "2025-04-02T12:03:42Z")

</div>

Predictably, when I do metaprogramming, I end up confused. I create functions that take user-defined function as an input - very flexible. But when the user writes a script to use my function, each time they parse the …

---

## [Facing problem in computing error in transient problem](https://discourse.julialang.org/t/facing-problem-in-computing-error-in-transient-problem/127628)

<div class="topic-metadata">

**Author:** [@Stayal](https://discourse.julialang.org/u/Stayal)\
**Replies:** 0\
**Last updated:** [April 2, 2025, 1:24pm UTC](https://discourse.julialang.org/t/facing-problem-in-computing-error-in-transient-problem/127628 "2025-04-02T13:24:06Z")

</div>

Hello everyone using Gridap using Printf domain = (0.0, 1.0, 0.0, 1.0) partition = (4, 4) model = CartesianDiscreteModel(domain, partition) order = 1 reffe = ReferenceFE(lagrangian, Float64, order) u\_ex(t) = x -\> t\*t…

---

## [Efficient way compute do WX+b?](https://discourse.julialang.org/t/efficient-way-compute-do-wx-b/127385)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 7\
**Last updated:** [April 2, 2025, 12:36pm UTC](https://discourse.julialang.org/t/efficient-way-compute-do-wx-b/127385 "2025-04-02T12:36:57Z")

</div>

Which is in Julia the most efficient CPU-way to compute Wx+b where W is a (JxI) matrix, X is a I-dimensional vector and b is a J dimensional vector ? (context: NN layers) I have saw this thread but I can’t understand…

---

## [Why does explicit declaration of ::INT save 40% runtime?](https://discourse.julialang.org/t/why-does-explicit-declaration-of-int-save-40-runtime/127575)

<div class="topic-metadata">

**Author:** [@uwestoehr](https://discourse.julialang.org/u/uwestoehr)\
**Replies:** 17\
**Last updated:** [April 2, 2025, 6:14am UTC](https://discourse.julialang.org/t/why-does-explicit-declaration-of-int-save-40-runtime/127575 "2025-04-02T06:14:08Z")

</div>

I am relatively new to Julia and I wrote some scripts my main issue is that my scripts perform always poor and I don’t understand why or what I am doing wrong. Take this code as example where I am failing: dimension = …

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

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