# Performance

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

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

**Page:** 80

---

## [Distributing loops across threads manually (something like OpenMP)](https://discourse.julialang.org/t/distributing-loops-across-threads-manually-something-like-openmp/70701)

<div class="topic-metadata">

**Author:** [@tgautam03](https://discourse.julialang.org/u/tgautam03)\
**Replies:** 14\
**Last updated:** [November 2, 2021, 4:09pm UTC](https://discourse.julialang.org/t/distributing-loops-across-threads-manually-something-like-openmp/70701 "2021-11-02T16:09:00Z")

</div>

Hi, I’m quite familiar with the workings of OpenMP and have understood the parallel programming concepts using Fork Join Model. I’m just starting out with julia and was hoping to understand multithreading in julia better…

---

## [How can I parallelize my Neural Network training](https://discourse.julialang.org/t/how-can-i-parallelize-my-neural-network-training/70771)

<div class="topic-metadata">

**Author:** [@oijoij](https://discourse.julialang.org/u/oijoij)\
**Replies:** 0\
**Last updated:** [November 2, 2021, 1:05am UTC](https://discourse.julialang.org/t/how-can-i-parallelize-my-neural-network-training/70771 "2021-11-02T01:05:05Z")

</div>

Hello, new here. Sorry if I make any mistakes. I am currently trying to train a Neural Network to approximate a function. However it is not fast enough, and I think the most obvious gains can come from parallelizing. S…

---

## [For loop optimization](https://discourse.julialang.org/t/for-loop-optimization/70700)

<div class="topic-metadata">

**Author:** [@claudio20497](https://discourse.julialang.org/u/claudio20497)\
**Replies:** 3\
**Last updated:** [October 31, 2021, 7:39pm UTC](https://discourse.julialang.org/t/for-loop-optimization/70700 "2021-10-31T19:39:39Z")

</div>

Hello, I’m not sure how to optimize the following for loop. array\_1 and array\_2 are two Vector{Vector{Int64}}s, and I’m interested in evaluating which combinations (of 2 elements) of their vector components has an elem…

---

## [Efficient trace of product of matrices](https://discourse.julialang.org/t/efficient-trace-of-product-of-matrices/13313)

<div class="topic-metadata">

**Author:** [@garrison](https://discourse.julialang.org/u/garrison)\
**Replies:** 15\
**Last updated:** [October 30, 2021, 5:00pm UTC](https://discourse.julialang.org/t/efficient-trace-of-product-of-matrices/13313 "2021-10-30T17:00:42Z")

</div>

In quantum statistical mechanics, it is common to compute the trace of the product of two (or more) matrices. The obvious way of expressing this in julia is tr(A \* B); however, this results in the computation of all ele…

---

## [Heroku – Memory quota vastly exceeded](https://discourse.julialang.org/t/heroku-memory-quota-vastly-exceeded/70562)

<div class="topic-metadata">

**Author:** [@cepel](https://discourse.julialang.org/u/cepel)\
**Replies:** 10\
**Last updated:** [October 29, 2021, 9:06pm UTC](https://discourse.julialang.org/t/heroku-memory-quota-vastly-exceeded/70562 "2021-10-29T21:06:17Z")

</div>

Hey there, I developed a Julia application using Dash and ObjectDetector, and deployed on Heroku. But I am having “R15 - Memory quota vastly exceeded” error. I checked the memory usage on my local computer and the ap…

---

## [OutOfMemory() when loading a database of images](https://discourse.julialang.org/t/outofmemory-when-loading-a-database-of-images/70523)

<div class="topic-metadata">

**Author:** [@Ivan](https://discourse.julialang.org/u/Ivan)\
**Replies:** 9\
**Last updated:** [October 28, 2021, 2:40pm UTC](https://discourse.julialang.org/t/outofmemory-when-loading-a-database-of-images/70523 "2021-10-28T14:40:54Z")

</div>

I am trying to work with a database of images (2767 images in total), but I run into an OutOfMemory() error when loading the data. This is how I am doing it: path = string(pwd(), "/Data") list = readdir(path, join = tru…

---

## [How does function inlining reflect on the profiling output?](https://discourse.julialang.org/t/how-does-function-inlining-reflect-on-the-profiling-output/70471)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 1\
**Last updated:** [October 28, 2021, 9:46am UTC](https://discourse.julialang.org/t/how-does-function-inlining-reflect-on-the-profiling-output/70471 "2021-10-28T09:46:23Z")

</div>

I have a Julia program. It includes a big function which calls another, small, function in two places. Profiling the execution and displaying a flame graph with ProfileView shows that most of the time is spent in the sm…

---

## [Dynamic dispatch with Union{Nothing, ...}](https://discourse.julialang.org/t/dynamic-dispatch-with-union-nothing/70174)

<div class="topic-metadata">

**Author:** [@goerch](https://discourse.julialang.org/u/goerch)\
**Replies:** 8\
**Last updated:** [October 28, 2021, 4:43am UTC](https://discourse.julialang.org/t/dynamic-dispatch-with-union-nothing/70174 "2021-10-28T04:43:19Z")

</div>

When benchmarking a data structure we encountered an interesting phenomenon. The data structure is mutable struct Node{K,D} parent::Union{Node{K,D},Nothing} left::Union{Node{K,D},Nothing} right::Union{Node{K…

---

## [Controls the number of LBFGS iterations with optim.jl](https://discourse.julialang.org/t/controls-the-number-of-lbfgs-iterations-with-optim-jl/70455)

<div class="topic-metadata">

**Author:** [@F-YF](https://discourse.julialang.org/u/F-YF)\
**Replies:** 5\
**Last updated:** [October 28, 2021, 2:51am UTC](https://discourse.julialang.org/t/controls-the-number-of-lbfgs-iterations-with-optim-jl/70455 "2021-10-28T02:51:38Z")

</div>

I want to use the LBFGS() method in optim package to optimize. Usually LBFGS will do many linearSearch, but I only want it to do one iteration. How to do that? LBFGS

---

## [Easy way to run benchmarks quickly](https://discourse.julialang.org/t/easy-way-to-run-benchmarks-quickly/70406)

<div class="topic-metadata">

**Author:** [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Replies:** 2\
**Last updated:** [October 27, 2021, 11:53pm UTC](https://discourse.julialang.org/t/easy-way-to-run-benchmarks-quickly/70406 "2021-10-27T23:53:03Z")

</div>

Why does @benchmark take so long even when evals is manually specified? using BenchmarkTools count = 0 @elapsed @benchmark (global count += 1; sleep(.05)) evals=1 samples=10 # 1.68 @elapsed for i in 1:count; sleep(.05)…

---

## [Why the performance varies greatly after @view?](https://discourse.julialang.org/t/why-the-performance-varies-greatly-after-view/70495)

<div class="topic-metadata">

**Author:** [@zhangjin](https://discourse.julialang.org/u/zhangjin)\
**Replies:** 2\
**Last updated:** [October 27, 2021, 5:23pm UTC](https://discourse.julialang.org/t/why-the-performance-varies-greatly-after-view/70495 "2021-10-27T17:23:50Z")

</div>

I focus on the following code’s efficient, and I use the TimerOutputs to measure the performance. using TimerOutputs const to = TimerOutput() abstract type AbstractSN end struct spi \<: AbstractSN M::Int8 …

---

## [Errors associated with "using GMT"](https://discourse.julialang.org/t/errors-associated-with-using-gmt/70393)

<div class="topic-metadata">

**Author:** [@leon](https://discourse.julialang.org/u/leon)\
**Replies:** 28\
**Last updated:** [October 27, 2021, 3:50am UTC](https://discourse.julialang.org/t/errors-associated-with-using-gmt/70393 "2021-10-27T03:50:15Z")

</div>

I just installed the mapping package to my Julia and I can verify that my GMT package was installed: Pkg.status("GMT") Status \`~/.julia/environments/v1.6/Project.toml\` \[5752ebe1\] GMT v0.37.1 However, a simple “…

---

## [How to improve performance in nested loops](https://discourse.julialang.org/t/how-to-improve-performance-in-nested-loops/70407)

<div class="topic-metadata">

**Author:** [@claudio20497](https://discourse.julialang.org/u/claudio20497)\
**Replies:** 3\
**Last updated:** [October 26, 2021, 10:34pm UTC](https://discourse.julialang.org/t/how-to-improve-performance-in-nested-loops/70407 "2021-10-26T22:34:50Z")

</div>

Hello, I’m writing a function whose performance suffers because of a nested for-loop. Below is a simplified version of that function. The function f() takes no arguments, and instantiates vecvec a vector of vectors of I…

---

## [LinearAlgebra.inv matrix inversion slower than MATLAB?](https://discourse.julialang.org/t/linearalgebra-inv-matrix-inversion-slower-than-matlab/70066)

<div class="topic-metadata">

**Author:** [@pitsianis](https://discourse.julialang.org/u/pitsianis)\
**Replies:** 21\
**Last updated:** [October 25, 2021, 7:04am UTC](https://discourse.julialang.org/t/linearalgebra-inv-matrix-inversion-slower-than-matlab/70066 "2021-10-25T07:04:12Z")

</div>

Why a matrix inversion is slower than MATLAB? I am comparing julia 1.6.3 (2021-09-23) Built by Homebrew (v1.6.3\_1) and MATLAB 9.11.0.1769968 (R2021b) on a late 2013 MacBook Pro 2.6 GHz Dual-Core Intel Core i5 with 16 GB…

---

## [Performance deviations when summing an integer matrix](https://discourse.julialang.org/t/performance-deviations-when-summing-an-integer-matrix/70260)

<div class="topic-metadata">

**Author:** [@goerch](https://discourse.julialang.org/u/goerch)\
**Replies:** 3\
**Last updated:** [October 23, 2021, 5:29pm UTC](https://discourse.julialang.org/t/performance-deviations-when-summing-an-integer-matrix/70260 "2021-10-23T17:29:07Z")

</div>

The following program using Tables using CSV using BenchmarkTools function process1(a::Matrix{Int}) count = 0 for i in 1:size(a, 1) for j in 1:size(a, 2) count += a\[i, j\] end end…

---

## [When will a vector of structs be contiguous in memory?](https://discourse.julialang.org/t/when-will-a-vector-of-structs-be-contiguous-in-memory/70181)

<div class="topic-metadata">

**Author:** [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Replies:** 8\
**Last updated:** [October 23, 2021, 4:29am UTC](https://discourse.julialang.org/t/when-will-a-vector-of-structs-be-contiguous-in-memory/70181 "2021-10-23T04:29:38Z")

</div>

Checking if a vector of structs is contiguous in memory gives some tips for how to check, but would like to know the general pattern. My specific use case is a sort of nested dictionary. I have an iterator of key-value …

---

## [Basic datastructures benchmark](https://discourse.julialang.org/t/basic-datastructures-benchmark/69753)

<div class="topic-metadata">

**Author:** [@goerch](https://discourse.julialang.org/u/goerch)\
**Replies:** 1\
**Last updated:** [October 22, 2021, 9:22pm UTC](https://discourse.julialang.org/t/basic-datastructures-benchmark/69753 "2021-10-22T21:22:41Z")

</div>

With the help of all you here I finished my evaluation of allocators for basic data structures with some at least for me surprising results. Thank you very much again! Please see https://github.com/goerch/Allocators.jl.…

---

## [How can I define functions inside of functions in a performant way?](https://discourse.julialang.org/t/how-can-i-define-functions-inside-of-functions-in-a-performant-way/70213)

<div class="topic-metadata">

**Author:** [@giancarloantonucci](https://discourse.julialang.org/u/giancarloantonucci)\
**Replies:** 9\
**Last updated:** [October 22, 2021, 3:52pm UTC](https://discourse.julialang.org/t/how-can-i-define-functions-inside-of-functions-in-a-performant-way/70213 "2021-10-22T15:52:04Z")

</div>

I want to define functions f1 and f2 (to be inputted inside a struct S) from another function f, defined at global scope, using another auxiliary function fun: mutable struct S f1::Function f2::Function end fun…

---

## [Float32 performance fluctuating over time](https://discourse.julialang.org/t/float32-performance-fluctuating-over-time/70206)

<div class="topic-metadata">

**Author:** [@Chiil](https://discourse.julialang.org/u/Chiil)\
**Replies:** 1\
**Last updated:** [October 22, 2021, 1:20pm UTC](https://discourse.julialang.org/t/float32-performance-fluctuating-over-time/70206 "2021-10-22T13:20:10Z")

</div>

I have coded a CFD code in Julia that has Float32 performance that increases as the simulation progresses, while the Float64 performance is constant in time. My suspicion is that is has to do with underflow in case of th…

---

## [SymRCM doesn't seem to help linear solver to perform](https://discourse.julialang.org/t/symrcm-doesnt-seem-to-help-linear-solver-to-perform/69878)

<div class="topic-metadata">

**Author:** [@Niceno](https://discourse.julialang.org/u/Niceno)\
**Replies:** 12\
**Last updated:** [October 22, 2021, 9:37am UTC](https://discourse.julialang.org/t/symrcm-doesnt-seem-to-help-linear-solver-to-perform/69878 "2021-10-22T09:37:21Z")

</div>

Dear all, Yesterday I came across SymRCM.jl package, which seems to work really neatly and is easy to use, but it doesn’t seem to bring me any performance benefits. Allow me to explain. I wrote a little computational …

---

## [Type inference with a functional programing style](https://discourse.julialang.org/t/type-inference-with-a-functional-programing-style/70105)

<div class="topic-metadata">

**Author:** [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Replies:** 10\
**Last updated:** [October 22, 2021, 8:43am UTC](https://discourse.julialang.org/t/type-inference-with-a-functional-programing-style/70105 "2021-10-22T08:43:21Z")

</div>

I’m having trouble with type inference. I’d like to be able to write this sort of thing and have it run quickly: function silly\_last(vs::AbstractVector) x = first(vs) map(vs) do v x = v end x e…

---

## [How to use LBFGS to get the minimum value in the optimization process, but not the last one](https://discourse.julialang.org/t/how-to-use-lbfgs-to-get-the-minimum-value-in-the-optimization-process-but-not-the-last-one/70080)

<div class="topic-metadata">

**Author:** [@F-YF](https://discourse.julialang.org/u/F-YF)\
**Replies:** 5\
**Last updated:** [October 22, 2021, 6:54am UTC](https://discourse.julialang.org/t/how-to-use-lbfgs-to-get-the-minimum-value-in-the-optimization-process-but-not-the-last-one/70080 "2021-10-22T06:54:45Z")

</div>

When I was doing optimization calculations with the Optim package\[Optim.jl\], , I found that the objective function sometimes unexpectedly tended to go up. I think it might have something to do with the LBFGS method, the …

---

## [Type stable return types](https://discourse.julialang.org/t/type-stable-return-types/70140)

<div class="topic-metadata">

**Author:** [@Amval](https://discourse.julialang.org/u/Amval)\
**Replies:** 3\
**Last updated:** [October 21, 2021, 1:40pm UTC](https://discourse.julialang.org/t/type-stable-return-types/70140 "2021-10-21T13:40:14Z")

</div>

Hello, I have a question regarding type-stability and good practices. Let’s say I have a function/constructor that takes a params::Dict which has some optional fields and returns a Session struct instance with the follo…

---

## [Best method for calculating the second derivative of 1D array](https://discourse.julialang.org/t/best-method-for-calculating-the-second-derivative-of-1d-array/69353)

<div class="topic-metadata">

**Author:** [@AngusRussell](https://discourse.julialang.org/u/AngusRussell)\
**Replies:** 11\
**Last updated:** [October 20, 2021, 7:45pm UTC](https://discourse.julialang.org/t/best-method-for-calculating-the-second-derivative-of-1d-array/69353 "2021-10-20T19:45:06Z")

</div>

Essentially I have 1D arrays of eigenvalues as shown in the above plot and I want to find the 2nd derivative of each energy band with respect to ϵ. My current method uses Dierckx.jl. In my code, the eigenvalues are …

---

## [Performance speed up when wrapping script with Juno.@profiler](https://discourse.julialang.org/t/performance-speed-up-when-wrapping-script-with-juno-profiler/70078)

<div class="topic-metadata">

**Author:** [@saul.ssto](https://discourse.julialang.org/u/saul.ssto)\
**Replies:** 4\
**Last updated:** [October 20, 2021, 6:22pm UTC](https://discourse.julialang.org/t/performance-speed-up-when-wrapping-script-with-juno-profiler/70078 "2021-10-20T18:22:48Z")

</div>

Hello, I’m trying to simulate the Belousov-Zhabotinsky (BZ) reaction as implemented here. I have written the following implementation for that purpose: using Images, ImageView, ProgressMeter function react(petridish::…

---

## [Multithreading on entries sparse matrix](https://discourse.julialang.org/t/multithreading-on-entries-sparse-matrix/70023)

<div class="topic-metadata">

**Author:** [@ismedina](https://discourse.julialang.org/u/ismedina)\
**Replies:** 5\
**Last updated:** [October 20, 2021, 9:40am UTC](https://discourse.julialang.org/t/multithreading-on-entries-sparse-matrix/70023 "2021-10-20T09:40:47Z")

</div>

In my work I usually have to perform some operations on sparse matrices that involve mostly checking which entries are still important and remove those that are not. I thought that I could use multithreading for that, bu…

---

## [Fast way to calculate statistics of an array based on values (labels) of another array](https://discourse.julialang.org/t/fast-way-to-calculate-statistics-of-an-array-based-on-values-labels-of-another-array/70054)

<div class="topic-metadata">

**Author:** [@Bjorn\_De](https://discourse.julialang.org/u/Bjorn_De)\
**Replies:** 7\
**Last updated:** [October 20, 2021, 7:17am UTC](https://discourse.julialang.org/t/fast-way-to-calculate-statistics-of-an-array-based-on-values-labels-of-another-array/70054 "2021-10-20T07:17:42Z")

</div>

Hey, I have two arrays of the same size (10000x10000). One array include labels as result of an segmentation. What I want is to compute statistics for each of these segments based on the 2nd array. My approach is very s…

---

## [Recursion to iteration](https://discourse.julialang.org/t/recursion-to-iteration/69891)

<div class="topic-metadata">

**Author:** [@goerch](https://discourse.julialang.org/u/goerch)\
**Replies:** 12\
**Last updated:** [October 18, 2021, 10:36am UTC](https://discourse.julialang.org/t/recursion-to-iteration/69891 "2021-10-18T10:36:15Z")

</div>

Hi all, I’m trying to convert some code from recursion to iteration keeping an internal stack. My benchmark is showing no improvement. MWE using BenchmarkTools mutable struct Node{T} value::T left::Union{Nothi…

---

## [ThreadsX mapreduce performance](https://discourse.julialang.org/t/threadsx-mapreduce-performance/69879)

<div class="topic-metadata">

**Author:** [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Replies:** 12\
**Last updated:** [October 18, 2021, 4:58am UTC](https://discourse.julialang.org/t/threadsx-mapreduce-performance/69879 "2021-10-18T04:58:20Z")

</div>

Hi, I wonder why ThreadsX.mapreduce is slower than a straightforward @threads loop for a simple function like ThreadsX.mapreduce(abs,max,x) computing the maximal absolute value of an array x. julia\> main() Threads.nth…

---

## [Special casing small integers known at compile time](https://discourse.julialang.org/t/special-casing-small-integers-known-at-compile-time/69934)

<div class="topic-metadata">

**Author:** [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Replies:** 4\
**Last updated:** [October 17, 2021, 6:35pm UTC](https://discourse.julialang.org/t/special-casing-small-integers-known-at-compile-time/69934 "2021-10-17T18:35:21Z")

</div>

I see this sort of code sometimes and it makes me cringe similar(a::Array{T,1}) where {T} = Vector{T}(undef, size(a,1)) similar(a::Array{T,2}) where {T} = Matrix{T}(undef, size(a,1)…

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

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