# Performance

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

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

**Page:** 111

---

## [Multithreading with dynamic scheduler](https://discourse.julialang.org/t/multithreading-with-dynamic-scheduler/45187)

<div class="topic-metadata">

**Author:** [@lucas711642](https://discourse.julialang.org/u/lucas711642)\
**Replies:** 10\
**Last updated:** [August 19, 2020, 8:35pm UTC](https://discourse.julialang.org/t/multithreading-with-dynamic-scheduler/45187 "2020-08-19T20:35:31Z")

</div>

I have an expensive function that I need to evaluate for several inputs. To use multithreading, I usually use the following workflow: inputs = collect(deepcopy(input) for \_ = 1 : Threads.nthreads()) Threads.@threads for…

---

## [Speed up parallel maximum across columns](https://discourse.julialang.org/t/speed-up-parallel-maximum-across-columns/45006)

<div class="topic-metadata">

**Author:** [@fyang](https://discourse.julialang.org/u/fyang)\
**Replies:** 1\
**Last updated:** [August 18, 2020, 7:06pm UTC](https://discourse.julialang.org/t/speed-up-parallel-maximum-across-columns/45006 "2020-08-18T19:06:42Z")

</div>

Hi Julia community! I need help on speeding up a function with parallelization. Here’s a MWE. using Distributed; n\_cores = 3; addprocs(n\_cores) @everywhere using SharedArrays, BenchmarkTools M = 10000; N = 10000; k = 2…

---

## [Column-wise reduction on a CUDA.CuArray matrix](https://discourse.julialang.org/t/column-wise-reduction-on-a-cuda-cuarray-matrix/45069)

<div class="topic-metadata">

**Author:** [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Replies:** 0\
**Last updated:** [August 16, 2020, 10:33pm UTC](https://discourse.julialang.org/t/column-wise-reduction-on-a-cuda-cuarray-matrix/45069 "2020-08-16T22:33:44Z")

</div>

As suggested here, I am trying to create a version of this findfirst kernel that operates over dimension 2 of input matrix xs and returns the first match for each vector along dimension 1. I think a good approach is a c…

---

## [Speed up simple product accumulator loop](https://discourse.julialang.org/t/speed-up-simple-product-accumulator-loop/44920)

<div class="topic-metadata">

**Author:** [@stst](https://discourse.julialang.org/u/stst)\
**Replies:** 6\
**Last updated:** [August 17, 2020, 7:52am UTC](https://discourse.julialang.org/t/speed-up-simple-product-accumulator-loop/44920 "2020-08-17T07:52:42Z")

</div>

Hello Julia community, I need help with speeding up an inner loop in a larger project (running on Julia 1.5.0). Here is a MWE. The loop accumulates multiplicatively into a vector. using BenchmarkTools function signal1…

---

## [Speeding up creation of maximum mask array](https://discourse.julialang.org/t/speeding-up-creation-of-maximum-mask-array/45001)

<div class="topic-metadata">

**Author:** [@vkv](https://discourse.julialang.org/u/vkv)\
**Replies:** 11\
**Last updated:** [August 17, 2020, 6:01am UTC](https://discourse.julialang.org/t/speeding-up-creation-of-maximum-mask-array/45001 "2020-08-17T06:01:48Z")

</div>

I’ve a program where it needs a mask array which is created by filling all column-wise maxima positions with 1 and others with 0. I want the mask to have only one 1 filled per column. I can do this by x = rand(3, 3); m…

---

## [Performance and allocation issue with arrays of functions (v1.5)](https://discourse.julialang.org/t/performance-and-allocation-issue-with-arrays-of-functions-v1-5/45013)

<div class="topic-metadata">

**Author:** [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Replies:** 6\
**Last updated:** [August 17, 2020, 2:44am UTC](https://discourse.julialang.org/t/performance-and-allocation-issue-with-arrays-of-functions-v1-5/45013 "2020-08-17T02:44:14Z")

</div>

I have an ODE type problem where I generate a sequence of values, x\_n, that, in principle, may be in a comparatively high dimensional space. Often, I don’t need to record teh full values, but rather, just some scalar va…

---

## [Buffer for CircularDeque](https://discourse.julialang.org/t/buffer-for-circulardeque/45041)

<div class="topic-metadata">

**Author:** [@Kruxigt](https://discourse.julialang.org/u/Kruxigt)\
**Replies:** 5\
**Last updated:** [August 16, 2020, 11:17pm UTC](https://discourse.julialang.org/t/buffer-for-circulardeque/45041 "2020-08-16T23:17:35Z")

</div>

Good day folks of Julialand! If I have something similar to the following function foo(x) w = 50 d = CircularDeque{Int64}(w) # Do some calculation based on x using d and return the result end for i in 1:10000…

---

## [Compilation of tips for speeding up computations](https://discourse.julialang.org/t/compilation-of-tips-for-speeding-up-computations/45033)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 1\
**Last updated:** [August 16, 2020, 1:10pm UTC](https://discourse.julialang.org/t/compilation-of-tips-for-speeding-up-computations/45033 "2020-08-16T13:10:47Z")

</div>

Every now and then someone posts a question asking about why Matlab/Python/C/Fortran is so much faster than Julia. The great community here is quickly to point out optimizations that can be used which result in a signifi…

---

## [Making vcat of splatted comprehension type-stable](https://discourse.julialang.org/t/making-vcat-of-splatted-comprehension-type-stable/43872)

<div class="topic-metadata">

**Author:** [@HenriDeh](https://discourse.julialang.org/u/HenriDeh)\
**Replies:** 5\
**Last updated:** [August 16, 2020, 12:56pm UTC](https://discourse.julialang.org/t/making-vcat-of-splatted-comprehension-type-stable/43872 "2020-08-16T12:56:33Z")

</div>

Hi, I am looking for a way to make this kind of operation type-stable. There are many uses to structs with lists of callables but I can’t seem to find a way to make the concatenation of their outputs type-stable julia\> …

---

## [How to reduce memory allocation when looping over an array?](https://discourse.julialang.org/t/how-to-reduce-memory-allocation-when-looping-over-an-array/45022)

<div class="topic-metadata">

**Author:** [@niashvili](https://discourse.julialang.org/u/niashvili)\
**Replies:** 2\
**Last updated:** [August 16, 2020, 5:47am UTC](https://discourse.julialang.org/t/how-to-reduce-memory-allocation-when-looping-over-an-array/45022 "2020-08-16T05:47:23Z")

</div>

Hi guys, I have one main question with a given example and a couple other ones related to understanding some concepts. First, here’s the example function: function brownian\_paths(; paths=10^3, n=10^5, t=1, S0=100, μ=(S…

---

## [Why is BLAS dot product so much faster than Julia loop?](https://discourse.julialang.org/t/why-is-blas-dot-product-so-much-faster-than-julia-loop/44994)

<div class="topic-metadata">

**Author:** [@JeffFessler](https://discourse.julialang.org/u/JeffFessler)\
**Replies:** 18\
**Last updated:** [August 15, 2020, 4:48pm UTC](https://discourse.julialang.org/t/why-is-blas-dot-product-so-much-faster-than-julia-loop/44994 "2020-08-15T16:48:19Z")

</div>

I wanted to illustrate the beauty of Julia for my class by showing the speed of a simple vector dot product, but to my surprise the Julia loop version was about 5x slower than the built-in dot() that (I think) calls BLAS…

---

## [Grassmann.jl A\\b 3x faster than Julia's StaticArrays.jl](https://discourse.julialang.org/t/grassmann-jl-a-b-3x-faster-than-julias-staticarrays-jl/41451)

<div class="topic-metadata">

**Author:** [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Replies:** 34\
**Last updated:** [August 14, 2020, 8:13pm UTC](https://discourse.julialang.org/t/grassmann-jl-a-b-3x-faster-than-julias-staticarrays-jl/41451 "2020-08-14T20:13:03Z")

</div>

In this algebra, it’s possible to compute on a mesh of arbitrary 5 dimensional conformal geometric algebra simplices, which can be represented by a bundle of nested dyadic tensors. julia\> using Grassmann, StaticArrays;…

---

## [Multithreading not giving noticeable advantage when running parallel functions](https://discourse.julialang.org/t/multithreading-not-giving-noticeable-advantage-when-running-parallel-functions/44830)

<div class="topic-metadata">

**Author:** [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Replies:** 19\
**Last updated:** [August 14, 2020, 8:11pm UTC](https://discourse.julialang.org/t/multithreading-not-giving-noticeable-advantage-when-running-parallel-functions/44830 "2020-08-14T20:11:55Z")

</div>

Hello, I have a research problem where I try to determine how a system’s behaviour depends on parameter values. Essentially I have a function determine\_behaviour(p) which takes a set of parameter values and determines h…

---

## [More upgrade, more slow down?](https://discourse.julialang.org/t/more-upgrade-more-slow-down/44458)

<div class="topic-metadata">

**Author:** [@paalon](https://discourse.julialang.org/u/paalon)\
**Replies:** 10\
**Last updated:** [August 13, 2020, 10:48pm UTC](https://discourse.julialang.org/t/more-upgrade-more-slow-down/44458 "2020-08-13T22:48:27Z")

</div>

Here is small benchmark code: using BenchmarkTools powersign(i) = ifelse(i % 2 == 0, 1, -1) function leibniz(n) s = 0 for i = 0:n s += powersign(i) / (2i + 1) end 4s end n = 10^5 @benchmark le…

---

## [The birthday paradox: help to be faster than Fortran](https://discourse.julialang.org/t/the-birthday-paradox-help-to-be-faster-than-fortran/44809)

<div class="topic-metadata">

**Author:** [@profesor\_s](https://discourse.julialang.org/u/profesor_s)\
**Replies:** 16\
**Last updated:** [August 13, 2020, 7:06pm UTC](https://discourse.julialang.org/t/the-birthday-paradox-help-to-be-faster-than-fortran/44809 "2020-08-13T19:06:24Z")

</div>

Introduction I am not able to beat Fortran using Julia. This is the time spent by the algorithm using these two languages: Fortran 0m 42s Julia 4m 33s As you can see, Julia takes 6.5 times the time Fortran takes to s…

---

## [Mmap access denied with SharedArrays](https://discourse.julialang.org/t/mmap-access-denied-with-sharedarrays/44881)

<div class="topic-metadata">

**Author:** [@mfariacastro](https://discourse.julialang.org/u/mfariacastro)\
**Replies:** 0\
**Last updated:** [August 13, 2020, 3:34pm UTC](https://discourse.julialang.org/t/mmap-access-denied-with-sharedarrays/44881 "2020-08-13T15:34:27Z")

</div>

I am running 1.5.0 on Windows. I keep running into an issue when creating a SharedArray. I am able to replicate the problem about 30% of the time. This is very annoying as it essentially means my code keeps crashing. Thi…

---

## [Slower execution with multi-threading using @threads macro](https://discourse.julialang.org/t/slower-execution-with-multi-threading-using-threads-macro/44867)

<div class="topic-metadata">

**Author:** [@trathi](https://discourse.julialang.org/u/trathi)\
**Replies:** 5\
**Last updated:** [August 13, 2020, 12:45pm UTC](https://discourse.julialang.org/t/slower-execution-with-multi-threading-using-threads-macro/44867 "2020-08-13T12:45:40Z")

</div>

I am running into an issue where allowing multi-threading leads to slower execution time. Following is the simple code where I am testing it: function sqr(x) return x\*x end y = zeros(10) for i=1:8 y\[i\] = sqr(i)…

---

## [Fast sparse interval matrices?](https://discourse.julialang.org/t/fast-sparse-interval-matrices/44864)

<div class="topic-metadata">

**Author:** [@fph](https://discourse.julialang.org/u/fph)\
**Replies:** 1\
**Last updated:** [August 13, 2020, 12:41pm UTC](https://discourse.julialang.org/t/fast-sparse-interval-matrices/44864 "2020-08-13T12:41:50Z")

</div>

I have noticed that using sparse interval matrices is a big performance hit: using ValidatedNumerics, SparseArrays import ValidatedNumerics.IntervalArithmetic.hull n = 10000 P = sprand(n, n, 0.01) Q = sprandn(n, n, 0.0…

---

## [Which line is resulting is huge memory allocation?](https://discourse.julialang.org/t/which-line-is-resulting-is-huge-memory-allocation/44822)

<div class="topic-metadata">

**Author:** [@Sanji\_Vinsmoke](https://discourse.julialang.org/u/Sanji_Vinsmoke)\
**Replies:** 10\
**Last updated:** [August 12, 2020, 8:23pm UTC](https://discourse.julialang.org/t/which-line-is-resulting-is-huge-memory-allocation/44822 "2020-08-12T20:23:30Z")

</div>

This code below is running very very slow must be due to the ridiculous number of memory allocations. input = "1113222113" function lookandsay(s::AbstractString)::AbstractString result = "" i = 1 while i \<=…

---

## [Simple Mat-Vec multiply (understanding performance, without the bugs)](https://discourse.julialang.org/t/simple-mat-vec-multiply-understanding-performance-without-the-bugs/44762)

<div class="topic-metadata">

**Author:** [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Replies:** 16\
**Last updated:** [August 12, 2020, 11:22am UTC](https://discourse.julialang.org/t/simple-mat-vec-multiply-understanding-performance-without-the-bugs/44762 "2020-08-12T11:22:53Z")

</div>

I wanted to show someone that straight ahead Julia code is reasonably fast. So I used the following: using BenchmarkTools,LinearAlgebra function matmul(A,v) if size(A,2) != length(v) throw(DimensionMismatch…

---

## [Advice on over- vs. proper use of type parameters](https://discourse.julialang.org/t/advice-on-over-vs-proper-use-of-type-parameters/44779)

<div class="topic-metadata">

**Author:** [@nben](https://discourse.julialang.org/u/nben)\
**Replies:** 2\
**Last updated:** [August 12, 2020, 10:12am UTC](https://discourse.julialang.org/t/advice-on-over-vs-proper-use-of-type-parameters/44779 "2020-08-12T10:12:15Z")

</div>

I am writing an immutable type in Julia and have realized while working on it that I have an opportunity to go a little crazy with the type parameters. Here’s a contrived example that deals with the same problem. I’m cur…

---

## [A possible way to improve training in Flux?](https://discourse.julialang.org/t/a-possible-way-to-improve-training-in-flux/44629)

<div class="topic-metadata">

**Author:** [@SambitMishra98](https://discourse.julialang.org/u/SambitMishra98)\
**Replies:** 15\
**Last updated:** [August 12, 2020, 7:44am UTC](https://discourse.julialang.org/t/a-possible-way-to-improve-training-in-flux/44629 "2020-08-12T07:44:42Z")

</div>

Let’s say I need my weights to be determined with an accuracy of 10^10 and hence want to train my network using Float64. Does it make sense to train my network with Float32 and then (after I get around 10^-7 accurac…

---

## [Performance inv & solve in Julia & R](https://discourse.julialang.org/t/performance-inv-solve-in-julia-r/44625)

<div class="topic-metadata">

**Author:** [@PharmCat](https://discourse.julialang.org/u/PharmCat)\
**Replies:** 15\
**Last updated:** [August 11, 2020, 9:26pm UTC](https://discourse.julialang.org/t/performance-inv-solve-in-julia-r/44625 "2020-08-11T21:26:47Z")

</div>

How can it be: Matrix inv(A) where A 150x150 matrix twice slower (2.643 ms) than in R (1.049 ms). But invercing by blocks in R ( 3.275 ms) slower than in Julia (58.917 μs) many times. Second not surprising, but first… …

---

## [Adding large matrix, why .+ is not the default?](https://discourse.julialang.org/t/adding-large-matrix-why-is-not-the-default/44708)

<div class="topic-metadata">

**Author:** [@raphaelchinchilla](https://discourse.julialang.org/u/raphaelchinchilla)\
**Replies:** 3\
**Last updated:** [August 10, 2020, 9:10pm UTC](https://discourse.julialang.org/t/adding-large-matrix-why-is-not-the-default/44708 "2020-08-10T21:10:40Z")

</div>

Take three large matrix A, B, C each with 1000x1000 elements. Here is the result for two benchmarks: using broadcasted operator “.+” @benchmark A.=A.+B.+C BenchmarkTools.Trial: memory estimate: 96 bytes allocs e…

---

## [Why is os.walk() + regex so much slower than glob](https://discourse.julialang.org/t/why-is-os-walk-regex-so-much-slower-than-glob/43906)

<div class="topic-metadata">

**Author:** [@OffbeatNeat](https://discourse.julialang.org/u/OffbeatNeat)\
**Replies:** 2\
**Last updated:** [August 7, 2020, 3:17pm UTC](https://discourse.julialang.org/t/why-is-os-walk-regex-so-much-slower-than-glob/43906 "2020-08-07T15:17:29Z")

</div>

Hi! So myself and another coworker were both writing julia code that basically did the same thing as a specific GNU find command. For my implementation, I used a regex for the filename and walkdir to find the files, so…

---

## [What is faster, abs(x) or x^2?](https://discourse.julialang.org/t/what-is-faster-abs-x-or-x-2/42547)

<div class="topic-metadata">

**Author:** [@azadoroz](https://discourse.julialang.org/u/azadoroz)\
**Replies:** 15\
**Last updated:** [August 7, 2020, 12:56am UTC](https://discourse.julialang.org/t/what-is-faster-abs-x-or-x-2/42547 "2020-08-07T00:56:48Z")

</div>

I need to compare many values to one. What would be faster: Option A: for i = 1 : N if abs(arr\[i\]) \> someValue doSomething(i); end end Option B: someValueSquared = someValue^2; for i = 1 : N if…

---

## [Reshape() still allocating memory in Julia 1.5.0](https://discourse.julialang.org/t/reshape-still-allocating-memory-in-julia-1-5-0/44437)

<div class="topic-metadata">

**Author:** [@benwcs](https://discourse.julialang.org/u/benwcs)\
**Replies:** 2\
**Last updated:** [August 6, 2020, 5:49pm UTC](https://discourse.julialang.org/t/reshape-still-allocating-memory-in-julia-1-5-0/44437 "2020-08-06T17:49:55Z")

</div>

It is great to see views no longer allocate memory in Julia 1.5.0! This we be very helpful for a project I am currenlty working on. However, it seems that calls to reshape still do, unless I use the @uviews macro supplie…

---

## [Julia Lang and VLSI design](https://discourse.julialang.org/t/julia-lang-and-vlsi-design/44356)

<div class="topic-metadata">

**Author:** [@Vrucoder](https://discourse.julialang.org/u/Vrucoder)\
**Replies:** 4\
**Last updated:** [August 6, 2020, 3:21pm UTC](https://discourse.julialang.org/t/julia-lang-and-vlsi-design/44356 "2020-08-06T15:21:12Z")

</div>

It is known from various articles on internet that Julia lang has better speed and efficiency. Can it be used in place of C++/SystemC in the VLSI design fields?

---

## [Expand matrix from n x n to n+1 x n+1](https://discourse.julialang.org/t/expand-matrix-from-n-x-n-to-n-1-x-n-1/44365)

<div class="topic-metadata">

**Author:** [@mleprovost](https://discourse.julialang.org/u/mleprovost)\
**Replies:** 2\
**Last updated:** [August 5, 2020, 9:26pm UTC](https://discourse.julialang.org/t/expand-matrix-from-n-x-n-to-n-1-x-n-1/44365 "2020-08-05T21:26:25Z")

</div>

Hello, Is there a convenient function to augment in-place a matrix A from n \\times n to n+1 \\times n+1. We can always do A = hcat(vcat(A, zeros(1, size(A,1))), zeros(size(A,1)+1,1))

---

## [Speeding up force calculations and mutable structs](https://discourse.julialang.org/t/speeding-up-force-calculations-and-mutable-structs/44228)

<div class="topic-metadata">

**Author:** [@Michael\_Wang](https://discourse.julialang.org/u/Michael_Wang)\
**Replies:** 20\
**Last updated:** [August 5, 2020, 3:45pm UTC](https://discourse.julialang.org/t/speeding-up-force-calculations-and-mutable-structs/44228 "2020-08-05T15:45:07Z")

</div>

I put together a simple package to simulate many interacting Brownian particles. I’m trying to speed up the force calculation (for Lennard-Jones). Below is the force calculation using cell lists to find neighbors. The…

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

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