# Performance

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

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

**Page:** 94

---

## [Efficient eval, splat, eval?](https://discourse.julialang.org/t/efficient-eval-splat-eval/60323)

<div class="topic-metadata">

**Author:** [@mewilhel](https://discourse.julialang.org/u/mewilhel)\
**Replies:** 2\
**Last updated:** [April 30, 2021, 3:23pm UTC](https://discourse.julialang.org/t/efficient-eval-splat-eval/60323 "2021-04-30T15:23:53Z")

</div>

Essentially, I’d like to perform the following snippet of code without allocating or creating an intermediate array (temp): x = Int\[1,2\] # could be of any length n (n is only known at runtime) temp = f.(x) #…

---

## [Initialise array without specific types](https://discourse.julialang.org/t/initialise-array-without-specific-types/60204)

<div class="topic-metadata">

**Author:** [@baptnz](https://discourse.julialang.org/u/baptnz)\
**Replies:** 25\
**Last updated:** [April 30, 2021, 12:51am UTC](https://discourse.julialang.org/t/initialise-array-without-specific-types/60204 "2021-04-30T00:51:36Z")

</div>

I wrote a program that works fine but has several hard-coded types (Float64, etc.) which I’m now trying to get rid of, because they get in the way of automatic differentiation. I’ve hit a snag with the following: I init…

---

## [Distributed loop and possible memory leak](https://discourse.julialang.org/t/distributed-loop-and-possible-memory-leak/60174)

<div class="topic-metadata">

**Author:** [@ovt](https://discourse.julialang.org/u/ovt)\
**Replies:** 0\
**Last updated:** [April 28, 2021, 3:06pm UTC](https://discourse.julialang.org/t/distributed-loop-and-possible-memory-leak/60174 "2021-04-28T15:06:09Z")

</div>

Hello, I’m trying to distribute some computation in a for loop among my procs. Here is what I tried: using Distributed addprocs(5) @everywhere begin using LinearAlgebra using SharedArrays using BenchmarkTools using Infi…

---

## [Is it possible to split a project in two?](https://discourse.julialang.org/t/is-it-possible-to-split-a-project-in-two/59214)

<div class="topic-metadata">

**Author:** [@RaquelSantos](https://discourse.julialang.org/u/RaquelSantos)\
**Replies:** 2\
**Last updated:** [April 28, 2021, 3:18pm UTC](https://discourse.julialang.org/t/is-it-possible-to-split-a-project-in-two/59214 "2021-04-28T15:18:55Z")

</div>

What I want to do is this: I want to have the same project in two environments. In one environment I would only have names that functioned as calls for the model to compile and in the other environment I would have the c…

---

## [Type stability for piecewise defined functions with expensive parts](https://discourse.julialang.org/t/type-stability-for-piecewise-defined-functions-with-expensive-parts/59790)

<div class="topic-metadata">

**Author:** [@alpharho](https://discourse.julialang.org/u/alpharho)\
**Replies:** 8\
**Last updated:** [April 28, 2021, 11:34am UTC](https://discourse.julialang.org/t/type-stability-for-piecewise-defined-functions-with-expensive-parts/59790 "2021-04-28T11:34:25Z")

</div>

The function function f(x) if x \< 0 return 0 end return expensive\_function(x) end Is not type-stable (in most cases). Is there a clean way to make it stable and generic, while staying performant for…

---

## [Expected 72X speedup, observed 1.1X](https://discourse.julialang.org/t/expected-72x-speedup-observed-1-1x/60071)

<div class="topic-metadata">

**Author:** [@PhilipDLoewen](https://discourse.julialang.org/u/PhilipDLoewen)\
**Replies:** 5\
**Last updated:** [April 28, 2021, 4:50am UTC](https://discourse.julialang.org/t/expected-72x-speedup-observed-1-1x/60071 "2021-04-28T04:50:41Z")

</div>

I dreamed up a simple-looking task that I thought multithreading could accelerate. Running the file below (I named it threadbench.jl) proved me wrong: with 72 cores and 72 threads, the timings are not appreciably better …

---

## [Huge difference in performance between two programmes](https://discourse.julialang.org/t/huge-difference-in-performance-between-two-programmes/60116)

<div class="topic-metadata">

**Author:** [@encendre](https://discourse.julialang.org/u/encendre)\
**Replies:** 7\
**Last updated:** [April 27, 2021, 7:02pm UTC](https://discourse.julialang.org/t/huge-difference-in-performance-between-two-programmes/60116 "2021-04-27T19:02:24Z")

</div>

I’m sorry for the not very descriptive title but I couldn’t find a better way to phrase it I have two similar programmes with a huge difference in performance let function useless() end @time let s = 0 for n i…

---

## [Locking in multithreading](https://discourse.julialang.org/t/locking-in-multithreading/60023)

<div class="topic-metadata">

**Author:** [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Replies:** 4\
**Last updated:** [April 27, 2021, 6:00am UTC](https://discourse.julialang.org/t/locking-in-multithreading/60023 "2021-04-27T06:00:00Z")

</div>

Hi, Here is a piece of code (not a MWE…) function parallelkernel!(elca,idof,R,...) # fast typestable kernel @threads for iel ∈ eachindex(elca) r = incremental(elca\[iel\],...) #lock(lk) do R…

---

## [How to make type-stable: passing an element of a vector of functions](https://discourse.julialang.org/t/how-to-make-type-stable-passing-an-element-of-a-vector-of-functions/60068)

<div class="topic-metadata">

**Author:** [@sofiablopez](https://discourse.julialang.org/u/sofiablopez)\
**Replies:** 4\
**Last updated:** [April 26, 2021, 11:31pm UTC](https://discourse.julialang.org/t/how-to-make-type-stable-passing-an-element-of-a-vector-of-functions/60068 "2021-04-26T23:31:44Z")

</div>

I have an array of functions, and I need to iterate it and pass each element of the array to another function. How can I make it type-stable? This code illustrates my problem: function f(g::Function, x::Int64) ret…

---

## [Reactive Programming with Multiprocessing](https://discourse.julialang.org/t/reactive-programming-with-multiprocessing/60048)

<div class="topic-metadata">

**Author:** [@Jack](https://discourse.julialang.org/u/Jack)\
**Replies:** 0\
**Last updated:** [April 26, 2021, 6:14pm UTC](https://discourse.julialang.org/t/reactive-programming-with-multiprocessing/60048 "2021-04-26T18:14:14Z")

</div>

Greeting, I am trying to combine coding in a reactive framework like Rocket.jl with multiprocessing. The idea is to have different actors working in different cores. It’s natural to write in a reactive framework to lever…

---

## [Generate function to build a static array from vector of vector](https://discourse.julialang.org/t/generate-function-to-build-a-static-array-from-vector-of-vector/59862)

<div class="topic-metadata">

**Author:** [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Replies:** 5\
**Last updated:** [April 26, 2021, 9:17am UTC](https://discourse.julialang.org/t/generate-function-to-build-a-static-array-from-vector-of-vector/59862 "2021-04-26T09:17:10Z")

</div>

I have a Vector of Vectors (actually Vector of SVectors, but I do not believe this is relevant to the question.) All vectors, inner and outer, have length N. I wish to generate an SMatrix from it in a typestable mann…

---

## [Huge Performance drop after upgrading to 1.6](https://discourse.julialang.org/t/huge-performance-drop-after-upgrading-to-1-6/59789)

<div class="topic-metadata">

**Author:** [@imLew](https://discourse.julialang.org/u/imLew)\
**Replies:** 13\
**Last updated:** [April 26, 2021, 9:08am UTC](https://discourse.julialang.org/t/huge-performance-drop-after-upgrading-to-1-6/59789 "2021-04-26T09:08:56Z")

</div>

Crossposting this from zulip to reach more people and because it’s a getting a bit long. tl;dr After upgrading to 1.6 my code runs 50 times slower, it seems to be caused by broadcasting with calls to materialize increa…

---

## [Eigenvectors of very large (non-sparse) symmetric matrices?](https://discourse.julialang.org/t/eigenvectors-of-very-large-non-sparse-symmetric-matrices/59885)

<div class="topic-metadata">

**Author:** [@JedPhillips](https://discourse.julialang.org/u/JedPhillips)\
**Replies:** 11\
**Last updated:** [April 25, 2021, 7:57pm UTC](https://discourse.julialang.org/t/eigenvectors-of-very-large-non-sparse-symmetric-matrices/59885 "2021-04-25T19:57:29Z")

</div>

I’m trying to get the first 50 dominant eigenvectors of a huge symmetric matrix, of dimension 65000 x 65000. I’m doing this on a computer cluster, so there’s no RAM limitation. But it still takes forever. In fact I don’t…

---

## [Compatibility with previous versions of Julia: how much makes sense for a new package?](https://discourse.julialang.org/t/compatibility-with-previous-versions-of-julia-how-much-makes-sense-for-a-new-package/59920)

<div class="topic-metadata">

**Author:** [@andreasvarga](https://discourse.julialang.org/u/andreasvarga)\
**Replies:** 4\
**Last updated:** [April 25, 2021, 7:29am UTC](https://discourse.julialang.org/t/compatibility-with-previous-versions-of-julia-how-much-makes-sense-for-a-new-package/59920 "2021-04-25T07:29:59Z")

</div>

I am developing several computational packages, mainly oriented towards control system applications. Several times I was confronted with keeping compatibility with earlier versions of Julia, where I set (I don’t remember…

---

## [LinearAlgebra.BLAS does not accept non-dense Julia Matrix type?](https://discourse.julialang.org/t/linearalgebra-blas-does-not-accept-non-dense-julia-matrix-type/59921)

<div class="topic-metadata">

**Author:** [@JianghuiDu](https://discourse.julialang.org/u/JianghuiDu)\
**Replies:** 3\
**Last updated:** [April 24, 2021, 6:55pm UTC](https://discourse.julialang.org/t/linearalgebra-blas-does-not-accept-non-dense-julia-matrix-type/59921 "2021-04-24T18:55:37Z")

</div>

LinearAlgebra.BLAS.gbmv!('N', 100, 1, 1, 1.0, A\_POC, ones(100), 0.0, ones(100)) throws error julia\> LinearAlgebra.BLAS.gbmv!('N', 100, 1, 1, 1.0, (A\_POC), ones(100), 0.0, on es(100)) ERROR: LoadError: MethodError: no m…

---

## [Odd BenchmarkTools timings using @threads and Octavian](https://discourse.julialang.org/t/odd-benchmarktools-timings-using-threads-and-octavian/59838)

<div class="topic-metadata">

**Author:** [@jlchan](https://discourse.julialang.org/u/jlchan)\
**Replies:** 4\
**Last updated:** [April 23, 2021, 2:54am UTC](https://discourse.julialang.org/t/odd-benchmarktools-timings-using-threads-and-octavian/59838 "2021-04-23T02:54:07Z")

</div>

I’m getting some odd behavior using @threads and Octavian. If I time matmul! and a simple tmap! implementation, I see reasonable speedup. using Octavian using LinearAlgebra A = randn(8,8) x = randn(8,10000) b = simila…

---

## [Allocations when splatting Triangle points](https://discourse.julialang.org/t/allocations-when-splatting-triangle-points/59792)

<div class="topic-metadata">

**Author:** [@weymouth](https://discourse.julialang.org/u/weymouth)\
**Replies:** 3\
**Last updated:** [April 22, 2021, 2:32pm UTC](https://discourse.julialang.org/t/allocations-when-splatting-triangle-points/59792 "2021-04-22T14:32:06Z")

</div>

I’m (finally) adding some distance functions to GeometryBasics.jl and I’m having a problem avoiding allocations when splatting to get the points of a triangle using GeometryBasics using BenchmarkTools vect\_to\_center(p,a…

---

## [Julia vs SciPy - Performance comparison and benchmark help](https://discourse.julialang.org/t/julia-vs-scipy-performance-comparison-and-benchmark-help/59758)

<div class="topic-metadata">

**Author:** [@miguelraz](https://discourse.julialang.org/u/miguelraz)\
**Replies:** 15\
**Last updated:** [April 22, 2021, 6:35am UTC](https://discourse.julialang.org/t/julia-vs-scipy-performance-comparison-and-benchmark-help/59758 "2021-04-22T06:35:10Z")

</div>

Hello all! I’m dusting off a one-function package I made a while ago, but I want to confirm that the benchmarks are honest. There’s some calls to scipy objects, and I would like to know if I’m measuring any sort of unfa…

---

## [Solving ODEs in a loop with DifferentialEquations.jl](https://discourse.julialang.org/t/solving-odes-in-a-loop-with-differentialequations-jl/59640)

<div class="topic-metadata">

**Author:** [@lucass-carneiro](https://discourse.julialang.org/u/lucass-carneiro)\
**Replies:** 10\
**Last updated:** [April 21, 2021, 7:54pm UTC](https://discourse.julialang.org/t/solving-odes-in-a-loop-with-differentialequations-jl/59640 "2021-04-21T19:54:04Z")

</div>

Hi there! I’m working on a problem where I must solve a system of ODEs repeatedly with different parameters and initial conditions. In particular, I’m not really interested in the solution as a whole, I only need to kno…

---

## [Preallocating large matrices in all cores is slower than allocating every time](https://discourse.julialang.org/t/preallocating-large-matrices-in-all-cores-is-slower-than-allocating-every-time/59261)

<div class="topic-metadata">

**Author:** [@kaslusimoes](https://discourse.julialang.org/u/kaslusimoes)\
**Replies:** 7\
**Last updated:** [April 21, 2021, 7:28pm UTC](https://discourse.julialang.org/t/preallocating-large-matrices-in-all-cores-is-slower-than-allocating-every-time/59261 "2021-04-21T19:28:55Z")

</div>

Hi everyone, I am trying to improve a piece of code of mine (numerical simulations for a scientific research project) to scale it up. It essentially involves running one computationally and memory heavy function for se…

---

## [Performance optimisation: Julia vs C++](https://discourse.julialang.org/t/performance-optimisation-julia-vs-c/59689)

<div class="topic-metadata">

**Author:** [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Replies:** 31\
**Last updated:** [April 21, 2021, 2:55pm UTC](https://discourse.julialang.org/t/performance-optimisation-julia-vs-c/59689 "2021-04-21T14:55:24Z")

</div>

Hi all! This is for the performance tweaking addicts out there :smiley: I had a conversation with a “C++ friend” today in which upon request I tried to showcase to him that Julia can be as performant as C++ (say, withi…

---

## [Type stability with tuples is hard](https://discourse.julialang.org/t/type-stability-with-tuples-is-hard/59094)

<div class="topic-metadata">

**Author:** [@mroavi](https://discourse.julialang.org/u/mroavi)\
**Replies:** 23\
**Last updated:** [April 21, 2021, 1:39pm UTC](https://discourse.julialang.org/t/type-stability-with-tuples-is-hard/59094 "2021-04-21T13:39:51Z")

</div>

I came across this article that talks about loop fusion. I saw this as a great opportunity to optimize my code since a lot of intermediate allocations are happening in my program. After having adapted my code, the perfor…

---

## [Generated Tuples of Functions](https://discourse.julialang.org/t/generated-tuples-of-functions/59499)

<div class="topic-metadata">

**Author:** [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Replies:** 3\
**Last updated:** [April 20, 2021, 10:20pm UTC](https://discourse.julialang.org/t/generated-tuples-of-functions/59499 "2021-04-20T22:20:11Z")

</div>

Continuing the discussion from Performance and allocation issue with arrays of functions (v1.5): I want to modify the question I originally posed above, to the case that the collection of functions on which I wish to ev…

---

## [Custom hash function in dict is very slow?](https://discourse.julialang.org/t/custom-hash-function-in-dict-is-very-slow/59683)

<div class="topic-metadata">

**Author:** [@pjentsch0](https://discourse.julialang.org/u/pjentsch0)\
**Replies:** 3\
**Last updated:** [April 20, 2021, 6:44pm UTC](https://discourse.julialang.org/t/custom-hash-function-in-dict-is-very-slow/59683 "2021-04-20T18:44:57Z")

</div>

why is using a custom hash function in a dict so slow? using BenchmarkTools import Base.hash,Base.isequal rtuple() = (trunc(Int,rand()\*10\_000),trunc(Int,rand()\*10\_000)) #make random tuple in \[0,10\_000) function Base.ha…

---

## [Performance closures with changing value of closed over variables](https://discourse.julialang.org/t/performance-closures-with-changing-value-of-closed-over-variables/59671)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 1\
**Last updated:** [April 20, 2021, 4:58pm UTC](https://discourse.julialang.org/t/performance-closures-with-changing-value-of-closed-over-variables/59671 "2021-04-20T16:58:36Z")

</div>

Similar things have been discussed in other threads, but this particular example was surprising to me: julia\> function main(x) g(x,y) = x + y f(x,inner\_g) = inner\_g(x) y = 1 f(x, x -\> …

---

## [Concatenate Generators](https://discourse.julialang.org/t/concatenate-generators/59653)

<div class="topic-metadata">

**Author:** [@etienne\_dg](https://discourse.julialang.org/u/etienne_dg)\
**Replies:** 18\
**Last updated:** [April 20, 2021, 3:01pm UTC](https://discourse.julialang.org/t/concatenate-generators/59653 "2021-04-20T15:01:00Z")

</div>

Hi, I try to initialize a vector in two parts, for example, a vector with fifty 0’s then fifty 1’s. I can create it in a loop, but it is not very concise: function foo1() a = Array{Int64}(undef, 100) for i in …

---

## [Efficient structure of Unitful arrays](https://discourse.julialang.org/t/efficient-structure-of-unitful-arrays/59612)

<div class="topic-metadata">

**Author:** [@snowgum](https://discourse.julialang.org/u/snowgum)\
**Replies:** 8\
**Last updated:** [April 20, 2021, 10:54am UTC](https://discourse.julialang.org/t/efficient-structure-of-unitful-arrays/59612 "2021-04-20T10:54:40Z")

</div>

I’m experiencing performance issues when using Unitful arrays inside a structure. I don’t know how to specify the type so well, so the problem may be from the type definition. Here is a simple example using a struct and…

---

## [Intrusive Collections in Julia](https://discourse.julialang.org/t/intrusive-collections-in-julia/59381)

<div class="topic-metadata">

**Author:** [@bjkaria](https://discourse.julialang.org/u/bjkaria)\
**Replies:** 9\
**Last updated:** [April 20, 2021, 3:33am UTC](https://discourse.julialang.org/t/intrusive-collections-in-julia/59381 "2021-04-20T03:33:33Z")

</div>

Would intrusive collections modeled after the boost intrusive boost intrusive 1.75.0 collection be a useful addition for Julia. Does Julia already have mechanisms which make such collections superfluous. Consider the ad…

---

## [Diminishing returns to \`nthreads\`](https://discourse.julialang.org/t/diminishing-returns-to-nthreads/59621)

<div class="topic-metadata">

**Author:** [@kailukowiak](https://discourse.julialang.org/u/kailukowiak)\
**Replies:** 3\
**Last updated:** [April 19, 2021, 10:29pm UTC](https://discourse.julialang.org/t/diminishing-returns-to-nthreads/59621 "2021-04-19T22:29:12Z")

</div>

Performance with n Threads I have a script that parses a 1Gb file and writes out two CSV files. I want to make this faster by parallelizing it on a large cloud instance. I’m currently testing on an AWS machine c5.9xlarge …

---

## [Poor performance passing data structures as function argument](https://discourse.julialang.org/t/poor-performance-passing-data-structures-as-function-argument/59601)

<div class="topic-metadata">

**Author:** [@snowgum](https://discourse.julialang.org/u/snowgum)\
**Replies:** 5\
**Last updated:** [April 19, 2021, 7:43pm UTC](https://discourse.julialang.org/t/poor-performance-passing-data-structures-as-function-argument/59601 "2021-04-19T19:43:21Z")

</div>

I have a compute-heavy function kernel that I am trying to use inside another function. This function takes several arrays and other data as arguments, and I was trying to make the code cleaner by passing an object as ar…

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

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