# Performance

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

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

**Page:** 128

---

## [Unexpected 4x slowdown when computing many svds in loop](https://discourse.julialang.org/t/unexpected-4x-slowdown-when-computing-many-svds-in-loop/27148)

<div class="topic-metadata">

**Author:** [@egcjm](https://discourse.julialang.org/u/egcjm)\
**Replies:** 4\
**Last updated:** [August 4, 2019, 4:01pm UTC](https://discourse.julialang.org/t/unexpected-4x-slowdown-when-computing-many-svds-in-loop/27148 "2019-08-04T16:01:06Z")

</div>

I compute svds of N roughly ~100x100 matrices and note a 4x slowdown when I do this in a loop for N \> 100. function f\_svd(n::Int64,a::Array{Float64,2}) for i in 1:n u,s,v = svd(a); end end (in my r…

---

## [Allocations in mapreduce/sum etc](https://discourse.julialang.org/t/allocations-in-mapreduce-sum-etc/27053)

<div class="topic-metadata">

**Author:** [@tchr](https://discourse.julialang.org/u/tchr)\
**Replies:** 2\
**Last updated:** [August 1, 2019, 4:11am UTC](https://discourse.julialang.org/t/allocations-in-mapreduce-sum-etc/27053 "2019-08-01T04:11:02Z")

</div>

I’m confused by why the following allocates (this is a reduced example that arose from trying to implement a function from #32739 via higher order functions instead of explicit loops): g(v) = mapreduce(i-\>v\[1\]\*i, +, eac…

---

## [How efficient is dictionary lookup in Julia?](https://discourse.julialang.org/t/how-efficient-is-dictionary-lookup-in-julia/26984)

<div class="topic-metadata">

**Author:** [@manuelma](https://discourse.julialang.org/u/manuelma)\
**Replies:** 6\
**Last updated:** [July 30, 2019, 11:32pm UTC](https://discourse.julialang.org/t/how-efficient-is-dictionary-lookup-in-julia/26984 "2019-07-30T23:32:24Z")

</div>

I have an application where I have to lookup keys in a dictionary several times, and depending on the particular case it could be that I lookup the same key hundreds of times. How much overhead should I expect? In Pytho…

---

## [What is the memory overhead of a mutable struct?](https://discourse.julialang.org/t/what-is-the-memory-overhead-of-a-mutable-struct/26963)

<div class="topic-metadata">

**Author:** [@Russ](https://discourse.julialang.org/u/Russ)\
**Replies:** 8\
**Last updated:** [July 30, 2019, 6:24pm UTC](https://discourse.julialang.org/t/what-is-the-memory-overhead-of-a-mutable-struct/26963 "2019-07-30T18:24:21Z")

</div>

I’m trying to figure out how much memory a mutable struct actually takes up. For example, in Java or C#, there’s a vptr and a syncroot/hash id, so the overhead is 8 or 16 bytes, depending on if it’s being run in 32 or 64…

---

## [Unusual slow Julia code compared to C++?](https://discourse.julialang.org/t/unusual-slow-julia-code-compared-to-c/22987)

<div class="topic-metadata">

**Author:** [@KestutisMa](https://discourse.julialang.org/u/KestutisMa)\
**Replies:** 21\
**Last updated:** [July 30, 2019, 4:03pm UTC](https://discourse.julialang.org/t/unusual-slow-julia-code-compared-to-c/22987 "2019-07-30T16:03:12Z")

</div>

Hello, We are investigating Gap Junctions channels in cells (during cardiac arrhythmia also propagation of excitation in neural networks). I am trying to implement our model in Julia, but first version ran about 10x sl…

---

## [Filling a preallocated array without allocations](https://discourse.julialang.org/t/filling-a-preallocated-array-without-allocations/26896)

<div class="topic-metadata">

**Author:** [@guilhermebodin](https://discourse.julialang.org/u/guilhermebodin)\
**Replies:** 7\
**Last updated:** [July 29, 2019, 6:05pm UTC](https://discourse.julialang.org/t/filling-a-preallocated-array-without-allocations/26896 "2019-07-29T18:05:28Z")

</div>

Hello, does anybody know if it is possible to fill a preallocated array without allocations? In other words, is there a way of performing this function loop without allocations mutable struct KF F::Array{Float64, 3…

---

## [Dot equals .=](https://discourse.julialang.org/t/dot-equals/26818)

<div class="topic-metadata">

**Author:** [@lewis](https://discourse.julialang.org/u/lewis)\
**Replies:** 3\
**Last updated:** [July 26, 2019, 10:57pm UTC](https://discourse.julialang.org/t/dot-equals/26818 "2019-07-26T22:57:15Z")

</div>

I am sort of getting fuzzy on how to apply syntactic loop fusion from More Dots - Syntactic Loop Fusion in Julia | juliabloggers.com Is this: nnp.theta\[hl\] .= nnp.theta\[hl\] .+ (hp.alphaovermb .\* (hp.lambda .\* nnp.theta…

---

## [Vector{Float} times Vector{Complex} slower than Vector{Complex} times Vector{Complex}](https://discourse.julialang.org/t/vector-float-times-vector-complex-slower-than-vector-complex-times-vector-complex/26857)

<div class="topic-metadata">

**Author:** [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Replies:** 6\
**Last updated:** [July 26, 2019, 6:41pm UTC](https://discourse.julialang.org/t/vector-float-times-vector-complex-slower-than-vector-complex-times-vector-complex/26857 "2019-07-26T18:41:59Z")

</div>

If you define Q = collect(-10:.01:10) v = Q.-transpose(Q) cv = complex.(v) comp = exp.(-im.\*Q) then multiplying cvcomp takes 2.94ms on my computer compared with 3.41ms for vcomp (times measured with btime) Any idea why…

---

## [How to access shared "inherited" fields without paying multiple dispatch performance price?](https://discourse.julialang.org/t/how-to-access-shared-inherited-fields-without-paying-multiple-dispatch-performance-price/26762)

<div class="topic-metadata">

**Author:** [@Russ](https://discourse.julialang.org/u/Russ)\
**Replies:** 14\
**Last updated:** [July 25, 2019, 9:46am UTC](https://discourse.julialang.org/t/how-to-access-shared-inherited-fields-without-paying-multiple-dispatch-performance-price/26762 "2019-07-25T09:46:23Z")

</div>

Hi, I’m evaluating Julia to replace some old C++ code. The code uses inheritance where there is a single base class and lots (100’s) of derived classes. There are a large number of instances, and the code needs to be abl…

---

## [How to use SIMD with a very simple example](https://discourse.julialang.org/t/how-to-use-simd-with-a-very-simple-example/26676)

<div class="topic-metadata">

**Author:** [@davidbp](https://discourse.julialang.org/u/davidbp)\
**Replies:** 6\
**Last updated:** [July 23, 2019, 5:05pm UTC](https://discourse.julialang.org/t/how-to-use-simd-with-a-very-simple-example/26676 "2019-07-23T17:05:53Z")

</div>

Hello, I am trying to understand how to use SIMD.jl. After trying the vadd! example in the documentation I wanted use SIMD in a different example. No success so far. This is what I would like to simdify: function myf…

---

## [Ways to make slow/sluggish REPL/interactive development experience faster?](https://discourse.julialang.org/t/ways-to-make-slow-sluggish-repl-interactive-development-experience-faster/25293)

<div class="topic-metadata">

**Author:** [@abe](https://discourse.julialang.org/u/abe)\
**Replies:** 35\
**Last updated:** [July 23, 2019, 11:56am UTC](https://discourse.julialang.org/t/ways-to-make-slow-sluggish-repl-interactive-development-experience-faster/25293 "2019-07-23T11:56:36Z")

</div>

New to Julia from R and so far very disappointed with the interactive experience. I get that compiles will take time, but it seems like everything is slow. I don’t get why something like “using mycoolpackage” or “add ano…

---

## [Split an Int128 to two Int64](https://discourse.julialang.org/t/split-an-int128-to-two-int64/26625)

<div class="topic-metadata">

**Author:** [@hros](https://discourse.julialang.org/u/hros)\
**Replies:** 2\
**Last updated:** [July 22, 2019, 12:31pm UTC](https://discourse.julialang.org/t/split-an-int128-to-two-int64/26625 "2019-07-22T12:31:46Z")

</div>

Edit: this post started as a question and as a I found an answer turned into a suggestion to update the documentation I have to multiply two Int64 values and split the result into the high and low 64 bit values. This i…

---

## [Puzzled by the difference in performance when summing an array in different ways](https://discourse.julialang.org/t/puzzled-by-the-difference-in-performance-when-summing-an-array-in-different-ways/26555)

<div class="topic-metadata">

**Author:** [@Nicolas\_Gagne](https://discourse.julialang.org/u/Nicolas_Gagne)\
**Replies:** 4\
**Last updated:** [July 19, 2019, 6:59pm UTC](https://discourse.julialang.org/t/puzzled-by-the-difference-in-performance-when-summing-an-array-in-different-ways/26555 "2019-07-19T18:59:12Z")

</div>

Hi everybody, While trying to test my understanding of “views vs slice of arrays” and “row-major vs column major”, I time (using @time) the following functions : A = rand(10000,10000); function sum\_1(x) counter = 0…

---

## [Fluctuations when measuring execution time of linear algebra code](https://discourse.julialang.org/t/fluctuations-when-measuring-execution-time-of-linear-algebra-code/26385)

<div class="topic-metadata">

**Author:** [@henrik227](https://discourse.julialang.org/u/henrik227)\
**Replies:** 12\
**Last updated:** [July 19, 2019, 2:07pm UTC](https://discourse.julialang.org/t/fluctuations-when-measuring-execution-time-of-linear-algebra-code/26385 "2019-07-19T14:07:08Z")

</div>

I’m trying to measure the execution time of linear algebra expressions, and I’m seeing strange patterns in the results. This is a MWE that reproduces this behavior for me: using DelimitedFiles using LinearAlgebra BLAS.s…

---

## [Indexing multidimensional arrays of arbitrary dimension](https://discourse.julialang.org/t/indexing-multidimensional-arrays-of-arbitrary-dimension/25728)

<div class="topic-metadata">

**Author:** [@hrchen](https://discourse.julialang.org/u/hrchen)\
**Replies:** 11\
**Last updated:** [June 26, 2019, 9:00pm UTC](https://discourse.julialang.org/t/indexing-multidimensional-arrays-of-arbitrary-dimension/25728 "2019-06-26T21:00:57Z")

</div>

I am writing a simulation that outputs a multidimensional array A that changes over time, and whose ndims depends on the input dimension (1 or 2 for now). I would like to save A over time in a larger array A\_t in my for-…

---

## [Bad performance using DistributedArray SPMD for 1D diffusion problem](https://discourse.julialang.org/t/bad-performance-using-distributedarray-spmd-for-1d-diffusion-problem/26443)

<div class="topic-metadata">

**Author:** [@henry2004y](https://discourse.julialang.org/u/henry2004y)\
**Replies:** 2\
**Last updated:** [July 18, 2019, 9:12pm UTC](https://discourse.julialang.org/t/bad-performance-using-distributedarray-spmd-for-1d-diffusion-problem/26443 "2019-07-18T21:12:50Z")

</div>

Hi all, I am writing my first parallel program in Julia 1.1 using the SPMD feature in the DistributedArray package. However, I am nowhere closer to the serial performance, and the parallel scaling is not good neither. …

---

## [Modules VS Passing arguments to functions](https://discourse.julialang.org/t/modules-vs-passing-arguments-to-functions/26477)

<div class="topic-metadata">

**Author:** [@tiago](https://discourse.julialang.org/u/tiago)\
**Replies:** 5\
**Last updated:** [July 18, 2019, 11:03am UTC](https://discourse.julialang.org/t/modules-vs-passing-arguments-to-functions/26477 "2019-07-18T11:03:39Z")

</div>

Hello, I developed a numerical solver for a certain PDE. In these situations it’s quite normal to test the algorithm with several different examples and have many parameters, arrays and anonymous functions that I must …

---

## [New behaviour due to an update of the package CSV when using CSV.write](https://discourse.julialang.org/t/new-behaviour-due-to-an-update-of-the-package-csv-when-using-csv-write/26442)

<div class="topic-metadata">

**Author:** [@steph\_de\_paris](https://discourse.julialang.org/u/steph_de_paris)\
**Replies:** 7\
**Last updated:** [July 17, 2019, 1:02pm UTC](https://discourse.julialang.org/t/new-behaviour-due-to-an-update-of-the-package-csv-when-using-csv-write/26442 "2019-07-17T13:02:29Z")

</div>

Hello, When I use the code using CSV using DataFrames rm("tmp.csv",force=true) df=DataFrame(\[Float64 for k in 1:1\],\[Symbol("ps\_prev\_$k") for k in 1:1\],0); push!(df,1000.0) CSV.write("tmp.csv",df,delim=';', append=true,…

---

## [Strange allocation](https://discourse.julialang.org/t/strange-allocation/26462)

<div class="topic-metadata">

**Author:** [@TheBB](https://discourse.julialang.org/u/TheBB)\
**Replies:** 2\
**Last updated:** [July 17, 2019, 3:31pm UTC](https://discourse.julialang.org/t/strange-allocation/26462 "2019-07-17T15:31:37Z")

</div>

I’m writing a type to represent an affine transformation (y=Ax+b), using static arrays. Here’s the code using BenchmarkTools using StaticArrays struct Affine{F, T, R} matrix :: SMatrix{T, F, R} vector :: SVecto…

---

## [Unusually bad performance of eigen() compared to eig() in Matlab](https://discourse.julialang.org/t/unusually-bad-performance-of-eigen-compared-to-eig-in-matlab/26433)

<div class="topic-metadata">

**Author:** [@doit](https://discourse.julialang.org/u/doit)\
**Replies:** 16\
**Last updated:** [July 17, 2019, 11:19am UTC](https://discourse.julialang.org/t/unusually-bad-performance-of-eigen-compared-to-eig-in-matlab/26433 "2019-07-17T11:19:35Z")

</div>

Hello everyone, I’m fairly new to Julia. I am working on implementing SBFEM in Julia. SBFEM requires solving a lot of eigenvalue problems. I noticed that my code in Matlab is running much (much) faster than in Julia. I …

---

## [Speed of dispatch with heterogeneous functions and types](https://discourse.julialang.org/t/speed-of-dispatch-with-heterogeneous-functions-and-types/26282)

<div class="topic-metadata">

**Author:** [@mhinsch](https://discourse.julialang.org/u/mhinsch)\
**Replies:** 10\
**Last updated:** [July 16, 2019, 10:57am UTC](https://discourse.julialang.org/t/speed-of-dispatch-with-heterogeneous-functions-and-types/26282 "2019-07-16T10:57:51Z")

</div>

I am planning to implement a continuous-time version of a discrete-time agent-based simulation (see https://github.com/mhinsch/RRGraphs). That means there will be some sort of central scheduler that handles dispatch of a…

---

## [Seemingly unnecessary code cruft in a compiled higher-order function](https://discourse.julialang.org/t/seemingly-unnecessary-code-cruft-in-a-compiled-higher-order-function/26357)

<div class="topic-metadata">

**Author:** [@xor0110](https://discourse.julialang.org/u/xor0110)\
**Replies:** 9\
**Last updated:** [July 15, 2019, 3:08pm UTC](https://discourse.julialang.org/t/seemingly-unnecessary-code-cruft-in-a-compiled-higher-order-function/26357 "2019-07-15T15:08:53Z")

</div>

Read this post if you care about zero-cost abstractions. This is a test of Julia’s ability to produce highly optimized code for higher-order functions, taking a function as an argument. The two functions are equivalent,…

---

## [Dispatch on Value allocating](https://discourse.julialang.org/t/dispatch-on-value-allocating/26337)

<div class="topic-metadata">

**Author:** [@cshenton](https://discourse.julialang.org/u/cshenton)\
**Replies:** 9\
**Last updated:** [July 14, 2019, 9:58pm UTC](https://discourse.julialang.org/t/dispatch-on-value-allocating/26337 "2019-07-14T21:58:57Z")

</div>

I want to provide a function that will value dispatch on a handful of int values (3,4,5). That works fine, but when I wrap that function so that the caller doesn’t have to put in Val(3) when calling there are allocations…

---

## [How to use minimum and maximum for a Vector{SVector{3}}](https://discourse.julialang.org/t/how-to-use-minimum-and-maximum-for-a-vector-svector-3/26235)

<div class="topic-metadata">

**Author:** [@CFBaptista](https://discourse.julialang.org/u/CFBaptista)\
**Replies:** 6\
**Last updated:** [July 12, 2019, 2:04pm UTC](https://discourse.julialang.org/t/how-to-use-minimum-and-maximum-for-a-vector-svector-3/26235 "2019-07-12T14:04:21Z")

</div>

If I want to determine the smallest values in the rows of A::Matrix it’s as easy as: min = minimum(A, dims=2) However, if I have a Vector of SVector{3}'s it’s a bit more complicated. This using StaticArrays function …

---

## [Improving performance due to setting types of the fields of a struct](https://discourse.julialang.org/t/improving-performance-due-to-setting-types-of-the-fields-of-a-struct/24965)

<div class="topic-metadata">

**Author:** [@Volker](https://discourse.julialang.org/u/Volker)\
**Replies:** 10\
**Last updated:** [July 12, 2019, 8:03am UTC](https://discourse.julialang.org/t/improving-performance-due-to-setting-types-of-the-fields-of-a-struct/24965 "2019-07-12T08:03:49Z")

</div>

Hi, I have a question about improving the performance of Julia. In the Julia documentation is something explained about setting types of a structs. " You can do better by declaring the type of a . Here, we are focused…

---

## [Make first call faster](https://discourse.julialang.org/t/make-first-call-faster/22845)

<div class="topic-metadata">

**Author:** [@KestutisMa](https://discourse.julialang.org/u/KestutisMa)\
**Replies:** 6\
**Last updated:** [July 12, 2019, 7:53am UTC](https://discourse.julialang.org/t/make-first-call-faster/22845 "2019-07-12T07:53:24Z")

</div>

Hello, I just started using Julia, I noticed that commands using Plotly plot(rand(10)) perform slowly ~30s in first run, but faster ~2s in second run. Could it be possible to cache that process to make it fast after …

---

## [How to improve compilation time and loading time of packages?](https://discourse.julialang.org/t/how-to-improve-compilation-time-and-loading-time-of-packages/26183)

<div class="topic-metadata">

**Author:** [@tencnivel](https://discourse.julialang.org/u/tencnivel)\
**Replies:** 8\
**Last updated:** [July 10, 2019, 11:48am UTC](https://discourse.julialang.org/t/how-to-improve-compilation-time-and-loading-time-of-packages/26183 "2019-07-10T11:48:27Z")

</div>

EDIT: I was mistaking the compilation time of the utiity package with its loading. See message below: https://discourse.julialang.org/t/how-to-improve-compilation-time-and-loading-time-of-packages/26183/7 Original post…

---

## [Constant type but changing value](https://discourse.julialang.org/t/constant-type-but-changing-value/26125)

<div class="topic-metadata">

**Author:** [@Paul\_McVay](https://discourse.julialang.org/u/Paul_McVay)\
**Replies:** 5\
**Last updated:** [July 9, 2019, 11:42am UTC](https://discourse.julialang.org/t/constant-type-but-changing-value/26125 "2019-07-09T11:42:01Z")

</div>

Is it possible to create a constant type but changing value variable? For example, I would like to create a max variable and a call to a function increments the max value and returns the new max. The max variable needs t…

---

## [A reverse! for CuArrays and Nd arrays](https://discourse.julialang.org/t/a-reverse-for-cuarrays-and-nd-arrays/24731)

<div class="topic-metadata">

**Author:** [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Replies:** 6\
**Last updated:** [July 8, 2019, 9:06am UTC](https://discourse.julialang.org/t/a-reverse-for-cuarrays-and-nd-arrays/24731 "2019-07-08T09:06:12Z")

</div>

Dear All, I have a 3d array V = zeros(N,N,N) and I would like to reverse it with respect to the last component. I achieve this by using the following function. This works well using CuArray (on master, see link) for A b…

---

## [Strange allocations with default positional argument and static arrays](https://discourse.julialang.org/t/strange-allocations-with-default-positional-argument-and-static-arrays/26069)

<div class="topic-metadata">

**Author:** [@pkofod](https://discourse.julialang.org/u/pkofod)\
**Replies:** 6\
**Last updated:** [July 7, 2019, 11:39am UTC](https://discourse.julialang.org/t/strange-allocations-with-default-positional-argument-and-static-arrays/26069 "2019-07-07T11:39:50Z")

</div>

I am wondering why the second and third version allocates. What am I missing here? \_ \_ \_ \_(\_)\_ | Documentation: https://docs.julialang.org (\_) | (\_) (\_) | \_ \_ \_| |\_ \_\_ \_ | …

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

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