# Performance

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

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

**Page:** 60

---

## [Sparse syrk() routine using Transducers.jl](https://discourse.julialang.org/t/sparse-syrk-routine-using-transducers-jl/86218)

<div class="topic-metadata">

**Author:** [@josuagrw](https://discourse.julialang.org/u/josuagrw)\
**Replies:** 0\
**Last updated:** [August 23, 2022, 7:09pm UTC](https://discourse.julialang.org/t/sparse-syrk-routine-using-transducers-jl/86218 "2022-08-23T19:09:07Z")

</div>

Hi, I implemented a sparse syrk routine to see if I could get something faster than the naive implementation: using SparseArrays using LinearAlgebra using Transducers using Combinatorics naive\_spsyrk(s) = Symmetric(s …

---

## [Automatic differentiation of spline functions](https://discourse.julialang.org/t/automatic-differentiation-of-spline-functions/86182)

<div class="topic-metadata">

**Author:** [@compleat](https://discourse.julialang.org/u/compleat)\
**Replies:** 4\
**Last updated:** [August 23, 2022, 2:39pm UTC](https://discourse.julialang.org/t/automatic-differentiation-of-spline-functions/86182 "2022-08-23T14:39:56Z")

</div>

Splines are a common fitting tool and there are a number of versions in Julia, but I can’t seem to find any versions which are auto-differentiable (i.e., for use in JuMP, NLopt, ODE’s, Integration, etc.). \[I’m guessing …

---

## [Replicate @tturbo performance](https://discourse.julialang.org/t/replicate-tturbo-performance/86146)

<div class="topic-metadata">

**Author:** [@gitboy16](https://discourse.julialang.org/u/gitboy16)\
**Replies:** 23\
**Last updated:** [August 23, 2022, 12:53pm UTC](https://discourse.julialang.org/t/replicate-tturbo-performance/86146 "2022-08-23T12:53:40Z")

</div>

Hi, Is there an easy way to replicate the performance of @tturbo but using just base Julia? The following Julia code might be used if needed for this discussion: function myminmax(x) a = b = x\[1\] @tturbo for i in…

---

## [\`map\` vs \`broadcast\`: should one prefer \`map\` if these are equivalent?](https://discourse.julialang.org/t/map-vs-broadcast-should-one-prefer-map-if-these-are-equivalent/86118)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 3\
**Last updated:** [August 23, 2022, 10:09am UTC](https://discourse.julialang.org/t/map-vs-broadcast-should-one-prefer-map-if-these-are-equivalent/86118 "2022-08-23T10:09:26Z")

</div>

I’m referring to the simplest case where map and broadcast are equivalent, that is – given a vector/tuple, I want to map a function over it to obtain another container. broadcast seems a natural choice here, and map seem…

---

## [ByRow vs broadcasting performance](https://discourse.julialang.org/t/byrow-vs-broadcasting-performance/86069)

<div class="topic-metadata">

**Author:** [@Soldalma](https://discourse.julialang.org/u/Soldalma)\
**Replies:** 0\
**Last updated:** [August 20, 2022, 4:42pm UTC](https://discourse.julialang.org/t/byrow-vs-broadcasting-performance/86069 "2022-08-20T16:42:46Z")

</div>

I was under the impression that ByRow would have better performance than broadcasting. However, trying an example today I found that it seems to be the other way. It may be due to some specific characteristic of my examp…

---

## [Recursive inner functions a thousand times slower?](https://discourse.julialang.org/t/recursive-inner-functions-a-thousand-times-slower/85604)

<div class="topic-metadata">

**Author:** [@ikirill](https://discourse.julialang.org/u/ikirill)\
**Replies:** 8\
**Last updated:** [August 20, 2022, 7:57am UTC](https://discourse.julialang.org/t/recursive-inner-functions-a-thousand-times-slower/85604 "2022-08-20T07:57:58Z")

</div>

In the following code function f(y) loop(x::Int)::Int = x \> 0 ? 1 + loop(x-1) : 0 loop(y) end g(x::Int)::Int = x \> 0 ? 1 + g(x-1) : 0 I get the following timings: julia\> @btime f(100) 12.770 μs (2 allocatio…

---

## [Extra allocation with \`T::DataType\`?](https://discourse.julialang.org/t/extra-allocation-with-t-datatype/85930)

<div class="topic-metadata">

**Author:** [@lucifer1004](https://discourse.julialang.org/u/lucifer1004)\
**Replies:** 17\
**Last updated:** [August 19, 2022, 7:04am UTC](https://discourse.julialang.org/t/extra-allocation-with-t-datatype/85930 "2022-08-19T07:04:54Z")

</div>

function A(T::DataType, m::Integer, n::Integer, s::Integer, θ::Number) θ = T(θ) half = θ / 2 cos\_half = cos(half) sin\_half = sin(half) kmin = max(0, m - n) kmax = min(s + m, s - n) sig = (-1)^…

---

## [Ominous type instability](https://discourse.julialang.org/t/ominous-type-instability/85169)

<div class="topic-metadata">

**Author:** [@arik](https://discourse.julialang.org/u/arik)\
**Replies:** 10\
**Last updated:** [August 20, 2022, 3:46am UTC](https://discourse.julialang.org/t/ominous-type-instability/85169 "2022-08-20T03:46:06Z")

</div>

Hi there! I am working on some Code that is supposed to be a demonstration of how you can create fast and efficient code with just a few easy, readable lines in Julia. Sadly one of the functions turns out to be not type…

---

## [Read lines from file without new allocations](https://discourse.julialang.org/t/read-lines-from-file-without-new-allocations/86018)

<div class="topic-metadata">

**Author:** [@CodeGodz](https://discourse.julialang.org/u/CodeGodz)\
**Replies:** 1\
**Last updated:** [August 19, 2022, 11:15pm UTC](https://discourse.julialang.org/t/read-lines-from-file-without-new-allocations/86018 "2022-08-19T23:15:56Z")

</div>

I have to read a 7TB file and noticed that each line, when read with eachline(..), comes with a new allocation. Since I know that a line can never exceed length X (but can be smaller) I thought I could pre-alloc a Vector…

---

## [Change the color of shaded area in plotting uncertain quantity in MonteCarloMeasurements.jl](https://discourse.julialang.org/t/change-the-color-of-shaded-area-in-plotting-uncertain-quantity-in-montecarlomeasurements-jl/85956)

<div class="topic-metadata">

**Author:** [@Firstname\_Lastname](https://discourse.julialang.org/u/Firstname_Lastname)\
**Replies:** 2\
**Last updated:** [August 19, 2022, 8:24am UTC](https://discourse.julialang.org/t/change-the-color-of-shaded-area-in-plotting-uncertain-quantity-in-montecarlomeasurements-jl/85956 "2022-08-19T08:24:29Z")

</div>

From the following code using MonteCarloMeasurements, Plots x = LinRange(1:0.1:3) a = 1 \\pm 0.1 b = 2 \\pm 0.3 f(x) = a\*x + b plot(x, f.(x)) I obtained a plot with shaded area in light blue. How can I change this co…

---

## [Performance of collections with Functions as abstract type](https://discourse.julialang.org/t/performance-of-collections-with-functions-as-abstract-type/85929)

<div class="topic-metadata">

**Author:** [@RGon](https://discourse.julialang.org/u/RGon)\
**Replies:** 6\
**Last updated:** [August 18, 2022, 9:48pm UTC](https://discourse.julialang.org/t/performance-of-collections-with-functions-as-abstract-type/85929 "2022-08-18T21:48:11Z")

</div>

I know from the docs I should avoid containers with abstract types, however I am running into a couple of use cases where I have tag calculation objects with arbitrary functions. Base.@kwdef struct TagCalculation{T\<:Fun…

---

## [Processus stop for large array of images](https://discourse.julialang.org/t/processus-stop-for-large-array-of-images/85921)

<div class="topic-metadata">

**Author:** [@musard0](https://discourse.julialang.org/u/musard0)\
**Replies:** 2\
**Last updated:** [August 18, 2022, 5:29pm UTC](https://discourse.julialang.org/t/processus-stop-for-large-array-of-images/85921 "2022-08-18T17:29:14Z")

</div>

Hello, here is my code : using Images function listOfImg(img::Array{Gray{Normed{UInt8,8}},2}) lengthImgSplit = 1000 nbImgToSave = 3000 imgSplit = similar(img, size(img, 1), lengthImgSplit) listOfImg = Array{typeof(i…

---

## [Assert type instability](https://discourse.julialang.org/t/assert-type-instability/85840)

<div class="topic-metadata">

**Author:** [@Joao\_Barata](https://discourse.julialang.org/u/Joao_Barata)\
**Replies:** 5\
**Last updated:** [August 16, 2022, 7:33pm UTC](https://discourse.julialang.org/t/assert-type-instability/85840 "2022-08-16T19:33:57Z")

</div>

Hi guys Simple question. Take the function below function bogus(n::Int) @assert n \> 1 end If I do @code\_warntype on this function, I get Arguments #self#::Core.Const(bogus) n::Int64 Body::Nothing 1 ─ %1 = (n…

---

## [Is it possible to traverse a tree without allocations](https://discourse.julialang.org/t/is-it-possible-to-traverse-a-tree-without-allocations/85490)

<div class="topic-metadata">

**Author:** [@peremato](https://discourse.julialang.org/u/peremato)\
**Replies:** 10\
**Last updated:** [August 15, 2022, 1:51pm UTC](https://discourse.julialang.org/t/is-it-possible-to-traverse-a-tree-without-allocations/85490 "2022-08-15T13:51:02Z")

</div>

I have defined a tree made of ‘nodes’ and ‘leaves’ as follows. Each leaf has a vector of indices that I would like to iterate under certain conditions. using AbstractTrees struct BVH name::String children::Unio…

---

## [Speeding up a sum involving 3 matrices](https://discourse.julialang.org/t/speeding-up-a-sum-involving-3-matrices/85713)

<div class="topic-metadata">

**Author:** [@structural](https://discourse.julialang.org/u/structural)\
**Replies:** 4\
**Last updated:** [August 14, 2022, 10:41pm UTC](https://discourse.julialang.org/t/speeding-up-a-sum-involving-3-matrices/85713 "2022-08-14T22:41:18Z")

</div>

Thanks for your answers. It made a 20x improvement in my overall computation time. May I get your help with another related task? I need to compute a 10,000+ row vector in which the i^{th} row is \\sum\_{jk} x^{}\_{ij}z^{}…

---

## [What is "JRUN\_CLUSTER\_COOKIE" error from initialisecluster() (JuliaRunClient)](https://discourse.julialang.org/t/what-is-jrun-cluster-cookie-error-from-initialisecluster-juliarunclient/85651)

<div class="topic-metadata">

**Author:** [@le\_ackerman](https://discourse.julialang.org/u/le_ackerman)\
**Replies:** 7\
**Last updated:** [August 12, 2022, 2:33pm UTC](https://discourse.julialang.org/t/what-is-jrun-cluster-cookie-error-from-initialisecluster-juliarunclient/85651 "2022-08-12T14:33:08Z")

</div>

I was going through tutorial notebooks on parallelisations and encountered this. What does this mean? the same error is for initParallel() also.

---

## [Help to analyze SnoopCompile results. What happens during \`boot.jl\`?](https://discourse.julialang.org/t/help-to-analyze-snoopcompile-results-what-happens-during-boot-jl/85633)

<div class="topic-metadata">

**Author:** [@guilhermebodin](https://discourse.julialang.org/u/guilhermebodin)\
**Replies:** 2\
**Last updated:** [August 11, 2022, 7:15pm UTC](https://discourse.julialang.org/t/help-to-analyze-snoopcompile-results-what-happens-during-boot-jl/85633 "2022-08-11T19:15:41Z")

</div>

Hello all! I have followed the tutorials on SnoopCompile about invalidation and inference and I still have a big question, in my case I have some parts of the code that trigger type inferences and I am working on fixing…

---

## [@threads - machine stops using allocated cores during run](https://discourse.julialang.org/t/threads-machine-stops-using-allocated-cores-during-run/85330)

<div class="topic-metadata">

**Author:** [@mrVeng](https://discourse.julialang.org/u/mrVeng)\
**Replies:** 4\
**Last updated:** [August 11, 2022, 12:39pm UTC](https://discourse.julialang.org/t/threads-machine-stops-using-allocated-cores-during-run/85330 "2022-08-11T12:39:35Z")

</div>

Dear all, I have a function in a function that I can run in parallel, and I am using the ‘@threads’ macro for that. Calling that outside function takes several hours, and, at the beginning, works as expected and all int…

---

## [Any faster way of computing small gradients?](https://discourse.julialang.org/t/any-faster-way-of-computing-small-gradients/85531)

<div class="topic-metadata">

**Author:** [@ForceBru](https://discourse.julialang.org/u/ForceBru)\
**Replies:** 21\
**Last updated:** [August 11, 2022, 7:21am UTC](https://discourse.julialang.org/t/any-faster-way-of-computing-small-gradients/85531 "2022-08-11T07:21:52Z")

</div>

I’ve tested multiple packages to compute the gradient of a log-likelihood (huge sum of the same function applied to different data points): const AV = AbstractVector{T} where T normal\_pdf(x::Real, mean::Real, var::Real…

---

## [Can we reuse Dictionary allocation?](https://discourse.julialang.org/t/can-we-reuse-dictionary-allocation/85582)

<div class="topic-metadata">

**Author:** [@CodeGodz](https://discourse.julialang.org/u/CodeGodz)\
**Replies:** 2\
**Last updated:** [August 10, 2022, 1:26pm UTC](https://discourse.julialang.org/t/can-we-reuse-dictionary-allocation/85582 "2022-08-10T13:26:22Z")

</div>

In our application we have to allocate over 20K dictionaries each having ~1M keys. Each of them is created in a for loop and since they are only used within the iteration garbage collection temporarily freezes the code w…

---

## [Optimizing matrix multiplication code and being compatible with autodiff](https://discourse.julialang.org/t/optimizing-matrix-multiplication-code-and-being-compatible-with-autodiff/85448)

<div class="topic-metadata">

**Author:** [@SebastianCallh](https://discourse.julialang.org/u/SebastianCallh)\
**Replies:** 6\
**Last updated:** [August 9, 2022, 7:42pm UTC](https://discourse.julialang.org/t/optimizing-matrix-multiplication-code-and-being-compatible-with-autodiff/85448 "2022-08-09T19:42:20Z")

</div>

I am trying to optimize some matrix multiplications inside a Turing model (a Kalman filter) but since I am depending on autodiff I can’t pre-allocate matrices and mutate things. How does one go about optimizing this type…

---

## [Broadcasting matrix-vector multiplication over specific axis for n-dimensional arrays](https://discourse.julialang.org/t/broadcasting-matrix-vector-multiplication-over-specific-axis-for-n-dimensional-arrays/85533)

<div class="topic-metadata">

**Author:** [@b-fg](https://discourse.julialang.org/u/b-fg)\
**Replies:** 3\
**Last updated:** [August 9, 2022, 2:58pm UTC](https://discourse.julialang.org/t/broadcasting-matrix-vector-multiplication-over-specific-axis-for-n-dimensional-arrays/85533 "2022-08-09T14:58:59Z")

</div>

I have a matrix-vector multiplication to fill axis=2 of my 3D array a (where basis is type Matrix): @inbounds for n ∈ 1:size(a, 1), s ∈ 1:size(a, 3) a\[n, :, s\] = @views basis \* b\[n, :, s\] end The question is how c…

---

## [Comparing exp() performance on Julia versus numpy](https://discourse.julialang.org/t/comparing-exp-performance-on-julia-versus-numpy/85325)

<div class="topic-metadata">

**Author:** [@torrance](https://discourse.julialang.org/u/torrance)\
**Replies:** 38\
**Last updated:** [August 8, 2022, 4:12pm UTC](https://discourse.julialang.org/t/comparing-exp-performance-on-julia-versus-numpy/85325 "2022-08-08T16:12:15Z")

</div>

So I was actually preparing a demo to show off Julia to colleagues when I encountered this issue. I want to simply compute the exponential of an array. In Julia (v. 1.7.2): arr = rand(100\_000) @benchmark exp.($arr) # …

---

## [Check type stability of a struct](https://discourse.julialang.org/t/check-type-stability-of-a-struct/85343)

<div class="topic-metadata">

**Author:** [@filchristou](https://discourse.julialang.org/u/filchristou)\
**Replies:** 5\
**Last updated:** [August 8, 2022, 2:28pm UTC](https://discourse.julialang.org/t/check-type-stability-of-a-struct/85343 "2022-08-08T14:28:45Z")

</div>

We usually speak of type stability for functions and we also have the tools to determine that (like @code\_warntype). But say I would like to check whether a struct is type-stable, in the sense that it is well defined an…

---

## [Performance of printing a type name](https://discourse.julialang.org/t/performance-of-printing-a-type-name/85468)

<div class="topic-metadata">

**Author:** [@ikirill](https://discourse.julialang.org/u/ikirill)\
**Replies:** 3\
**Last updated:** [August 8, 2022, 2:27pm UTC](https://discourse.julialang.org/t/performance-of-printing-a-type-name/85468 "2022-08-08T14:27:14Z")

</div>

Is this expected, or is this a bug? Printing Val(:hello\_world) is ~1000 times slower than printing :hello\_world, and I imagine this affects things like printing stack traces with complicated types. julia\> @benchmark str…

---

## [Startup without $HOME on AWS](https://discourse.julialang.org/t/startup-without-home-on-aws/85452)

<div class="topic-metadata">

**Author:** [@sparrowhawk](https://discourse.julialang.org/u/sparrowhawk)\
**Replies:** 1\
**Last updated:** [August 8, 2022, 1:39am UTC](https://discourse.julialang.org/t/startup-without-home-on-aws/85452 "2022-08-08T01:39:17Z")

</div>

Hi all, I’m trying to run Julia on Amazon Workspaces, where all users at our workshop can simply spin up Julia and VSCode on a virtual 8 core Windows 10 machine. However, every time I spin up a new workspace, the windows…

---

## [Parameter estimation of an ODE in Julia is slower than in R](https://discourse.julialang.org/t/parameter-estimation-of-an-ode-in-julia-is-slower-than-in-r/85114)

<div class="topic-metadata">

**Author:** [@laurar1891](https://discourse.julialang.org/u/laurar1891)\
**Replies:** 25\
**Last updated:** [August 7, 2022, 11:15pm UTC](https://discourse.julialang.org/t/parameter-estimation-of-an-ode-in-julia-is-slower-than-in-r/85114 "2022-08-07T23:15:04Z")

</div>

I’ve been trying to estimate parameters (using max likelihood) of an ODE using the DifferentialEquations and Optim packages in Julia aiming to get a faster convergence compared to R. Problem is that I still can do it fas…

---

## [Faster matrix product with a specifically structured matrix](https://discourse.julialang.org/t/faster-matrix-product-with-a-specifically-structured-matrix/67355)

<div class="topic-metadata">

**Author:** [@lrnv](https://discourse.julialang.org/u/lrnv)\
**Replies:** 26\
**Last updated:** [August 7, 2022, 8:47pm UTC](https://discourse.julialang.org/t/faster-matrix-product-with-a-specifically-structured-matrix/67355 "2022-08-07T20:47:56Z")

</div>

Hi, I have a sparse matrix P that turns out to have only equal values (or zeros) on each line: julia\> all(\[sum(unique(P\[i,:\]).!=0)\<=1 for i in 1:size(P,1)\]) true julia\> Where I used \<=1 since some lines are complete…

---

## [PackageCompiler: Do optimisation flags influence the produced sysimages?](https://discourse.julialang.org/t/packagecompiler-do-optimisation-flags-influence-the-produced-sysimages/47338)

<div class="topic-metadata">

**Author:** [@SteffenPL](https://discourse.julialang.org/u/SteffenPL)\
**Replies:** 0\
**Last updated:** [September 26, 2020, 9:07pm UTC](https://discourse.julialang.org/t/packagecompiler-do-optimisation-flags-influence-the-produced-sysimages/47338 "2020-09-26T21:07:34Z")

</div>

Is there a difference between julia -O3 -e "import PackageCompiler; PackageCompiler.create\_sysimage(...)" vs julia -e "import PackageCompiler; PackageCompiler.create\_sysimage(...)"? Are the produced sysimages the sa…

---

## [Type stability when using fields of structs](https://discourse.julialang.org/t/type-stability-when-using-fields-of-structs/85408)

<div class="topic-metadata">

**Author:** [@Jonas208](https://discourse.julialang.org/u/Jonas208)\
**Replies:** 12\
**Last updated:** [August 7, 2022, 12:43pm UTC](https://discourse.julialang.org/t/type-stability-when-using-fields-of-structs/85408 "2022-08-07T12:43:34Z")

</div>

I am trying to optimize a function which mainly operates on arrays that are (nearly all) fields of a given struct. Yet, the performance of the function is NOT really fast. My first idea was to check type stability and ty…

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

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