# Performance

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

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

**Page:** 35

---

## [Appropriate warning for size using code\_warntype](https://discourse.julialang.org/t/appropriate-warning-for-size-using-code-warntype/105457)

<div class="topic-metadata">

**Author:** [@Jake](https://discourse.julialang.org/u/Jake)\
**Replies:** 2\
**Last updated:** [October 27, 2023, 8:39am UTC](https://discourse.julialang.org/t/appropriate-warning-for-size-using-code-warntype/105457 "2023-10-27T08:39:12Z")

</div>

I tried profiling some code using JET. When I used size() on a matrix of type Any, the warning came back that the output of the function size is of type Any. This confused me because I thought size could only output of…

---

## [How to improve the implementation of a function involving a numerical integration?](https://discourse.julialang.org/t/how-to-improve-the-implementation-of-a-function-involving-a-numerical-integration/105444)

<div class="topic-metadata">

**Author:** [@lsablon](https://discourse.julialang.org/u/lsablon)\
**Replies:** 7\
**Last updated:** [October 27, 2023, 4:10am UTC](https://discourse.julialang.org/t/how-to-improve-the-implementation-of-a-function-involving-a-numerical-integration/105444 "2023-10-27T04:10:03Z")

</div>

Hello, I am trying to optimize my code, but I don’t really know in which direction I should go (but I know I don’t want to use multithreading). Here is my goal: I want to implement the following function k\_\\perp(x,y;…

---

## [Optimizing Complex Batch Matrix Multiplication](https://discourse.julialang.org/t/optimizing-complex-batch-matrix-multiplication/105381)

<div class="topic-metadata">

**Author:** [@quantumtwist](https://discourse.julialang.org/u/quantumtwist)\
**Replies:** 2\
**Last updated:** [October 25, 2023, 3:31pm UTC](https://discourse.julialang.org/t/optimizing-complex-batch-matrix-multiplication/105381 "2023-10-25T15:31:16Z")

</div>

Hello fellow Julians! In my code the bottleneck step is a batched ComplexF64 matrix multiplication of the form C\[i,k,n\] = conj(A)\[j,i,n\] \* B\[j,k,n\]. Naively, one should loop over n and do in-place multiplication. Howeve…

---

## [Compilation options for Downfall mitigation](https://discourse.julialang.org/t/compilation-options-for-downfall-mitigation/104844)

<div class="topic-metadata">

**Author:** [@mmesiti](https://discourse.julialang.org/u/mmesiti)\
**Replies:** 4\
**Last updated:** [October 25, 2023, 9:21am UTC](https://discourse.julialang.org/t/compilation-options-for-downfall-mitigation/104844 "2023-10-25T09:21:04Z")

</div>

Hello everybody, the code I am working on has suffered from a huge performance hit (up to 50%) because of the microcode update to mitigate the Downfall vulnerability. The generated code was using a lot of gather instruc…

---

## [About In-line-fft](https://discourse.julialang.org/t/about-in-line-fft/105340)

<div class="topic-metadata">

**Author:** [@Take1234](https://discourse.julialang.org/u/Take1234)\
**Replies:** 6\
**Last updated:** [October 24, 2023, 12:32pm UTC](https://discourse.julialang.org/t/about-in-line-fft/105340 "2023-10-24T12:32:07Z")

</div>

Hi Experts ,I’m just studing Julia But I’m in truble. Berrow 2D turblence simulation code is that I translated from Matlab is use too much memory. At my Simulation environment it use approx. 32 GB. I found some info abou…

---

## [How to use multithreading appropriately?](https://discourse.julialang.org/t/how-to-use-multithreading-appropriately/105154)

<div class="topic-metadata">

**Author:** [@Strange\_Xue](https://discourse.julialang.org/u/Strange_Xue)\
**Replies:** 6\
**Last updated:** [October 23, 2023, 1:26pm UTC](https://discourse.julialang.org/t/how-to-use-multithreading-appropriately/105154 "2023-10-23T13:26:18Z")

</div>

Functions having same output but different multithreading setting have very different performances. Why would this happen? Are there any rules to conform when using multithreading? Below shows the code snippets of data …

---

## [The Optimization Problem with Nested Loops in Julia](https://discourse.julialang.org/t/the-optimization-problem-with-nested-loops-in-julia/104833)

<div class="topic-metadata">

**Author:** [@Umut\_Can\_Turhan](https://discourse.julialang.org/u/Umut_Can_Turhan)\
**Replies:** 8\
**Last updated:** [October 23, 2023, 8:02am UTC](https://discourse.julialang.org/t/the-optimization-problem-with-nested-loops-in-julia/104833 "2023-10-23T08:02:55Z")

</div>

Hi everyone, I have a problem related to the optimization problem with nested loops. I use QuantumOptics.jl (qojulia.org) module to calculate for some physical situation. First of all, let me share my code and explain it…

---

## [Best way to count element pairs (x,y) satisfying a condition?](https://discourse.julialang.org/t/best-way-to-count-element-pairs-x-y-satisfying-a-condition/105264)

<div class="topic-metadata">

**Author:** [@Alergy](https://discourse.julialang.org/u/Alergy)\
**Replies:** 19\
**Last updated:** [October 22, 2023, 10:42am UTC](https://discourse.julialang.org/t/best-way-to-count-element-pairs-x-y-satisfying-a-condition/105264 "2023-10-22T10:42:00Z")

</div>

Hello everyone! I was trying to optimize the following MWE: using BenchmarkTools N = 2^20 a = rand(N); b = rand(N); @btime count(a+b .\< 1) 2.492 ms (9 allocations: 8.13 MiB) This seems to be allocating memory for a …

---

## [How to control options for displaying table in Weave.jl?](https://discourse.julialang.org/t/how-to-control-options-for-displaying-table-in-weave-jl/105256)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 0\
**Last updated:** [October 21, 2023, 1:17am UTC](https://discourse.julialang.org/t/how-to-control-options-for-displaying-table-in-weave-jl/105256 "2023-10-21T01:17:34Z")

</div>

Hello! I’ve been playing a bit with Weave.jl tonight and found it very fun to use! I tried to do a table though, and I must admit: I did struggle quite a bit. Basically it does work if one does; using DataFrames DataF…

---

## [2D Interpolation on an irregular grid](https://discourse.julialang.org/t/2d-interpolation-on-an-irregular-grid/105247)

<div class="topic-metadata">

**Author:** [@k\_j](https://discourse.julialang.org/u/k_j)\
**Replies:** 8\
**Last updated:** [October 20, 2023, 10:53pm UTC](https://discourse.julialang.org/t/2d-interpolation-on-an-irregular-grid/105247 "2023-10-20T22:53:52Z")

</div>

I want to do 2D interpolation on an irregular grid. In particular, I have a function f:\\mathbb R^2 \\rightarrow \\mathbb R, (x, y) \\mapsto z. I have an irregular grid D = (x\_i, y\_i)\_i as well as the corresponding values F…

---

## [PiNN model not working with an LSTM layer](https://discourse.julialang.org/t/pinn-model-not-working-with-an-lstm-layer/105222)

<div class="topic-metadata">

**Author:** [@Maria\_Adelaide\_Loffa](https://discourse.julialang.org/u/Maria_Adelaide_Loffa)\
**Replies:** 0\
**Last updated:** [October 20, 2023, 8:42am UTC](https://discourse.julialang.org/t/pinn-model-not-working-with-an-lstm-layer/105222 "2023-10-20T08:42:40Z")

</div>

Hi everyone, It hase been a while that I have an issue with a PINN model. When using a chain of dense layers, the model works fine. However, when using a chain of DENSE and LSTM layers, there seems to be something wrong…

---

## [MPI + Multithreading with ParallelStencil.jl + ImplicitGlobalGrid.jl](https://discourse.julialang.org/t/mpi-multithreading-with-parallelstencil-jl-implicitglobalgrid-jl/105138)

<div class="topic-metadata">

**Author:** [@ali-vaziri](https://discourse.julialang.org/u/ali-vaziri)\
**Replies:** 4\
**Last updated:** [October 19, 2023, 11:13pm UTC](https://discourse.julialang.org/t/mpi-multithreading-with-parallelstencil-jl-implicitglobalgrid-jl/105138 "2023-10-19T23:13:48Z")

</div>

Hi, I tried using ParallelStencil+ImplicitGlobalGrid with MPI on CPU clusters, but I cannot get the multiprocessing to work. I attempted the acoustic2D.jl example from the ParallelStencil repo and added ImplicitGlobalGr…

---

## [Relocation issue during create\_sysimage() of large libraries of code (Flux, FastAI, Cairo)](https://discourse.julialang.org/t/relocation-issue-during-create-sysimage-of-large-libraries-of-code-flux-fastai-cairo/105110)

<div class="topic-metadata">

**Author:** [@raph38130](https://discourse.julialang.org/u/raph38130)\
**Replies:** 0\
**Last updated:** [October 18, 2023, 10:09am UTC](https://discourse.julialang.org/t/relocation-issue-during-create-sysimage-of-large-libraries-of-code-flux-fastai-cairo/105110 "2023-10-18T10:09:38Z")

</div>

julia-1.9.3 on ibm power9 ppc64le I successfully created a sysimage with Flux, FastAI, … but can’t incrementally add CairoMakie due to relocation error. Working sysimage.so is 821MB large. Summary/tmp/jl\_uxK58XMbaX.o(t…

---

## [Avoid allocations on broadcasted getindex()](https://discourse.julialang.org/t/avoid-allocations-on-broadcasted-getindex/105098)

<div class="topic-metadata">

**Author:** [@ejmeitz](https://discourse.julialang.org/u/ejmeitz)\
**Replies:** 2\
**Last updated:** [October 18, 2023, 9:53am UTC](https://discourse.julialang.org/t/avoid-allocations-on-broadcasted-getindex/105098 "2023-10-18T09:53:36Z")

</div>

If I have the code below is there someway to do this without allocating intermediate arrays? It feels like it should be possible but I cant figure it out. I can do this without allocating if I was indexing with a range, …

---

## [Penalty for not defining mutable struct fields types](https://discourse.julialang.org/t/penalty-for-not-defining-mutable-struct-fields-types/105020)

<div class="topic-metadata">

**Author:** [@jondavis847](https://discourse.julialang.org/u/jondavis847)\
**Replies:** 10\
**Last updated:** [October 16, 2023, 8:20pm UTC](https://discourse.julialang.org/t/penalty-for-not-defining-mutable-struct-fields-types/105020 "2023-10-16T20:20:01Z")

</div>

Hello, I have a rather large and complicated mutable struct which I use to just house pre-allocated Vector{SArray} 's of a system. I can then pass this struct to my functions which get called many times without allocati…

---

## [Tasks booted to efficiency cores when not in foreground or rendered on the screen](https://discourse.julialang.org/t/tasks-booted-to-efficiency-cores-when-not-in-foreground-or-rendered-on-the-screen/104980)

<div class="topic-metadata">

**Author:** [@Di11on](https://discourse.julialang.org/u/Di11on)\
**Replies:** 2\
**Last updated:** [October 15, 2023, 7:14pm UTC](https://discourse.julialang.org/t/tasks-booted-to-efficiency-cores-when-not-in-foreground-or-rendered-on-the-screen/104980 "2023-10-15T19:14:04Z")

</div>

Hi folks, I have discovered an issue with my 13900k based machine (I now very much regret the poor choice of a 13900k). Processes run on performance cores when the app/task is in the foreground on the screen - but whene…

---

## [Why does this Python code performs three times faster than Julia?](https://discourse.julialang.org/t/why-does-this-python-code-performs-three-times-faster-than-julia/104919)

<div class="topic-metadata">

**Author:** [@SantiagoOrtiz](https://discourse.julialang.org/u/SantiagoOrtiz)\
**Replies:** 22\
**Last updated:** [October 13, 2023, 11:59pm UTC](https://discourse.julialang.org/t/why-does-this-python-code-performs-three-times-faster-than-julia/104919 "2023-10-13T23:59:17Z")

</div>

I tried to follow basic Performance Tips, but surprisingly, my Python code does it faster than Julia. # Julia code ʋ₀::Float64 = 1.0 r₀::Float64 = 1.0 n::Int64 = 5000000 const σ::Float64 = 1.0 const ϵ::Float64 = 1.0 c…

---

## [Tune Metropolis-Hastings (normal distribution) scale parameters (and algorithms parameters in general)](https://discourse.julialang.org/t/tune-metropolis-hastings-normal-distribution-scale-parameters-and-algorithms-parameters-in-general/104925)

<div class="topic-metadata">

**Author:** [@caesoma](https://discourse.julialang.org/u/caesoma)\
**Replies:** 10\
**Last updated:** [October 13, 2023, 5:32pm UTC](https://discourse.julialang.org/t/tune-metropolis-hastings-normal-distribution-scale-parameters-and-algorithms-parameters-in-general/104925 "2023-10-13T17:32:38Z")

</div>

I am doing Bayesian inference of a few parameters (~3), albeit of a highly nonlinear model, and I am interested in the performance of random-walk Metropolis-Hastings versus Hamiltonian Monte Carlo methods. I don’t expect…

---

## [Training a LSTM model for time series, lack of performance](https://discourse.julialang.org/t/training-a-lstm-model-for-time-series-lack-of-performance/104868)

<div class="topic-metadata">

**Author:** [@Maria\_Adelaide\_Loffa](https://discourse.julialang.org/u/Maria_Adelaide_Loffa)\
**Replies:** 9\
**Last updated:** [October 13, 2023, 4:16pm UTC](https://discourse.julialang.org/t/training-a-lstm-model-for-time-series-lack-of-performance/104868 "2023-10-13T16:16:58Z")

</div>

Hi everyone, I’m trying to train a LSTM model for forecasting a time series. At this stage training happens, but with a really bad performance: loss function values exhibit really minimal changes. I added a picture tha…

---

## [Static HMC mass matrix/metric parameter](https://discourse.julialang.org/t/static-hmc-mass-matrix-metric-parameter/104926)

<div class="topic-metadata">

**Author:** [@caesoma](https://discourse.julialang.org/u/caesoma)\
**Replies:** 0\
**Last updated:** [October 13, 2023, 10:13am UTC](https://discourse.julialang.org/t/static-hmc-mass-matrix-metric-parameter/104926 "2023-10-13T10:13:46Z")

</div>

I am running inference of a nonlinear model as described here it will run (albeit poorly) even with Metropolis-Hastings, and with acceptable results with NUTS and HMC with Dual averaging tuning of path length: With va…

---

## [What is the most idiomatic way to allocate a (reusable) buffer for a function?](https://discourse.julialang.org/t/what-is-the-most-idiomatic-way-to-allocate-a-reusable-buffer-for-a-function/104892)

<div class="topic-metadata">

**Author:** [@fph](https://discourse.julialang.org/u/fph)\
**Replies:** 10\
**Last updated:** [October 12, 2023, 2:42pm UTC](https://discourse.julialang.org/t/what-is-the-most-idiomatic-way-to-allocate-a-reusable-buffer-for-a-function/104892 "2023-10-12T14:42:55Z")

</div>

Suppose I have a function f that allocates, for instance the following function sum\_of\_fractions(a) v = map(x -\> 1/(x+a), 1:10) return sum(v) end Assume for the sake of this discussion that I cannot get rid of …

---

## [Call function on vectors of mixed type (using \`FunctionWrapper\` and \`Union\`s)](https://discourse.julialang.org/t/call-function-on-vectors-of-mixed-type-using-functionwrapper-and-union-s/92750)

<div class="topic-metadata">

**Author:** [@GoodDayToYouAll](https://discourse.julialang.org/u/GoodDayToYouAll)\
**Replies:** 2\
**Last updated:** [October 12, 2023, 9:52am UTC](https://discourse.julialang.org/t/call-function-on-vectors-of-mixed-type-using-functionwrapper-and-union-s/92750 "2023-10-12T09:52:30Z")

</div>

Hi everyone and a happy new year! In one part of my code I have a vector v whose elements have different types. Additionally, I have a function f with different methods for all the involved types and want to call this …

---

## [Training a NeuralODE with an ODE depending on exogenous time-dependent input](https://discourse.julialang.org/t/training-a-neuralode-with-an-ode-depending-on-exogenous-time-dependent-input/101304)

<div class="topic-metadata">

**Author:** [@Maria\_Adelaide\_Loffa](https://discourse.julialang.org/u/Maria_Adelaide_Loffa)\
**Replies:** 5\
**Last updated:** [October 12, 2023, 8:08am UTC](https://discourse.julialang.org/t/training-a-neuralode-with-an-ode-depending-on-exogenous-time-dependent-input/101304 "2023-10-12T08:08:23Z")

</div>

Hi everyone. I’m working on developing a NeuralODE trained on ad ODE which describes a building’s thermal behaviour through an RC equation. I tried both with the definition of a NeuralODE from a multilayer NN and by tr…

---

## [Correct way to perform direct socket io, i.e no memory copy](https://discourse.julialang.org/t/correct-way-to-perform-direct-socket-io-i-e-no-memory-copy/104758)

<div class="topic-metadata">

**Author:** [@L\_Adam](https://discourse.julialang.org/u/L_Adam)\
**Replies:** 1\
**Last updated:** [October 10, 2023, 7:26pm UTC](https://discourse.julialang.org/t/correct-way-to-perform-direct-socket-io-i-e-no-memory-copy/104758 "2023-10-10T19:26:43Z")

</div>

currently, socket read/write are through stream interface, and it’s buffered. and to read that, there is an extra memory copy with take!. what is the proper way to do direct socket io, without memory copy?(or is direct …

---

## [Loop vs vectorization](https://discourse.julialang.org/t/loop-vs-vectorization/104796)

<div class="topic-metadata">

**Author:** [@Alberto\_Roman](https://discourse.julialang.org/u/Alberto_Roman)\
**Replies:** 4\
**Last updated:** [October 10, 2023, 12:40pm UTC](https://discourse.julialang.org/t/loop-vs-vectorization/104796 "2023-10-10T12:40:15Z")

</div>

Hi all, I have a partial differential equation to solve using finite difference. I am trying to understand if it is better to use a vectorized version or a loop version to calculate the right hand side of the equation, …

---

## [Help in accelerating constructing Symbolic jacobian?](https://discourse.julialang.org/t/help-in-accelerating-constructing-symbolic-jacobian/104701)

<div class="topic-metadata">

**Author:** [@yewalenikhil65](https://discourse.julialang.org/u/yewalenikhil65)\
**Replies:** 9\
**Last updated:** [October 10, 2023, 1:19am UTC](https://discourse.julialang.org/t/help-in-accelerating-constructing-symbolic-jacobian/104701 "2023-10-10T01:19:06Z")

</div>

Can anyone help me accelerate/optimize this computation of symbolic computation of Jacobian? I am on latest version of Symbolics and julia 1.9.3. using Symbolics using ToeplitzMatrices N= 280; a = Symbolics.variable…

---

## [Most performant way to perform matrix and vector calculations in a function](https://discourse.julialang.org/t/most-performant-way-to-perform-matrix-and-vector-calculations-in-a-function/104672)

<div class="topic-metadata">

**Author:** [@eduardosalaz](https://discourse.julialang.org/u/eduardosalaz)\
**Replies:** 5\
**Last updated:** [October 9, 2023, 9:42pm UTC](https://discourse.julialang.org/t/most-performant-way-to-perform-matrix-and-vector-calculations-in-a-function/104672 "2023-10-09T21:42:50Z")

</div>

Hi there everone. Currently I have the following function: function start\_constraints(S, B, M, V, R, X, values\_matrix, risk\_vec) for i in 1:S for m in 1:M values\_matrix\[i, m\] = sum(X\[i, j\] \* V\[m\]…

---

## [Unknown memory allocation when displaying pixels in Gtk.jl](https://discourse.julialang.org/t/unknown-memory-allocation-when-displaying-pixels-in-gtk-jl/82566)

<div class="topic-metadata">

**Author:** [@Alan\_Bahm](https://discourse.julialang.org/u/Alan_Bahm)\
**Replies:** 1\
**Last updated:** [October 9, 2023, 9:47am UTC](https://discourse.julialang.org/t/unknown-memory-allocation-when-displaying-pixels-in-gtk-jl/82566 "2023-10-09T09:47:29Z")

</div>

Hi all! I have some memory allocation I don’t understand when using Gtk, and hoping for some advice. I’ve built an application to display and tweak (many) scientifically computed 2kx2k images, and they are displayed …

---

## [Any general ideas about reducing GC time involving DataFrames?](https://discourse.julialang.org/t/any-general-ideas-about-reducing-gc-time-involving-dataframes/104740)

<div class="topic-metadata">

**Author:** [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Replies:** 2\
**Last updated:** [October 9, 2023, 1:57am UTC](https://discourse.julialang.org/t/any-general-ideas-about-reducing-gc-time-involving-dataframes/104740 "2023-10-09T01:57:40Z")

</div>

Say I have thousands of CSV files to be processed. For each, I will read the file into a Dataframe, process it, and then store the results in another DataFrame. During this process, it seems two main allocations (one for…

---

## [Using Base.Iterators for optimization, good idea?](https://discourse.julialang.org/t/using-base-iterators-for-optimization-good-idea/104717)

<div class="topic-metadata">

**Author:** [@bguillen](https://discourse.julialang.org/u/bguillen)\
**Replies:** 0\
**Last updated:** [October 7, 2023, 10:15pm UTC](https://discourse.julialang.org/t/using-base-iterators-for-optimization-good-idea/104717 "2023-10-07T22:15:34Z")

</div>

I implemented Hoare and Lomuto’s partitions with iterators. They behave as expected in terms of numbers of comparisons (N-1) and swaps (Hoare’s doing fewer than Lomuto’s). However the benchmarks are giving me same times…

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

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