# Performance

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

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

**Page:** 105

---

## [Unsolvable dynamic dispatch in a \`for\` loop](https://discourse.julialang.org/t/unsolvable-dynamic-dispatch-in-a-for-loop/50643)

<div class="topic-metadata">

**Author:** [@drarnau](https://discourse.julialang.org/u/drarnau)\
**Replies:** 3\
**Last updated:** [November 23, 2020, 9:11pm UTC](https://discourse.julialang.org/t/unsolvable-dynamic-dispatch-in-a-for-loop/50643 "2020-11-23T21:11:34Z")

</div>

Hello, I posted about this problem last week. I think now I have the most simple example to illustrate it: function my2outputs(a::Float64, g::Function) myRange = LinRange(-10.0,10.0,100) myMax, myLoc = findmax(…

---

## [Eigs on huge SparseArrays doesn't use all BLAS threads](https://discourse.julialang.org/t/eigs-on-huge-sparsearrays-doesnt-use-all-blas-threads/50626)

<div class="topic-metadata">

**Author:** [@Ahmed\_Abouelkomsan](https://discourse.julialang.org/u/Ahmed_Abouelkomsan)\
**Replies:** 7\
**Last updated:** [November 23, 2020, 8:27pm UTC](https://discourse.julialang.org/t/eigs-on-huge-sparsearrays-doesnt-use-all-blas-threads/50626 "2020-11-23T20:27:29Z")

</div>

Hi all, I am dealing with huge sparse arrays of dimensions greater than 10^6. I am interested in finding only few extremal eigenvalues. To this end, I tried to use the Arpack package but I noticed that if the size of th…

---

## [How do I distribute Mamba mcmc function iterations on different processors?](https://discourse.julialang.org/t/how-do-i-distribute-mamba-mcmc-function-iterations-on-different-processors/50462)

<div class="topic-metadata">

**Author:** [@EllieA](https://discourse.julialang.org/u/EllieA)\
**Replies:** 3\
**Last updated:** [November 23, 2020, 7:48pm UTC](https://discourse.julialang.org/t/how-do-i-distribute-mamba-mcmc-function-iterations-on-different-processors/50462 "2020-11-23T19:48:08Z")

</div>

Hi all, I am new to Mamba package, I know that it has automated paralleling for different “chains” but as my data set is a huge one, I would like to distribute the iterations on different processors. Is it possible?

---

## [Assign vector to slices and allocation](https://discourse.julialang.org/t/assign-vector-to-slices-and-allocation/49887)

<div class="topic-metadata">

**Author:** [@cricci](https://discourse.julialang.org/u/cricci)\
**Replies:** 7\
**Last updated:** [November 23, 2020, 6:06pm UTC](https://discourse.julialang.org/t/assign-vector-to-slices-and-allocation/49887 "2020-11-23T18:06:50Z")

</div>

I am trying to optimize my code by reducing all unnecessary memory allocation. In particular I have a some assignment I need to repeat many many times. Hence I pre-allocate all necessary vectors and matrices in order to …

---

## [Could this simple function go faster?](https://discourse.julialang.org/t/could-this-simple-function-go-faster/50034)

<div class="topic-metadata">

**Author:** [@lrnv](https://discourse.julialang.org/u/lrnv)\
**Replies:** 15\
**Last updated:** [November 22, 2020, 7:46pm UTC](https://discourse.julialang.org/t/could-this-simple-function-go-faster/50034 "2020-11-22T19:46:52Z")

</div>

Hi, First time ever writing julia code. I’ve spend some time trying to optimise this function, mainly making it type-stable, and separate some precomputations. But maybe this is not the best way to go. The resulting co…

---

## [Copying a QR decomposition matrix Q is extremely slow](https://discourse.julialang.org/t/copying-a-qr-decomposition-matrix-q-is-extremely-slow/50430)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 7\
**Last updated:** [November 22, 2020, 8:58am UTC](https://discourse.julialang.org/t/copying-a-qr-decomposition-matrix-q-is-extremely-slow/50430 "2020-11-22T08:58:40Z")

</div>

This is on julia 1.5.3 julia\> f = qr(ones(100, 20), Val(true)); julia\> copy(f.Q); @time copy(f.Q); 0.057310 seconds (40.00 k allocations: 338.516 MiB, 10.85% gc time) julia\> copy(Array(f.Q)); @time copy(Array(f.Q));…

---

## [\`cat\` allocates too much memory](https://discourse.julialang.org/t/cat-allocates-too-much-memory/50443)

<div class="topic-metadata">

**Author:** [@ArthurW](https://discourse.julialang.org/u/ArthurW)\
**Replies:** 11\
**Last updated:** [November 19, 2020, 4:50pm UTC](https://discourse.julialang.org/t/cat-allocates-too-much-memory/50443 "2020-11-19T16:50:54Z")

</div>

Hi. I’m new to Julia language. I’m trying to convert a big vector of small arrays into a tensor, but cat() is drawing too much resources. julia\> A = \[rand(Int, (28,28)) for \_ ∈ 1:10000\]; julia\> @time cat(A..., dims=3)…

---

## [Unexpected speed difference for differently chained functions](https://discourse.julialang.org/t/unexpected-speed-difference-for-differently-chained-functions/50427)

<div class="topic-metadata">

**Author:** [@Phypix](https://discourse.julialang.org/u/Phypix)\
**Replies:** 3\
**Last updated:** [November 19, 2020, 4:23pm UTC](https://discourse.julialang.org/t/unexpected-speed-difference-for-differently-chained-functions/50427 "2020-11-19T16:23:23Z")

</div>

I want to chain several to be applied element-wise on an array. I have first used the default approach with f(A) = @. f1(f2(A)). However I noticed, that by defining the captures c1 = x -\> f1.(x) and c2 = x -\> f2.(x) and…

---

## [Svdvals is inefficient for tall matrices](https://discourse.julialang.org/t/svdvals-is-inefficient-for-tall-matrices/50330)

<div class="topic-metadata">

**Author:** [@JeffFessler](https://discourse.julialang.org/u/JeffFessler)\
**Replies:** 2\
**Last updated:** [November 19, 2020, 2:46pm UTC](https://discourse.julialang.org/t/svdvals-is-inefficient-for-tall-matrices/50330 "2020-11-19T14:46:08Z")

</div>

For a tall matrix X, calling svdvals(X) directly is noticeably slower than calling it on svdvals(X'X) despite the overhead of the extra matrix-matrix multiply: using BenchmarkTools: @btime using LinearAlgebra: svdvals X…

---

## [How to get --machine-file for array tasks?](https://discourse.julialang.org/t/how-to-get-machine-file-for-array-tasks/50401)

<div class="topic-metadata">

**Author:** [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Replies:** 0\
**Last updated:** [November 18, 2020, 9:22pm UTC](https://discourse.julialang.org/t/how-to-get-machine-file-for-array-tasks/50401 "2020-11-18T21:22:46Z")

</div>

I have the following sbatch.sub script which defines a job array where each is meant to call run.jl with it’s respective slurm nodefile (please see below). This produces outputs for both array iterations but they say so…

---

## [Dynamic dispatch in a for loop](https://discourse.julialang.org/t/dynamic-dispatch-in-a-for-loop/50282)

<div class="topic-metadata">

**Author:** [@drarnau](https://discourse.julialang.org/u/drarnau)\
**Replies:** 17\
**Last updated:** [November 18, 2020, 6:03pm UTC](https://discourse.julialang.org/t/dynamic-dispatch-in-a-for-loop/50282 "2020-11-18T18:03:31Z")

</div>

Hello, While trying to optimise my code, Juno’s profiler flagged a portion of my code as doing some dynamic dispatch. Since my original code is fairly long, here is the smallest example I could come up with to illustrat…

---

## [Slurm cpus vs tasks in Distributed](https://discourse.julialang.org/t/slurm-cpus-vs-tasks-in-distributed/50357)

<div class="topic-metadata">

**Author:** [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Replies:** 0\
**Last updated:** [November 18, 2020, 5:39am UTC](https://discourse.julialang.org/t/slurm-cpus-vs-tasks-in-distributed/50357 "2020-11-18T05:39:18Z")

</div>

Given that Slurm tasks map to workers in Distributed, it seems like there is actually no representation of Slurm “cpus” in the sbatch “–cpus-per-task” sense. Is this correct?

---

## [Matrix multiplication](https://discourse.julialang.org/t/matrix-multiplication/50293)

<div class="topic-metadata">

**Author:** [@nhavt](https://discourse.julialang.org/u/nhavt)\
**Replies:** 6\
**Last updated:** [November 17, 2020, 7:45pm UTC](https://discourse.julialang.org/t/matrix-multiplication/50293 "2020-11-17T19:45:22Z")

</div>

Hi there, I need to perform many matrix multiplications as follows. Here I proposed two functions (f1 and f2). I am wondering whether we could improve the speed of the function f2 further? Thanks in advance! using Line…

---

## [JuMP.set\_objective\_coefficient performance](https://discourse.julialang.org/t/jump-set-objective-coefficient-performance/50283)

<div class="topic-metadata">

**Author:** [@omicron](https://discourse.julialang.org/u/omicron)\
**Replies:** 3\
**Last updated:** [November 17, 2020, 1:27pm UTC](https://discourse.julialang.org/t/jump-set-objective-coefficient-performance/50283 "2020-11-17T13:27:38Z")

</div>

Hi, I’m using JuMP to build LP-problems and later I want to update the objective coefficients with the function set\_objective\_coefficient instead of building the whole LP again. Below are the functions I defined and the …

---

## [Improve performance of vector-matrix multiplication](https://discourse.julialang.org/t/improve-performance-of-vector-matrix-multiplication/50251)

<div class="topic-metadata">

**Author:** [@uwechsler](https://discourse.julialang.org/u/uwechsler)\
**Replies:** 2\
**Last updated:** [November 16, 2020, 10:16pm UTC](https://discourse.julialang.org/t/improve-performance-of-vector-matrix-multiplication/50251 "2020-11-16T22:16:19Z")

</div>

In a larger project, I have to compute a (row)vector-matrix multiplication. I guess that in mathematical terms, I would write it as c = x\\cdot M^T where x\\in \\mathbb{R}^{1 \\times n}, M^T\\in \\mathbb{R}^{n \\times m} and c…

---

## [Acceleration of a function](https://discourse.julialang.org/t/acceleration-of-a-function/50181)

<div class="topic-metadata">

**Author:** [@Jonas](https://discourse.julialang.org/u/Jonas)\
**Replies:** 16\
**Last updated:** [November 16, 2020, 2:09pm UTC](https://discourse.julialang.org/t/acceleration-of-a-function/50181 "2020-11-16T14:09:49Z")

</div>

Hello everyone, I am currently transforming some Matlab code into Julia. Everything works fine, but I recognized a big difference in runtime. I don’t have much experience in that regard, so I started reading the guideli…

---

## [Const FileData = AbstractVector{UInt8}](https://discourse.julialang.org/t/const-filedata-abstractvector-uint8/50147)

<div class="topic-metadata">

**Author:** [@JuergenD](https://discourse.julialang.org/u/JuergenD)\
**Replies:** 7\
**Last updated:** [November 16, 2020, 7:47am UTC](https://discourse.julialang.org/t/const-filedata-abstractvector-uint8/50147 "2020-11-16T07:47:43Z")

</div>

Hi, I thought const FileData = AbstractVector{UInt8} it is just an alias, but afaik it is not. buf = obj.buf # buf is defined as ::FileData while start \< size ... fn(@view buf\[start:stop\]) ... end The ver…

---

## [Plots... \`xrot\` stopped working?](https://discourse.julialang.org/t/plots-xrot-stopped-working/46503)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 3\
**Last updated:** [November 16, 2020, 7:19am UTC](https://discourse.julialang.org/t/plots-xrot-stopped-working/46503 "2020-11-16T07:19:03Z")

</div>

In min June, I used keyword xrot to rotate the xticks in Plots with PyPlot backend: Today, the xrot keyword doesn’t seem to work any more: Has the keyword been removed/changed?

---

## [Conditional Logit MLP in Flux](https://discourse.julialang.org/t/conditional-logit-mlp-in-flux/50140)

<div class="topic-metadata">

**Author:** [@compleat](https://discourse.julialang.org/u/compleat)\
**Replies:** 4\
**Last updated:** [November 15, 2020, 1:03pm UTC](https://discourse.julialang.org/t/conditional-logit-mlp-in-flux/50140 "2020-11-15T13:03:56Z")

</div>

I have been trying for awhile to get Conditional Logistic Regression (mathematically equivalent to Cox Proportional Hazards model) working with MLP’s in Flux, and have found a way, though it is clumsy. I am wondering i…

---

## [Struct Parameterized by One Dimension of StaticArray Matrix Members](https://discourse.julialang.org/t/struct-parameterized-by-one-dimension-of-staticarray-matrix-members/50115)

<div class="topic-metadata">

**Author:** [@tawheeler](https://discourse.julialang.org/u/tawheeler)\
**Replies:** 9\
**Last updated:** [November 15, 2020, 9:38am UTC](https://discourse.julialang.org/t/struct-parameterized-by-one-dimension-of-staticarray-matrix-members/50115 "2020-11-15T09:38:51Z")

</div>

I would like to preallocate some static arrays for use with DifferentialEquations.jl. My problem uses a lot of matrices that are 3 x N, where N is not known ahead of time. I would like to use StaticArrays.jl and do somet…

---

## [Builtin argmin is slower than manual](https://discourse.julialang.org/t/builtin-argmin-is-slower-than-manual/50127)

<div class="topic-metadata">

**Author:** [@endremborza](https://discourse.julialang.org/u/endremborza)\
**Replies:** 13\
**Last updated:** [November 14, 2020, 3:57pm UTC](https://discourse.julialang.org/t/builtin-argmin-is-slower-than-manual/50127 "2020-11-14T15:57:27Z")

</div>

I don’t understand how this is possible. I tried it many times, targmin always wins, and by quite a significant margin (1.5.2) using BenchmarkTools function targmin(a) m = Inf ind = 0 for i in 1:length(a) …

---

## [Alternative for \`searchsortedfirst\` for repeatedly searching the same array with concentrated values](https://discourse.julialang.org/t/alternative-for-searchsortedfirst-for-repeatedly-searching-the-same-array-with-concentrated-values/50063)

<div class="topic-metadata">

**Author:** [@malacroi](https://discourse.julialang.org/u/malacroi)\
**Replies:** 6\
**Last updated:** [November 13, 2020, 3:44pm UTC](https://discourse.julialang.org/t/alternative-for-searchsortedfirst-for-repeatedly-searching-the-same-array-with-concentrated-values/50063 "2020-11-13T15:44:51Z")

</div>

I have a sorted array a, of positive integers (related to integer partitions), and need to repeatedly find the first index with a value \>= k for various k uniformly distributed between 1 and a\[end\]. This is exactly the …

---

## [Operation on columns of a matrix](https://discourse.julialang.org/t/operation-on-columns-of-a-matrix/50060)

<div class="topic-metadata">

**Author:** [@nhavt](https://discourse.julialang.org/u/nhavt)\
**Replies:** 3\
**Last updated:** [November 13, 2020, 7:51am UTC](https://discourse.julialang.org/t/operation-on-columns-of-a-matrix/50060 "2020-11-13T07:51:45Z")

</div>

Hello there, I would like to ask a question regarding an operation on two columns of a matrix as you can see below. Here I proposed two functions to perform the task. The function f1 has two allocations even though I us…

---

## [Conversion of Vector{UInt8} to String without copy](https://discourse.julialang.org/t/conversion-of-vector-uint8-to-string-without-copy/49837)

<div class="topic-metadata">

**Author:** [@JuergenD](https://discourse.julialang.org/u/JuergenD)\
**Replies:** 7\
**Last updated:** [November 12, 2020, 6:32pm UTC](https://discourse.julialang.org/t/conversion-of-vector-uint8-to-string-without-copy/49837 "2020-11-12T18:32:03Z")

</div>

Hi, use case: large files with a binary structure and embedded “text” elements. Depending on the file size, we either read them fully into mem, or mmap them. Hence in both cases, the data are fully available in memory…

---

## [How to run HTTP Post request as background task?](https://discourse.julialang.org/t/how-to-run-http-post-request-as-background-task/49673)

<div class="topic-metadata">

**Author:** [@uwechsler](https://discourse.julialang.org/u/uwechsler)\
**Replies:** 3\
**Last updated:** [November 11, 2020, 2:59am UTC](https://discourse.julialang.org/t/how-to-run-http-post-request-as-background-task/49673 "2020-11-11T02:59:15Z")

</div>

Hi everybody, I am working on a wrapper for the Seq logger for Julia (see WIP project) Using the REST API for posting raw events , it is possible to post log events to the Seq logging server. My current implementatio…

---

## [Allocation / performance for 2d array sorts](https://discourse.julialang.org/t/allocation-performance-for-2d-array-sorts/49910)

<div class="topic-metadata">

**Author:** [@endremborza](https://discourse.julialang.org/u/endremborza)\
**Replies:** 5\
**Last updated:** [November 10, 2020, 11:03pm UTC](https://discourse.julialang.org/t/allocation-performance-for-2d-array-sorts/49910 "2020-11-10T23:03:06Z")

</div>

I’m just getting started with Julia so I’m trying to optimize every piece of code, not just for practicality, but to learn more about the language. I ran into an interesting case, where the number of allocation seems to …

---

## [Accessing rows without copying](https://discourse.julialang.org/t/accessing-rows-without-copying/49945)

<div class="topic-metadata">

**Author:** [@barthelemymp](https://discourse.julialang.org/u/barthelemymp)\
**Replies:** 1\
**Last updated:** [November 10, 2020, 9:01pm UTC](https://discourse.julialang.org/t/accessing-rows-without-copying/49945 "2020-11-10T21:01:46Z")

</div>

Hello, I am optimizing my code, and I wanted to know how I could access the row of a matrix directly (not making a copy of it, and pass it to a function. right now I do: @threads for i=1:n\_rows results\[i\] = myfu…

---

## [Struct with a field of type \`Function\`](https://discourse.julialang.org/t/struct-with-a-field-of-type-function/49669)

<div class="topic-metadata">

**Author:** [@Azzaare](https://discourse.julialang.org/u/Azzaare)\
**Replies:** 8\
**Last updated:** [November 10, 2020, 4:33pm UTC](https://discourse.julialang.org/t/struct-with-a-field-of-type-function/49669 "2020-11-10T16:33:26Z")

</div>

Hi there, I am trying to define a struct that contains the keys to a set of variables vars and a function with a signature that corresponds to those variables. struct MyType f::Function vars::Vector{Int} end A…

---

## [Flux example 100x slower with L2 regularisation(?!)](https://discourse.julialang.org/t/flux-example-100x-slower-with-l2-regularisation/49914)

<div class="topic-metadata">

**Author:** [@compleat](https://discourse.julialang.org/u/compleat)\
**Replies:** 5\
**Last updated:** [November 10, 2020, 2:51pm UTC](https://discourse.julialang.org/t/flux-example-100x-slower-with-l2-regularisation/49914 "2020-11-10T14:51:20Z")

</div>

I am running a network in Flux/ADAM without regularisation which does 100 epochs in about as many seconds. When I add an L2-penalty of 0.01\*sum(abs2 , m\[2\].W) to the loss function and train, it takes 90-100 seconds per…

---

## [Making use of \`optlevel\` etc](https://discourse.julialang.org/t/making-use-of-optlevel-etc/49917)

<div class="topic-metadata">

**Author:** [@jules](https://discourse.julialang.org/u/jules)\
**Replies:** 1\
**Last updated:** [November 10, 2020, 2:35pm UTC](https://discourse.julialang.org/t/making-use-of-optlevel-etc/49917 "2020-11-10T14:35:05Z")

</div>

The Makie ecosystem still suffers from large compilation latency. Tim Holy has kindly been looking at invalidations for us, but that is relatively slow work and hard to do for the amount of code that is there. One option…

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

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