# Performance

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

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

**Page:** 110

---

## [How to prevent memory build-up?](https://discourse.julialang.org/t/how-to-prevent-memory-build-up/45929)

<div class="topic-metadata">

**Author:** [@adevaucorbeil](https://discourse.julialang.org/u/adevaucorbeil)\
**Replies:** 11\
**Last updated:** [September 4, 2020, 1:42am UTC](https://discourse.julialang.org/t/how-to-prevent-memory-build-up/45929 "2020-09-04T01:42:01Z")

</div>

Hi there, I have a complex modeling code that involves a while loop which could be run a million times. In this loop, there are many, but some no-so complex mathematical operations involving SVectors and Arrays of SVect…

---

## [Static Arrays in pure Julia](https://discourse.julialang.org/t/static-arrays-in-pure-julia/46030)

<div class="topic-metadata">

**Author:** [@Renan\_Rabelo](https://discourse.julialang.org/u/Renan_Rabelo)\
**Replies:** 2\
**Last updated:** [September 3, 2020, 11:22pm UTC](https://discourse.julialang.org/t/static-arrays-in-pure-julia/46030 "2020-09-03T23:22:17Z")

</div>

Before Julia I used to code in Java, and Java has static arrays (immutable size). I know for sure that static arrays are way faster than dynamic ones, so how can I use they in pure Julia? I found a package called “Stat…

---

## [Julia 1.5.1 slows down when running multiple instances in parallel](https://discourse.julialang.org/t/julia-1-5-1-slows-down-when-running-multiple-instances-in-parallel/45934)

<div class="topic-metadata">

**Author:** [@stakaz](https://discourse.julialang.org/u/stakaz)\
**Replies:** 7\
**Last updated:** [September 2, 2020, 11:27am UTC](https://discourse.julialang.org/t/julia-1-5-1-slows-down-when-running-multiple-instances-in-parallel/45934 "2020-09-02T11:27:57Z")

</div>

Hello, I noticed a weird behavior in julia 1.5.1 performance (e. g. loading packages) compared to julia 1.1.0. I have a batch script which starts various julia scripts simultaneously on a cluster. In a simplified versi…

---

## [Makie: animation becomes slow after redrawing surface about 25 times](https://discourse.julialang.org/t/makie-animation-becomes-slow-after-redrawing-surface-about-25-times/45582)

<div class="topic-metadata">

**Author:** [@samo](https://discourse.julialang.org/u/samo)\
**Replies:** 8\
**Last updated:** [September 2, 2020, 10:16am UTC](https://discourse.julialang.org/t/makie-animation-becomes-slow-after-redrawing-surface-about-25-times/45582 "2020-09-02T10:16:27Z")

</div>

Context I am working on an example of a 3-D visualization of a 2-D glacier flow. Until now the visualization is done for a very small problem (256x256 grid points). Later it should also work for much larger problems. Pr…

---

## [Switched from Python to Julia for speed, but it's not faster...?](https://discourse.julialang.org/t/switched-from-python-to-julia-for-speed-but-its-not-faster/45904)

<div class="topic-metadata">

**Author:** [@PaulScotti](https://discourse.julialang.org/u/PaulScotti)\
**Replies:** 12\
**Last updated:** [September 2, 2020, 2:51am UTC](https://discourse.julialang.org/t/switched-from-python-to-julia-for-speed-but-its-not-faster/45904 "2020-09-02T02:51:43Z")

</div>

I have a Python script where the major speed hurdle is a single function in the statsmodels package. However, it seems that if I use PyCall to use the same Python function in Julia, the speed hurdle persists to the same …

---

## [Understanding relative performance of (returning vs. mutating vs. both) functions](https://discourse.julialang.org/t/understanding-relative-performance-of-returning-vs-mutating-vs-both-functions/45862)

<div class="topic-metadata">

**Author:** [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Replies:** 9\
**Last updated:** [September 1, 2020, 10:29pm UTC](https://discourse.julialang.org/t/understanding-relative-performance-of-returning-vs-mutating-vs-both-functions/45862 "2020-09-01T22:29:23Z")

</div>

I’m trying to choose the fastest among the following 3 functions: using Test, BenchmarkTools function Mut!(x::Array{Int64,2},y::Array{Int64,1}) map!(z-\>z\*2,x,x) y .= vec(reduce(+,x,dims=1)) end function MutRet(…

---

## [Speed up in Julia](https://discourse.julialang.org/t/speed-up-in-julia/45864)

<div class="topic-metadata">

**Author:** [@Nova](https://discourse.julialang.org/u/Nova)\
**Replies:** 11\
**Last updated:** [September 1, 2020, 2:58pm UTC](https://discourse.julialang.org/t/speed-up-in-julia/45864 "2020-09-01T14:58:35Z")

</div>

I have a question to figure out how to improve the performance of my code in Julia. I have a function that takes N seconds to be finished. I want to optimize the function to achieve a better performance. To do this, I g…

---

## [Reading data in Julia 1.2.0](https://discourse.julialang.org/t/reading-data-in-julia-1-2-0/45876)

<div class="topic-metadata">

**Author:** [@Nova](https://discourse.julialang.org/u/Nova)\
**Replies:** 1\
**Last updated:** [September 1, 2020, 7:55am UTC](https://discourse.julialang.org/t/reading-data-in-julia-1-2-0/45876 "2020-09-01T07:55:24Z")

</div>

I have a file (A.nets) storing data in the following format: NetDegree : 4 n0 o197239 I : -0.500000 -6.000000 o197110 O : -1.500000 -3.000000 o85644 I : -6.000000 -2.000000 o0 I : -3.000000 -5.000000 NetDegree : …

---

## [Best way to initialize a sparse matrix with some non-zero columns](https://discourse.julialang.org/t/best-way-to-initialize-a-sparse-matrix-with-some-non-zero-columns/45856)

<div class="topic-metadata">

**Author:** [@mleprovost](https://discourse.julialang.org/u/mleprovost)\
**Replies:** 2\
**Last updated:** [August 31, 2020, 10:41pm UTC](https://discourse.julialang.org/t/best-way-to-initialize-a-sparse-matrix-with-some-non-zero-columns/45856 "2020-08-31T22:41:42Z")

</div>

Hello, I would like to initialize a sparse array A of size N \\times Nx, for which only the columns in dims are non-zeros. How can I improve this code? using LinearAlgebra using SparseArrays N = 200 Nx = 20 dim = \[1…

---

## [Speed up sparse matrix multiplication](https://discourse.julialang.org/t/speed-up-sparse-matrix-multiplication/45819)

<div class="topic-metadata">

**Author:** [@Nova](https://discourse.julialang.org/u/Nova)\
**Replies:** 8\
**Last updated:** [August 31, 2020, 7:55pm UTC](https://discourse.julialang.org/t/speed-up-sparse-matrix-multiplication/45819 "2020-08-31T19:55:56Z")

</div>

I have a sparse matrix multiplication in my code but it’s very slow, is there anyway to make it faster? @btime A2 = D \* A \* D 50.816 s (18 allocations: 5.12 GiB) A: adjacency matrix, 6554063×6554063 SparseMatrixCSC{F…

---

## [Conditionally suppress output of @time](https://discourse.julialang.org/t/conditionally-suppress-output-of-time/45851)

<div class="topic-metadata">

**Author:** [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Replies:** 2\
**Last updated:** [August 31, 2020, 7:39pm UTC](https://discourse.julialang.org/t/conditionally-suppress-output-of-time/45851 "2020-08-31T19:39:49Z")

</div>

Is there a parameterized version of @time where I can suppress output unless e.g. ‘log\_level \> k’ ? I would like to make the performance of a sequence of function calls debuggable with minimal repetition of code

---

## [Comparing performance of 2 simple averaging functions - why is one faster?](https://discourse.julialang.org/t/comparing-performance-of-2-simple-averaging-functions-why-is-one-faster/45854)

<div class="topic-metadata">

**Author:** [@lwhitefox](https://discourse.julialang.org/u/lwhitefox)\
**Replies:** 5\
**Last updated:** [August 31, 2020, 7:06pm UTC](https://discourse.julialang.org/t/comparing-performance-of-2-simple-averaging-functions-why-is-one-faster/45854 "2020-08-31T19:06:29Z")

</div>

Below I include code for two simple functions that compute averages of pairs of adjacent values in an input 1D vector. Function f2 is almost twice as fast as f3 - I’d like to understand why! If anything, I would have ex…

---

## [Performant piecewise function evaluation](https://discourse.julialang.org/t/performant-piecewise-function-evaluation/45762)

<div class="topic-metadata">

**Author:** [@archermarx](https://discourse.julialang.org/u/archermarx)\
**Replies:** 4\
**Last updated:** [August 30, 2020, 7:31pm UTC](https://discourse.julialang.org/t/performant-piecewise-function-evaluation/45762 "2020-08-30T19:31:20Z")

</div>

I’m working on developing a solver that requires piecewise-defined polynomial functions to be evaluated very frequently. The easiest way to define such a function would be something like function piecewise\_hardcoded(x) …

---

## [Arrays of structs/tuples with mutable members](https://discourse.julialang.org/t/arrays-of-structs-tuples-with-mutable-members/45754)

<div class="topic-metadata">

**Author:** [@Stephen\_Vavasis](https://discourse.julialang.org/u/Stephen_Vavasis)\
**Replies:** 4\
**Last updated:** [August 29, 2020, 7:23pm UTC](https://discourse.julialang.org/t/arrays-of-structs-tuples-with-mutable-members/45754 "2020-08-29T19:23:11Z")

</div>

I tested the performance of an array of tuples and structs in Julia 1.3.1 and 1.5.1 and am a bit confused about the results. There are eight separate times based on three choices: 1.3.1 vs 1.5.1, structs vs tuples, and …

---

## [LoopVectorization.jl: adding \`@avx\` makes code slower](https://discourse.julialang.org/t/loopvectorization-jl-adding-avx-makes-code-slower/45742)

<div class="topic-metadata">

**Author:** [@ranocha](https://discourse.julialang.org/u/ranocha)\
**Replies:** 8\
**Last updated:** [August 29, 2020, 4:22pm UTC](https://discourse.julialang.org/t/loopvectorization-jl-adding-avx-makes-code-slower/45742 "2020-08-29T16:22:34Z")

</div>

I am given a multi-dimensional Array and have to multiply it by an SMatrix along multiple dimensions. Using a straightforward approach in 2 dimensions, adding @avx from the great package LoopVectorization.jl increases th…

---

## [Data copying in Distributed computing](https://discourse.julialang.org/t/data-copying-in-distributed-computing/45704)

<div class="topic-metadata">

**Author:** [@Sheemon7](https://discourse.julialang.org/u/Sheemon7)\
**Replies:** 0\
**Last updated:** [August 28, 2020, 7:25pm UTC](https://discourse.julialang.org/t/data-copying-in-distributed-computing/45704 "2020-08-28T19:25:06Z")

</div>

I have a perfectly parallelizable task, which I want to compute using several processes (threads are not applicable here). Say I want to pmap a function f, taking about 1-10 seconds over a vector A of 10M elements. The p…

---

## [Setfield redundant load/store elision fails with unions](https://discourse.julialang.org/t/setfield-redundant-load-store-elision-fails-with-unions/45703)

<div class="topic-metadata">

**Author:** [@Christian\_Rorvik](https://discourse.julialang.org/u/Christian_Rorvik)\
**Replies:** 0\
**Last updated:** [August 28, 2020, 6:33pm UTC](https://discourse.julialang.org/t/setfield-redundant-load-store-elision-fails-with-unions/45703 "2020-08-28T18:33:15Z")

</div>

Not really an issue with Setfield.jl, but this is where I’ve most encountered this. When updating immutable types (e.g., in arrays or references), we need to construct an entirely new object with the desired fields repl…

---

## [My Random Forest is very slow](https://discourse.julialang.org/t/my-random-forest-is-very-slow/45471)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 10\
**Last updated:** [August 28, 2020, 3:59pm UTC](https://discourse.julialang.org/t/my-random-forest-is-very-slow/45471 "2020-08-28T15:59:30Z")

</div>

I implemented Decision Tree and Random Forest classifiers/regressions based originally on Josh Gordon’s code in Python. The problem is that building the forest is very slow… It is said everywhere that one of the advant…

---

## [Computing pairwise Sørensen–Dice coefficient between many BitVectors](https://discourse.julialang.org/t/computing-pairwise-sorensen-dice-coefficient-between-many-bitvectors/45567)

<div class="topic-metadata">

**Author:** [@Brian\_Thorne](https://discourse.julialang.org/u/Brian_Thorne)\
**Replies:** 4\
**Last updated:** [August 27, 2020, 3:33pm UTC](https://discourse.julialang.org/t/computing-pairwise-sorensen-dice-coefficient-between-many-bitvectors/45567 "2020-08-27T15:33:58Z")

</div>

Hi all, I’m trying to match (or ideally beat) the performance of a Python/C library (anonlink) that computes the Sørensen–Dice coefficient but I’m struggling to match the performance - except when calling the same C code…

---

## [Type parameters by default?](https://discourse.julialang.org/t/type-parameters-by-default/45577)

<div class="topic-metadata">

**Author:** [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Replies:** 4\
**Last updated:** [August 26, 2020, 6:23pm UTC](https://discourse.julialang.org/t/type-parameters-by-default/45577 "2020-08-26T18:23:27Z")

</div>

Hi everyone, I’ve noticed a pattern in my Julia code and I wondered if it would make sense to have some compiler technology to automatically add type parameters for fields that have no explicit type. For example, consi…

---

## [Correct way of parallelizing on a HPC remote cluster machine](https://discourse.julialang.org/t/correct-way-of-parallelizing-on-a-hpc-remote-cluster-machine/45294)

<div class="topic-metadata">

**Author:** [@trathi](https://discourse.julialang.org/u/trathi)\
**Replies:** 8\
**Last updated:** [August 25, 2020, 3:08am UTC](https://discourse.julialang.org/t/correct-way-of-parallelizing-on-a-hpc-remote-cluster-machine/45294 "2020-08-25T03:08:09Z")

</div>

I want to know what is the correct way of running a julia script (which has some part that requires parallelization) on a HPC cluster remote machine. My PBS script looks like: #!/bin/bash -l #PBS -l walltime=01:00:00,n…

---

## [Profiling compilation/inference](https://discourse.julialang.org/t/profiling-compilation-inference/44496)

<div class="topic-metadata">

**Author:** [@mhauru](https://discourse.julialang.org/u/mhauru)\
**Replies:** 10\
**Last updated:** [August 24, 2020, 10:07pm UTC](https://discourse.julialang.org/t/profiling-compilation-inference/44496 "2020-08-24T22:07:29Z")

</div>

I have a package for which running the test script results in around 20 minutes of compilation. Presumably somewhere in my package there’s something that’s giving inference a very hard time. I’ve done some work trying to…

---

## [CUDA Speed drop](https://discourse.julialang.org/t/cuda-speed-drop/45412)

<div class="topic-metadata">

**Author:** [@Marcell\_Havlik](https://discourse.julialang.org/u/Marcell_Havlik)\
**Replies:** 4\
**Last updated:** [August 23, 2020, 8:28pm UTC](https://discourse.julialang.org/t/cuda-speed-drop/45412 "2020-08-23T20:28:22Z")

</div>

Hey, I found this interesting phenomenon, can anyone explain the situation? using BenchmarkTools BenchmarkTools.DEFAULT\_PARAMETERS.seconds = 2.50 using CUDA arit100(x::AbstractArray, y::AbstractArray) = for i=1:100 x …

---

## [Shared Sparse Arrays?](https://discourse.julialang.org/t/shared-sparse-arrays/45420)

<div class="topic-metadata">

**Author:** [@anon92994695](https://discourse.julialang.org/u/anon92994695)\
**Replies:** 0\
**Last updated:** [August 23, 2020, 4:09pm UTC](https://discourse.julialang.org/t/shared-sparse-arrays/45420 "2020-08-23T16:09:03Z")

</div>

Wasn’t sure if this should be in performance or first steps so feel free to relocate it. Are there any current/recommended implementations that handle altering sparse arrays in a parallel loop? I did some searches and d…

---

## [Performance Issues - Rayleigh Compressible](https://discourse.julialang.org/t/performance-issues-rayleigh-compressible/45397)

<div class="topic-metadata">

**Author:** [@axsano](https://discourse.julialang.org/u/axsano)\
**Replies:** 3\
**Last updated:** [August 23, 2020, 3:20pm UTC](https://discourse.julialang.org/t/performance-issues-rayleigh-compressible/45397 "2020-08-23T15:20:53Z")

</div>

I have this function called Rayleigh Compressible that is used to perform analysis of fluid flow stability, using LinearAlgebra function rayleighc(Ω, U, M, dU, D, D2) Λ = zeros(ComplexF64, 3\*size(D, 1), length(Ω));…

---

## [Why doesn't multithreading help here?](https://discourse.julialang.org/t/why-doesnt-multithreading-help-here/45286)

<div class="topic-metadata">

**Author:** [@cgeoga](https://discourse.julialang.org/u/cgeoga)\
**Replies:** 12\
**Last updated:** [August 22, 2020, 2:44am UTC](https://discourse.julialang.org/t/why-doesnt-multithreading-help-here/45286 "2020-08-22T02:44:13Z")

</div>

Hello— A very common computational issue for me is that I want to assemble kernel matrices with pretty expensive kernel functions. I have tried various ways to do this efficiently in parallel, but I can’t seem to write …

---

## [Processing Rows with multiple threads](https://discourse.julialang.org/t/processing-rows-with-multiple-threads/45253)

<div class="topic-metadata">

**Author:** [@danielw2904](https://discourse.julialang.org/u/danielw2904)\
**Replies:** 6\
**Last updated:** [August 20, 2020, 2:36pm UTC](https://discourse.julialang.org/t/processing-rows-with-multiple-threads/45253 "2020-08-20T14:36:09Z")

</div>

I find myself having to process a lot of data recently where a) the processing of two different rows is independent and b) processing each row is expensive. I find myself coding a version of the following every time: us…

---

## [Solving Boundary Value Problems with Shooting() and DifferentialEquations.jl](https://discourse.julialang.org/t/solving-boundary-value-problems-with-shooting-and-differentialequations-jl/45265)

<div class="topic-metadata">

**Author:** [@Gregers](https://discourse.julialang.org/u/Gregers)\
**Replies:** 0\
**Last updated:** [August 20, 2020, 11:37am UTC](https://discourse.julialang.org/t/solving-boundary-value-problems-with-shooting-and-differentialequations-jl/45265 "2020-08-20T11:37:20Z")

</div>

Hey, Im trying to solve a Boundary Value Problems with Shooting() and DifferentialEquations.jl. My problem is formulated as this: This problem is an IVP with known initial values and has also a known analytical solu…

---

## [Measuring and storing execution time in a variable](https://discourse.julialang.org/t/measuring-and-storing-execution-time-in-a-variable/45236)

<div class="topic-metadata">

**Author:** [@trathi](https://discourse.julialang.org/u/trathi)\
**Replies:** 2\
**Last updated:** [August 20, 2020, 4:50am UTC](https://discourse.julialang.org/t/measuring-and-storing-execution-time-in-a-variable/45236 "2020-08-20T04:50:03Z")

</div>

I want to measure the time from the moment the code enters pmap and exit it. Also, I want to store it in a variable. So is there a way I can store the output of @time or is there a julia package that does it more efficie…

---

## [Make entire function constant fold](https://discourse.julialang.org/t/make-entire-function-constant-fold/45229)

<div class="topic-metadata">

**Author:** [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Replies:** 4\
**Last updated:** [August 19, 2020, 10:03pm UTC](https://discourse.julialang.org/t/make-entire-function-constant-fold/45229 "2020-08-19T22:03:27Z")

</div>

Right now, in BetterExp, I have code that looks like MAX\_EXP(::Val{2}, ::Type{Float64}) = 1024.0 # log2 2^1023\*(2-2^-52) MIN\_EXP(::Val{2}, ::Type{Float64}) = -1075.0 # log2 2^-1075…

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

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