# Performance

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

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

**Page:** 84

---

## [Environment variable for BLAS.set\_num\_threads default?](https://discourse.julialang.org/t/environment-variable-for-blas-set-num-threads-default/67594)

<div class="topic-metadata">

**Author:** [@goerz](https://discourse.julialang.org/u/goerz)\
**Replies:** 1\
**Last updated:** [September 2, 2021, 6:54pm UTC](https://discourse.julialang.org/t/environment-variable-for-blas-set-num-threads-default/67594 "2021-09-02T18:54:36Z")

</div>

Is there an environment variable that I can set in my .bashrc so I don’t have to manually prevent multiple BLAS threads (BLAS.set\_num\_threads(1)) in every program? I never, ever want BLAS to run in multithreaded mode. I…

---

## [Passing struct vs struct fields as function arguments](https://discourse.julialang.org/t/passing-struct-vs-struct-fields-as-function-arguments/67584)

<div class="topic-metadata">

**Author:** [@fipelle](https://discourse.julialang.org/u/fipelle)\
**Replies:** 5\
**Last updated:** [September 2, 2021, 4:01pm UTC](https://discourse.julialang.org/t/passing-struct-vs-struct-fields-as-function-arguments/67584 "2021-09-02T16:01:36Z")

</div>

Hi, I have noticed that passing struct fields as function arguments generally results in better performance compared to passing the struct directly. For instance, using BenchmarkTools; using Random; struct MyStruct …

---

## [Avoiding memory allocation with function passed as argument](https://discourse.julialang.org/t/avoiding-memory-allocation-with-function-passed-as-argument/67494)

<div class="topic-metadata">

**Author:** [@Joris\_Pinkse](https://discourse.julialang.org/u/Joris_Pinkse)\
**Replies:** 14\
**Last updated:** [September 2, 2021, 3:19pm UTC](https://discourse.julialang.org/t/avoiding-memory-allocation-with-function-passed-as-argument/67494 "2021-09-02T15:19:56Z")

</div>

Consider the code at the bottom. The actual case is more complex, so something that does not depend on the definition of the function A would be appreciated. This gives the time and allocation numbers below. Presumabl…

---

## [Speed up matrix multiplication with permuted vector](https://discourse.julialang.org/t/speed-up-matrix-multiplication-with-permuted-vector/67491)

<div class="topic-metadata">

**Author:** [@Thomas](https://discourse.julialang.org/u/Thomas)\
**Replies:** 5\
**Last updated:** [September 1, 2021, 11:24am UTC](https://discourse.julialang.org/t/speed-up-matrix-multiplication-with-permuted-vector/67491 "2021-09-01T11:24:51Z")

</div>

I have a very large sparse matrix of the order (1768, 39816100) that goes into the following (part of Computing sparse orthogonal projections - #2 by stevengj): QR = qr(A::SparseMatrixCSC) # A = sparse matrix of size (1…

---

## [Running time](https://discourse.julialang.org/t/running-time/67462)

<div class="topic-metadata">

**Author:** [@tortijazz](https://discourse.julialang.org/u/tortijazz)\
**Replies:** 5\
**Last updated:** [September 1, 2021, 6:55am UTC](https://discourse.julialang.org/t/running-time/67462 "2021-09-01T06:55:23Z")

</div>

Hi everybody, I was making simulations with Flux.jl, DiffEqFlux.jl, Optim.jl, DiffEqSensitivity.jl and OrdinaryDiffEq.jl in Julia-1.5.2 and I saw that there was a new stable release (1.6.2 version), so I did upgrade Jul…

---

## [Multi-threading and Dierckx.jl & Interpolations.jl and gradients](https://discourse.julialang.org/t/multi-threading-and-dierckx-jl-interpolations-jl-and-gradients/67452)

<div class="topic-metadata">

**Author:** [@gianmariomanca](https://discourse.julialang.org/u/gianmariomanca)\
**Replies:** 6\
**Last updated:** [September 1, 2021, 6:15am UTC](https://discourse.julialang.org/t/multi-threading-and-dierckx-jl-interpolations-jl-and-gradients/67452 "2021-09-01T06:15:55Z")

</div>

I noticed that if I use https://github.com/kbarbary/Dierckx.jl (1D, k=3 and derivatives) in a loop with the Threads.@threads macro I get partially corrupted results. If I remove the Threads.@threads macro results look f…

---

## [Behavior of Julia package manager, deleting folders in registeries/General very frequently, unacceptable](https://discourse.julialang.org/t/behavior-of-julia-package-manager-deleting-folders-in-registeries-general-very-frequently-unacceptable/67468)

<div class="topic-metadata">

**Author:** [@Lian\_Yunlong](https://discourse.julialang.org/u/Lian_Yunlong)\
**Replies:** 6\
**Last updated:** [September 1, 2021, 3:19am UTC](https://discourse.julialang.org/t/behavior-of-julia-package-manager-deleting-folders-in-registeries-general-very-frequently-unacceptable/67468 "2021-09-01T03:19:58Z")

</div>

Dear Julia developers and experts, I am a scientific researcher and a regular Julia user. I often run Julia programs on HPC. During the development of my own package, I need to add other packages from time to time. Ever…

---

## [Product of two symmetric matrices: LoopVectorization.jl vs LinearAlgebra](https://discourse.julialang.org/t/product-of-two-symmetric-matrices-loopvectorization-jl-vs-linearalgebra/67396)

<div class="topic-metadata">

**Author:** [@fipelle](https://discourse.julialang.org/u/fipelle)\
**Replies:** 9\
**Last updated:** [August 31, 2021, 8:11pm UTC](https://discourse.julialang.org/t/product-of-two-symmetric-matrices-loopvectorization-jl-vs-linearalgebra/67396 "2021-08-31T20:11:59Z")

</div>

Hi, I am playing around with LoopVectorization.jl. In doing so, I have noticed that it seems to be about 1.5x faster than LinearAlgebra in computing the product between two symmetric matrices (while being about as fast …

---

## [Taking advantage of rowwise-constant sparse matrix](https://discourse.julialang.org/t/taking-advantage-of-rowwise-constant-sparse-matrix/67366)

<div class="topic-metadata">

**Author:** [@lrnv](https://discourse.julialang.org/u/lrnv)\
**Replies:** 7\
**Last updated:** [August 30, 2021, 4:48pm UTC](https://discourse.julialang.org/t/taking-advantage-of-rowwise-constant-sparse-matrix/67366 "2021-08-30T16:48:58Z")

</div>

Hi, This is a follow-up of this previous thread where we discussed with @Sukera the possibility to improve matrix-vector product in the case where the matrix is sparse, but also has only one possible non-zero value per …

---

## [How to improve runtime with measurements.jl?](https://discourse.julialang.org/t/how-to-improve-runtime-with-measurements-jl/67343)

<div class="topic-metadata">

**Author:** [@Cevheriferd](https://discourse.julialang.org/u/Cevheriferd)\
**Replies:** 11\
**Last updated:** [August 30, 2021, 4:35pm UTC](https://discourse.julialang.org/t/how-to-improve-runtime-with-measurements-jl/67343 "2021-08-30T16:35:19Z")

</div>

Dear all, I am using the measurements.jl package to calculate the error in my dataset. I have an array with voltage values which all have their own uncertainty. But when I want to calculate the mean of the array, it tak…

---

## [Unexpected allocations when accessing IdDict](https://discourse.julialang.org/t/unexpected-allocations-when-accessing-iddict/65996)

<div class="topic-metadata">

**Author:** [@StefanMathis](https://discourse.julialang.org/u/StefanMathis)\
**Replies:** 9\
**Last updated:** [August 30, 2021, 4:28pm UTC](https://discourse.julialang.org/t/unexpected-allocations-when-accessing-iddict/65996 "2021-08-30T16:28:18Z")

</div>

Hello, I found that accessing an IdDict can lead to memory allocations, while accessing a Dict does not. I first encountered this behaviour in combination with the Memoization.jl package, therefore the original thread c…

---

## [How to modify marker style in Pyplot?](https://discourse.julialang.org/t/how-to-modify-marker-style-in-pyplot/67293)

<div class="topic-metadata">

**Author:** [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)\
**Replies:** 1\
**Last updated:** [August 29, 2021, 4:48pm UTC](https://discourse.julialang.org/t/how-to-modify-marker-style-in-pyplot/67293 "2021-08-29T16:48:45Z")

</div>

Hello, I am using PyPlot to draw a plot. What are the parameters for the fill color, line, and size fo the markers? I am using myPlot = plot(col\_x, col\_y, linestyle = "none", marker = "o", color = "black") but if I u…

---

## [Solving difference equation: Part 2](https://discourse.julialang.org/t/solving-difference-equation-part-2/67057)

<div class="topic-metadata">

**Author:** [@MathGuy](https://discourse.julialang.org/u/MathGuy)\
**Replies:** 4\
**Last updated:** [August 29, 2021, 8:43am UTC](https://discourse.julialang.org/t/solving-difference-equation-part-2/67057 "2021-08-29T08:43:02Z")

</div>

In my previous post I was trying to get to reach a conclusion whether I can get more speed in solving a system of difference equation (basically a discrete dynamical system) through a hand-written code. I got useful sug…

---

## [Allocations of @threads](https://discourse.julialang.org/t/allocations-of-threads/67047)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 10\
**Last updated:** [August 28, 2021, 10:27pm UTC](https://discourse.julialang.org/t/allocations-of-threads/67047 "2021-08-28T22:27:10Z")

</div>

In simulations, one usually has a external loop which runs over time steps, and inner loops that compute, for example, interactions between particles. These last loops are parallelized. Therefore, one has something as: j…

---

## [Multithreading balancing](https://discourse.julialang.org/t/multithreading-balancing/67220)

<div class="topic-metadata">

**Author:** [@Joris\_Pinkse](https://discourse.julialang.org/u/Joris_Pinkse)\
**Replies:** 6\
**Last updated:** [August 28, 2021, 10:13pm UTC](https://discourse.julialang.org/t/multithreading-balancing/67220 "2021-08-28T22:13:52Z")

</div>

Consider the following scenario (in local scope): function .... @threads for i ∈ 1:128 y\[i\] = dosomethingexpensive( x\[i\] ) end end Say I’m running this on a machine with 32 physical cores. Then often,…

---

## [Solve ODE with many different initial conditions](https://discourse.julialang.org/t/solve-ode-with-many-different-initial-conditions/66384)

<div class="topic-metadata">

**Author:** [@hongchengni](https://discourse.julialang.org/u/hongchengni)\
**Replies:** 4\
**Last updated:** [August 28, 2021, 3:41pm UTC](https://discourse.julialang.org/t/solve-ode-with-many-different-initial-conditions/66384 "2021-08-28T15:41:20Z")

</div>

Hello friends, I have an ODE to solve with many different initial conditions varying in a nested loop. In my old code, I simply define the ODEProblem within the inner loop, which is simplest but slow. I suppose there ar…

---

## [Are exceptions in Julia "Zero Cost"](https://discourse.julialang.org/t/are-exceptions-in-julia-zero-cost/38405)

<div class="topic-metadata">

**Author:** [@risingganymede](https://discourse.julialang.org/u/risingganymede)\
**Replies:** 12\
**Last updated:** [August 28, 2021, 1:02am UTC](https://discourse.julialang.org/t/are-exceptions-in-julia-zero-cost/38405 "2021-08-28T01:02:39Z")

</div>

In C++, there is no performance penalty for writing exception handlers provided that exceptions aren’t actually thrown (which should be “rare”). I was wondering if handling exceptions in Julia adds any overhead in the no…

---

## [Speed up Julia code for simple Monte Carlo Pi estimation (compared to Numba)](https://discourse.julialang.org/t/speed-up-julia-code-for-simple-monte-carlo-pi-estimation-compared-to-numba/59808)

<div class="topic-metadata">

**Author:** [@smpurkis](https://discourse.julialang.org/u/smpurkis)\
**Replies:** 20\
**Last updated:** [August 22, 2021, 4:45am UTC](https://discourse.julialang.org/t/speed-up-julia-code-for-simple-monte-carlo-pi-estimation-compared-to-numba/59808 "2021-08-22T04:45:45Z")

</div>

Hello, I’m benchmarking Julia against some other langauges, mainly against Cython, Numba etc (in this case mainly Numba). I’m running a simple Monte Carlo estimate of Pi. Trying to recreate Python+Numba vs. Julia, and ex…

---

## [Performance drawback with subtyping](https://discourse.julialang.org/t/performance-drawback-with-subtyping/51939)

<div class="topic-metadata">

**Author:** [@Ronneesley](https://discourse.julialang.org/u/Ronneesley)\
**Replies:** 34\
**Last updated:** [August 26, 2021, 2:37pm UTC](https://discourse.julialang.org/t/performance-drawback-with-subtyping/51939 "2021-08-26T14:37:16Z")

</div>

Hello, I’ve a problem with subtype, see the code: abstract type LineAbstract end mutable struct LineA \<: LineAbstract color::String end mutable struct LineB \<: LineAbstract length::Int end mutable struct…

---

## [Passing Function As Object VS Creating New Function](https://discourse.julialang.org/t/passing-function-as-object-vs-creating-new-function/66933)

<div class="topic-metadata">

**Author:** [@cmdenis](https://discourse.julialang.org/u/cmdenis)\
**Replies:** 5\
**Last updated:** [August 26, 2021, 1:56pm UTC](https://discourse.julialang.org/t/passing-function-as-object-vs-creating-new-function/66933 "2021-08-26T13:56:48Z")

</div>

Hello! So, I’ve stumbled upon a performance difference between two situations, and I don’t understand the reason behind this difference. The difference in computation time occurs between 1) passing a function to a varia…

---

## [Load testing of REST APIs](https://discourse.julialang.org/t/load-testing-of-rest-apis/66906)

<div class="topic-metadata">

**Author:** [@Jan\_Dolinsky](https://discourse.julialang.org/u/Jan_Dolinsky)\
**Replies:** 3\
**Last updated:** [August 26, 2021, 1:39pm UTC](https://discourse.julialang.org/t/load-testing-of-rest-apis/66906 "2021-08-26T13:39:37Z")

</div>

Hello, I would like to ask whether there is some package / effort providing load testing functionalities for REST APIs. We currently consider using jMeter but I wanted to check whether there is something I might not be …

---

## [Reduce number of allocations](https://discourse.julialang.org/t/reduce-number-of-allocations/66990)

<div class="topic-metadata">

**Author:** [@daviddoij](https://discourse.julialang.org/u/daviddoij)\
**Replies:** 11\
**Last updated:** [August 25, 2021, 10:03pm UTC](https://discourse.julialang.org/t/reduce-number-of-allocations/66990 "2021-08-25T22:03:26Z")

</div>

I would like to reduce the number of allocations in this particular problem (for context, that’s problem 30 of project euler). I got it right, but I think there are too many allocations. function power\_digit\_sum(pow, n)…

---

## [Solving difference equation](https://discourse.julialang.org/t/solving-difference-equation/66977)

<div class="topic-metadata">

**Author:** [@MathGuy](https://discourse.julialang.org/u/MathGuy)\
**Replies:** 8\
**Last updated:** [August 25, 2021, 7:58pm UTC](https://discourse.julialang.org/t/solving-difference-equation/66977 "2021-08-25T19:58:26Z")

</div>

This is my code to solve a system of difference equations: function trajectoryDiscrete(sys\_eq, init\_cond, NIter, par1, par2) neq = length(init\_cond) traj= zeros(Float64,NIter+1,neq) traj\[1,:\] = init\_cond …

---

## [How to make EvoTrees.jl more performant?](https://discourse.julialang.org/t/how-to-make-evotrees-jl-more-performant/66407)

<div class="topic-metadata">

**Author:** [@YummyPampers2](https://discourse.julialang.org/u/YummyPampers2)\
**Replies:** 25\
**Last updated:** [August 25, 2021, 3:53pm UTC](https://discourse.julialang.org/t/how-to-make-evotrees-jl-more-performant/66407 "2021-08-25T15:53:35Z")

</div>

Hello Folks: Code Snippets obtained from Alan Turing Institute @ablaom Using Pluto.jl, Windows, Julia v 1.6.x I am using EvoTrees.jl Evaluation First I am loading and Instantiating the Gradient Tree Boosting Model B…

---

## [PaddedViews very slow](https://discourse.julialang.org/t/paddedviews-very-slow/66979)

<div class="topic-metadata">

**Author:** [@weymouth](https://discourse.julialang.org/u/weymouth)\
**Replies:** 7\
**Last updated:** [August 25, 2021, 3:07pm UTC](https://discourse.julialang.org/t/paddedviews-very-slow/66979 "2021-08-25T15:07:05Z")

</div>

I’m sure to be doing something silly, but I can’t seem to get PaddedViews.jl up to speed. Consider the LoopVectorization.jl image filtering example using LoopVectorization, OffsetArrays, Images, PaddedViews kern = Image…

---

## [A demo is 1.5x faster in Flux than tensorflow, both use cpu; while 3.0x slower during using CUDA](https://discourse.julialang.org/t/a-demo-is-1-5x-faster-in-flux-than-tensorflow-both-use-cpu-while-3-0x-slower-during-using-cuda/66703)

<div class="topic-metadata">

**Author:** [@HANHAOHAN](https://discourse.julialang.org/u/HANHAOHAN)\
**Replies:** 5\
**Last updated:** [August 25, 2021, 2:30am UTC](https://discourse.julialang.org/t/a-demo-is-1-5x-faster-in-flux-than-tensorflow-both-use-cpu-while-3-0x-slower-during-using-cuda/66703 "2021-08-25T02:30:41Z")

</div>

using Flux using CUDA data = randn(Float32, 2, 100000) |\> gpu y = reshape(sin.(data\[1,:\] .\* data\[2,:\]), (1, size(data)\[2\])) |\> gpu model = Chain( Dense(2, 10, relu), Dense(10, 10, relu), Dense(10, 10, relu), Dense(10, 10…

---

## [Transducers and reduct-like reduction](https://discourse.julialang.org/t/transducers-and-reduct-like-reduction/66070)

<div class="topic-metadata">

**Author:** [@Tomas\_Pevny](https://discourse.julialang.org/u/Tomas_Pevny)\
**Replies:** 3\
**Last updated:** [August 24, 2021, 6:26pm UTC](https://discourse.julialang.org/t/transducers-and-reduct-like-reduction/66070 "2021-08-24T18:26:08Z")

</div>

Dear All, this question is mainly for @tkf . I would like to ask, if some there is a reducer in Transducers.jl that would implement reduce-like paralelism. Using your example, I am looking for this: (a + b) + (c + d) …

---

## [Fast large binary heap for SNIC super-pixel](https://discourse.julialang.org/t/fast-large-binary-heap-for-snic-super-pixel/66878)

<div class="topic-metadata">

**Author:** [@Geoffrey](https://discourse.julialang.org/u/Geoffrey)\
**Replies:** 2\
**Last updated:** [August 24, 2021, 11:45am UTC](https://discourse.julialang.org/t/fast-large-binary-heap-for-snic-super-pixel/66878 "2021-08-24T11:45:11Z")

</div>

Hello there, I’m looking for help in order to optimize an implementation of the SNIC algorithm (Achanta et al 2017) for pre-segmenting image in super-pixels/voxels. The algorithm use a binary heap to get quick access to…

---

## [Using closures for performance gain when handling datasets and making repeated function calls](https://discourse.julialang.org/t/using-closures-for-performance-gain-when-handling-datasets-and-making-repeated-function-calls/66809)

<div class="topic-metadata">

**Author:** [@rubaiyat](https://discourse.julialang.org/u/rubaiyat)\
**Replies:** 3\
**Last updated:** [August 24, 2021, 9:47am UTC](https://discourse.julialang.org/t/using-closures-for-performance-gain-when-handling-datasets-and-making-repeated-function-calls/66809 "2021-08-24T09:47:54Z")

</div>

Hello everyone, I’m in a situation where I’m estimating parameters of a model using a dataset. This requires optimization, and my question is about how I can leverage closures to speed up the process. I’d be curious to…

---

## [How to use threads in a reduction with LoopVectorization?](https://discourse.julialang.org/t/how-to-use-threads-in-a-reduction-with-loopvectorization/66836)

<div class="topic-metadata">

**Author:** [@Chiil](https://discourse.julialang.org/u/Chiil)\
**Replies:** 3\
**Last updated:** [August 23, 2021, 12:55pm UTC](https://discourse.julialang.org/t/how-to-use-threads-in-a-reduction-with-loopvectorization/66836 "2021-08-23T12:55:39Z")

</div>

I have the following function. How do I make this parallel with LoopVectorization? In C++ I would add the reduction clause and the associated variable to my OpenMP #pragma, but in Julia I do not know what is the best per…

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

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