# Performance

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

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

**Page:** 43

---

## [Very slow startup in VScode](https://discourse.julialang.org/t/very-slow-startup-in-vscode/46996)

<div class="topic-metadata">

**Author:** [@MathMan](https://discourse.julialang.org/u/MathMan)\
**Replies:** 11\
**Last updated:** [May 25, 2023, 3:48pm UTC](https://discourse.julialang.org/t/very-slow-startup-in-vscode/46996 "2023-05-25T15:48:02Z")

</div>

I am new to Julia and I am using vscode with the Julia extension to run code. Unfortunately, Julia responds incredibly slow. Outputs into the terminal take 7-8 seconds every time I run this simple script. a = 2 b = 3 c …

---

## [Making a view of a combination of array indexes and scalars, creating an array to send to a function](https://discourse.julialang.org/t/making-a-view-of-a-combination-of-array-indexes-and-scalars-creating-an-array-to-send-to-a-function/99332)

<div class="topic-metadata">

**Author:** [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Replies:** 7\
**Last updated:** [May 25, 2023, 3:24pm UTC](https://discourse.julialang.org/t/making-a-view-of-a-combination-of-array-indexes-and-scalars-creating-an-array-to-send-to-a-function/99332 "2023-05-25T15:24:47Z")

</div>

I have a combination of scalar values, and values stored in vectors. Is there a good way to create a view of these and send to other functions, rather than allocating it all to a new array? I am performance de-bugging a…

---

## [The most efficient way to calculate the pairwise correlation between rows of a large Matrix{Float64}](https://discourse.julialang.org/t/the-most-efficient-way-to-calculate-the-pairwise-correlation-between-rows-of-a-large-matrix-float64/99313)

<div class="topic-metadata">

**Author:** [@Shayan](https://discourse.julialang.org/u/Shayan)\
**Replies:** 10\
**Last updated:** [May 25, 2023, 11:02am UTC](https://discourse.julialang.org/t/the-most-efficient-way-to-calculate-the-pairwise-correlation-between-rows-of-a-large-matrix-float64/99313 "2023-05-25T11:02:54Z")

</div>

I wonder the most efficient way to calculate the pairwise correlation between rows of a Matrix{Float64} with a large number of rows and columns. I know “large” is subjective. Suppose the large is (5000, 50000) (meaning 5…

---

## [KernelAbstractions on CPU. Why so slow?](https://discourse.julialang.org/t/kernelabstractions-on-cpu-why-so-slow/99272)

<div class="topic-metadata">

**Author:** [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Replies:** 8\
**Last updated:** [May 24, 2023, 9:40am UTC](https://discourse.julialang.org/t/kernelabstractions-on-cpu-why-so-slow/99272 "2023-05-24T09:40:00Z")

</div>

In the following code, launched with a single thread, KernelAbstractions’ function is almost twice slower than a simple broadcasting. Any ideas why? using BenchmarkTools using KernelAbstractions @kernel function mulcab…

---

## [Problem reading parquet file in Julia 1.9.0](https://discourse.julialang.org/t/problem-reading-parquet-file-in-julia-1-9-0/99314)

<div class="topic-metadata">

**Author:** [@MiquellaXMalenia](https://discourse.julialang.org/u/MiquellaXMalenia)\
**Replies:** 0\
**Last updated:** [May 24, 2023, 8:47am UTC](https://discourse.julialang.org/t/problem-reading-parquet-file-in-julia-1-9-0/99314 "2023-05-24T08:47:59Z")

</div>

Hello, Is anyone else experiencing problems reading parquet files in Julia 1.9.0? I was checking how my code performed when upgrading my Julia version from 1.8.4 to 1.9.0, and noticed the first run being extremely slow.…

---

## [Why is typeof not type inferable in this case?](https://discourse.julialang.org/t/why-is-typeof-not-type-inferable-in-this-case/99297)

<div class="topic-metadata">

**Author:** [@Larbino1](https://discourse.julialang.org/u/Larbino1)\
**Replies:** 2\
**Last updated:** [May 23, 2023, 7:13pm UTC](https://discourse.julialang.org/t/why-is-typeof-not-type-inferable-in-this-case/99297 "2023-05-23T19:13:43Z")

</div>

I’m messing around with ForwardDiff, trying to write some type stable code, and have found an instance where typeof does not properly infer the type. I’m a bit stuck as to what to try here! I think this particular funct…

---

## [Curious case of FFTW performance benchmarking](https://discourse.julialang.org/t/curious-case-of-fftw-performance-benchmarking/99215)

<div class="topic-metadata">

**Author:** [@vvbond](https://discourse.julialang.org/u/vvbond)\
**Replies:** 6\
**Last updated:** [May 22, 2023, 5:06pm UTC](https://discourse.julialang.org/t/curious-case-of-fftw-performance-benchmarking/99215 "2023-05-22T17:06:41Z")

</div>

While benchmarking FFTW’s rfft() transform, I’ve stumbled upon an interesting behaviour that I’d like to pick the collective brain about. The behaviour goes as follows: bm = @benchmark rfft(A,1) setup=(A=rand(Float32,…

---

## [Why is for loops so slow?](https://discourse.julialang.org/t/why-is-for-loops-so-slow/99199)

<div class="topic-metadata">

**Author:** [@perebalazs](https://discourse.julialang.org/u/perebalazs)\
**Replies:** 9\
**Last updated:** [May 22, 2023, 1:48pm UTC](https://discourse.julialang.org/t/why-is-for-loops-so-slow/99199 "2023-05-22T13:48:46Z")

</div>

I tried to write a simple code for solving a system of equations using Gauss elimination. The coefficient matrix is symmetric. This code runs more than 16 times slower than the built-in x=A\\b algorithm. I’ve tried almost…

---

## [Copy array elements by index](https://discourse.julialang.org/t/copy-array-elements-by-index/99127)

<div class="topic-metadata">

**Author:** [@Simon\_Exner](https://discourse.julialang.org/u/Simon_Exner)\
**Replies:** 5\
**Last updated:** [May 20, 2023, 3:03pm UTC](https://discourse.julialang.org/t/copy-array-elements-by-index/99127 "2023-05-20T15:03:13Z")

</div>

Hi, MWE: function y\_from\_x!(y, x) interesting\_indices = \[7, 2, 4\] for i in keys(interesting\_indices) y\[i\] = x\[interesting\_indices\[i\]\] end end a=collect(2:9) b=zeros(3) y\_from\_x!(b,a) then b is \[8.0…

---

## [Multithreading over multiple CPU](https://discourse.julialang.org/t/multithreading-over-multiple-cpu/99106)

<div class="topic-metadata">

**Author:** [@astro-kevin](https://discourse.julialang.org/u/astro-kevin)\
**Replies:** 8\
**Last updated:** [May 19, 2023, 3:57pm UTC](https://discourse.julialang.org/t/multithreading-over-multiple-cpu/99106 "2023-05-19T15:57:00Z")

</div>

Is the @threads macro available for multithreading over multiple CPU, or does it only work for setups with one CPU?

---

## [How can I avoid using global variables that will vary their values?](https://discourse.julialang.org/t/how-can-i-avoid-using-global-variables-that-will-vary-their-values/99085)

<div class="topic-metadata">

**Author:** [@AliceandBob](https://discourse.julialang.org/u/AliceandBob)\
**Replies:** 14\
**Last updated:** [May 19, 2023, 2:21pm UTC](https://discourse.julialang.org/t/how-can-i-avoid-using-global-variables-that-will-vary-their-values/99085 "2023-05-19T14:21:45Z")

</div>

I am using Julia to solve a quantum system with a self-consistence iteration algorithm. In my current code, many global variables and arrays are used which, from many documents, are harmful to the performance. However, I…

---

## [Collect for CuArray composite types](https://discourse.julialang.org/t/collect-for-cuarray-composite-types/99082)

<div class="topic-metadata">

**Author:** [@RainerHeintzmann](https://discourse.julialang.org/u/RainerHeintzmann)\
**Replies:** 2\
**Last updated:** [May 19, 2023, 11:46am UTC](https://discourse.julialang.org/t/collect-for-cuarray-composite-types/99082 "2023-05-19T11:46:44Z")

</div>

Using CUDA.jl single index access is discouraged for good reasons. However, if I want to implement a composite type (e.g. ShiftedArrays.jl) to work well with CuArray it needs to support collect. Yet the collect mechanis…

---

## [Performance of IdDict vs Dict](https://discourse.julialang.org/t/performance-of-iddict-vs-dict/57589)

<div class="topic-metadata">

**Author:** [@DrChainsaw](https://discourse.julialang.org/u/DrChainsaw)\
**Replies:** 13\
**Last updated:** [May 19, 2023, 5:18am UTC](https://discourse.julialang.org/t/performance-of-iddict-vs-dict/57589 "2023-05-19T05:18:53Z")

</div>

I have always lazily assumed that IdDict would always be faster if keying by identity is desired, but it seems like this is not the case: julia\> function benchmarkdict(DType, ks) d = DType(k =\> k for k in ks)…

---

## [A way for identifying the code portion being re-compiled?](https://discourse.julialang.org/t/a-way-for-identifying-the-code-portion-being-re-compiled/99077)

<div class="topic-metadata">

**Author:** [@Atiyah](https://discourse.julialang.org/u/Atiyah)\
**Replies:** 1\
**Last updated:** [May 18, 2023, 8:29pm UTC](https://discourse.julialang.org/t/a-way-for-identifying-the-code-portion-being-re-compiled/99077 "2023-05-18T20:29:57Z")

</div>

Motivation: I done some re-structuring to my code. Afterwords, re-executing with the @time macro within REPL indicates that part of the code is getting re-compiled, e.g. .... seconds (... , 50.63% compilation time: 100%…

---

## [Removing specific Type from Union](https://discourse.julialang.org/t/removing-specific-type-from-union/98943)

<div class="topic-metadata">

**Author:** [@RainerHeintzmann](https://discourse.julialang.org/u/RainerHeintzmann)\
**Replies:** 13\
**Last updated:** [May 18, 2023, 6:15pm UTC](https://discourse.julialang.org/t/removing-specific-type-from-union/98943 "2023-05-18T18:15:54Z")

</div>

I am trying to find a way to remove a specific type from a Union of types. In the code below, I would like to inherit from AbtractArray{T,N} if R is Nothing but otherwise inherit from the Union{T,R}: julia\> struct MyT{T…

---

## [Computationally efficient image filtering](https://discourse.julialang.org/t/computationally-efficient-image-filtering/98889)

<div class="topic-metadata">

**Author:** [@donkeysaddle](https://discourse.julialang.org/u/donkeysaddle)\
**Replies:** 3\
**Last updated:** [May 16, 2023, 12:49pm UTC](https://discourse.julialang.org/t/computationally-efficient-image-filtering/98889 "2023-05-16T12:49:16Z")

</div>

I would like to filter hundreds of thousands of small images (say 35x35), using 5x5 kernels (that do not factor). I only want the “good data,” meaning the 31x31 filtered image that comes from correlating the filter at ea…

---

## [Package precompile fail with Distributed](https://discourse.julialang.org/t/package-precompile-fail-with-distributed/98887)

<div class="topic-metadata">

**Author:** [@Gabriel\_Kreindler](https://discourse.julialang.org/u/Gabriel_Kreindler)\
**Replies:** 0\
**Last updated:** [May 15, 2023, 5:06pm UTC](https://discourse.julialang.org/t/package-precompile-fail-with-distributed/98887 "2023-05-15T17:06:49Z")

</div>

I get a persistent error with the following code: git\_julia\_proj\_path = "SOME\_PATH" using Distributed n\_procs = 2 rmprocs(workers()) addprocs(2) # local first using Pkg Pkg.activate(git\_julia\_proj\_path) Pkg.precomp…

---

## [Interpreting profiling flame charts: function runs dramatically faster after calling unrelated function](https://discourse.julialang.org/t/interpreting-profiling-flame-charts-function-runs-dramatically-faster-after-calling-unrelated-function/98836)

<div class="topic-metadata">

**Author:** [@PatrickMcFarlane](https://discourse.julialang.org/u/PatrickMcFarlane)\
**Replies:** 4\
**Last updated:** [May 15, 2023, 12:42pm UTC](https://discourse.julialang.org/t/interpreting-profiling-flame-charts-function-runs-dramatically-faster-after-calling-unrelated-function/98836 "2023-05-15T12:42:36Z")

</div>

I am working on a code base to solve a large dynamic economic model with heterogeneous agents. I coded up two different iterative algorithms for solving the model. These are wrapped in functions that I’ll call f1 and f…

---

## [Slower execution and more GC in command prompt than VSCode](https://discourse.julialang.org/t/slower-execution-and-more-gc-in-command-prompt-than-vscode/98739)

<div class="topic-metadata">

**Author:** [@PatrickMcFarlane](https://discourse.julialang.org/u/PatrickMcFarlane)\
**Replies:** 5\
**Last updated:** [May 14, 2023, 1:52pm UTC](https://discourse.julialang.org/t/slower-execution-and-more-gc-in-command-prompt-than-vscode/98739 "2023-05-14T13:52:56Z")

</div>

I have a large repository for solving a dynamic economic model with heterogeneous agents. The code takes about 400 seconds to run when running Julia from the command prompt, but only about 240 seconds when running in VS…

---

## [GC going nuts](https://discourse.julialang.org/t/gc-going-nuts/93447)

<div class="topic-metadata">

**Author:** [@mwlidar](https://discourse.julialang.org/u/mwlidar)\
**Replies:** 18\
**Last updated:** [May 13, 2023, 9:07am UTC](https://discourse.julialang.org/t/gc-going-nuts/93447 "2023-05-13T09:07:53Z")

</div>

I have workload where I process larger datasets (a few GB) iteratively. After adjusting some parameters the processing is repeated within the same REPL session. After two or three rounds all slows down and switching on G…

---

## [Why is NPZ so much faster than JLD in this case?](https://discourse.julialang.org/t/why-is-npz-so-much-faster-than-jld-in-this-case/98776)

<div class="topic-metadata">

**Author:** [@Michael\_Hess](https://discourse.julialang.org/u/Michael_Hess)\
**Replies:** 3\
**Last updated:** [May 13, 2023, 3:06am UTC](https://discourse.julialang.org/t/why-is-npz-so-much-faster-than-jld-in-this-case/98776 "2023-05-13T03:06:33Z")

</div>

Hello! First post here so sorry in advance :') I am doing numerical simulations on a large dataset for a wide range of parameters, and I was trying to save the results of this analysis using the JLD save function. The a…

---

## [Transducers vs Iterators](https://discourse.julialang.org/t/transducers-vs-iterators/98771)

<div class="topic-metadata">

**Author:** [@jekyllstein](https://discourse.julialang.org/u/jekyllstein)\
**Replies:** 0\
**Last updated:** [May 12, 2023, 11:03pm UTC](https://discourse.julialang.org/t/transducers-vs-iterators/98771 "2023-05-12T23:03:42Z")

</div>

I have an example of a simple processing pipeline where I noticed Transducers.jl was making a lot of allocations and behaving slowly compared to compositing iterators and generators together. I’m wondering if there’s a …

---

## [Very different performance in different computers due to garbage collection?](https://discourse.julialang.org/t/very-different-performance-in-different-computers-due-to-garbage-collection/87563)

<div class="topic-metadata">

**Author:** [@TheLeache](https://discourse.julialang.org/u/TheLeache)\
**Replies:** 28\
**Last updated:** [May 12, 2023, 12:54pm UTC](https://discourse.julialang.org/t/very-different-performance-in-different-computers-due-to-garbage-collection/87563 "2023-05-12T12:54:26Z")

</div>

So, I have a code which calculates a measure of “openness” or “sprawl” around points in a series of big rasters from the National Land Cover Dataset. I had used this code on my personal laptop (A 2020 ROG G14 with a Ryze…

---

## [Saving arguments or wrap function?](https://discourse.julialang.org/t/saving-arguments-or-wrap-function/98688)

<div class="topic-metadata">

**Author:** [@Veenty](https://discourse.julialang.org/u/Veenty)\
**Replies:** 4\
**Last updated:** [May 11, 2023, 5:42pm UTC](https://discourse.julialang.org/t/saving-arguments-or-wrap-function/98688 "2023-05-11T17:42:41Z")

</div>

Currently I have a structure where I save functions into something of the sort struct fooS x::Float64 A::Dict{Symbol, Function} fooS(x) = new(consfoo(x)...) end function consfoo(x) return x, Dict{Sym…

---

## [Performance penalty of \`\>(1)\` vs \`x -\> x \>1\`?](https://discourse.julialang.org/t/performance-penalty-of-1-vs-x-x-1/98547)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 36\
**Last updated:** [May 11, 2023, 12:47am UTC](https://discourse.julialang.org/t/performance-penalty-of-1-vs-x-x-1/98547 "2023-05-11T00:47:30Z")

</div>

Why is there this performance penalty in using \>(1) vs x -\> x \> 1 in these examples? (happens in 1.8.5 and 1.9-rc3): julia\> using BenchmarkTools julia\> mat = randn(1000, 1000); julia\> @btime sum(\>(1), $mat) 557.740 …

---

## [CSV.Row very slow for reading files line by line](https://discourse.julialang.org/t/csv-row-very-slow-for-reading-files-line-by-line/98563)

<div class="topic-metadata">

**Author:** [@amael](https://discourse.julialang.org/u/amael)\
**Replies:** 0\
**Last updated:** [May 9, 2023, 4:39pm UTC](https://discourse.julialang.org/t/csv-row-very-slow-for-reading-files-line-by-line/98563 "2023-05-09T16:39:20Z")

</div>

Hi @stevengj @quinnj @CodeGodz, I’m trying to use CSV.Row as well as ViewReader to read files line by line as efficiently as possible (following the topic ViewReader discussion). Ultimately the goal is to process on the…

---

## [Where do these allocations come from?](https://discourse.julialang.org/t/where-do-these-allocations-come-from/98549)

<div class="topic-metadata">

**Author:** [@matthias314](https://discourse.julialang.org/u/matthias314)\
**Replies:** 4\
**Last updated:** [May 9, 2023, 4:29pm UTC](https://discourse.julialang.org/t/where-do-these-allocations-come-from/98549 "2023-05-09T16:29:13Z")

</div>

I want to write a function g(w, x...) with the following properties: If none of the arguments following w is a vector, then the tuple x is appended to w (a vector). For each of the other vector arguments, the function sh…

---

## [Sum with generic implementation is slower than double sum](https://discourse.julialang.org/t/sum-with-generic-implementation-is-slower-than-double-sum/98512)

<div class="topic-metadata">

**Author:** [@PaterPen](https://discourse.julialang.org/u/PaterPen)\
**Replies:** 2\
**Last updated:** [May 9, 2023, 12:28pm UTC](https://discourse.julialang.org/t/sum-with-generic-implementation-is-slower-than-double-sum/98512 "2023-05-09T12:28:09Z")

</div>

Why is the latter implementation slower? These results surprise me especially given the fact that we have less allocations. using BenchmarkTools mat = randn(1000, 1000) @btime sum(sum(x -\> x \> 1, mat, dims=1)) # 135.16…

---

## [HDF5 utilising only a fraction of available system resources](https://discourse.julialang.org/t/hdf5-utilising-only-a-fraction-of-available-system-resources/98481)

<div class="topic-metadata">

**Author:** [@silkskier](https://discourse.julialang.org/u/silkskier)\
**Replies:** 5\
**Last updated:** [May 8, 2023, 10:41pm UTC](https://discourse.julialang.org/t/hdf5-utilising-only-a-fraction-of-available-system-resources/98481 "2023-05-08T22:41:37Z")

</div>

I’ve recently written a simple script converting the OCVS (OGLE Collection of Variable Stars) database (which is basically a single text file containing a list of attributes of every star in the collection) and a large a…

---

## [Avoiding computing inverse of matrix, don't think it's possible in my case](https://discourse.julialang.org/t/avoiding-computing-inverse-of-matrix-dont-think-its-possible-in-my-case/98478)

<div class="topic-metadata">

**Author:** [@p\_f](https://discourse.julialang.org/u/p_f)\
**Replies:** 4\
**Last updated:** [May 8, 2023, 4:03pm UTC](https://discourse.julialang.org/t/avoiding-computing-inverse-of-matrix-dont-think-its-possible-in-my-case/98478 "2023-05-08T16:03:53Z")

</div>

I have a system of (6+3N) equations given by: A\*inv(B)\*C\*dX = K which I then solve using dX = (A\*inv(B)\*C) \\ K A\*inv(B)\*C form a square (6+3N) matrix but the submatrices have sizes: A: (6+3N) x (6N) B: (6N) x (6N) …

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

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