# Performance

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

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

**Page:** 144

---

## [Construct large sparse matrix by blocks](https://discourse.julialang.org/t/construct-large-sparse-matrix-by-blocks/10034)

<div class="topic-metadata">

**Author:** [@WenlongGong](https://discourse.julialang.org/u/WenlongGong)\
**Replies:** 4\
**Last updated:** [March 28, 2018, 8:59pm UTC](https://discourse.julialang.org/t/construct-large-sparse-matrix-by-blocks/10034 "2018-03-28T20:59:53Z")

</div>

I’m looking for a function to construct a sparse matrix based on several blocks of smaller sparse matrices. An simple example: A11=A12=A21=A22=sprandn(4,2,0.6) The final sparse matrix A should be a combination of thes…

---

## [Inference and speeding in an interpolation](https://discourse.julialang.org/t/inference-and-speeding-in-an-interpolation/10027)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 8\
**Last updated:** [March 28, 2018, 11:40am UTC](https://discourse.julialang.org/t/inference-and-speeding-in-an-interpolation/10027 "2018-03-28T11:40:18Z")

</div>

Out of convenience I’m wrapping a scaled interpolation from Interpolations.jl: grid\_x = 0:0.1:100.0 grid\_y = 0:0.1:100.0 f(x, y) = (x + y)^2 farr = \[f(x, y) for x in grid\_x, y in grid\_y\] using Interpolations functio…

---

## [Innefficient paralellization? Need some help optimizing a simple dot product](https://discourse.julialang.org/t/innefficient-paralellization-need-some-help-optimizing-a-simple-dot-product/9723)

<div class="topic-metadata">

**Author:** [@cdacosta](https://discourse.julialang.org/u/cdacosta)\
**Replies:** 32\
**Last updated:** [March 28, 2018, 7:23am UTC](https://discourse.julialang.org/t/innefficient-paralellization-need-some-help-optimizing-a-simple-dot-product/9723 "2018-03-28T07:23:06Z")

</div>

I have a very simple code I’d like to optimize, and I’m not sure I am getting the expected results. For the sake of simplicity I am optimizing a loop which computes the dot product. I have implemented two functions, a se…

---

## [Performance degradation after upgrading from 0.5.1 to 0.6.2 -- how to avoid memory allocation?](https://discourse.julialang.org/t/performance-degradation-after-upgrading-from-0-5-1-to-0-6-2-how-to-avoid-memory-allocation/9971)

<div class="topic-metadata">

**Author:** [@jinliangwei](https://discourse.julialang.org/u/jinliangwei)\
**Replies:** 9\
**Last updated:** [March 26, 2018, 9:33am UTC](https://discourse.julialang.org/t/performance-degradation-after-upgrading-from-0-5-1-to-0-6-2-how-to-avoid-memory-allocation/9971 "2018-03-26T09:33:05Z")

</div>

for rating in ratings x\_idx = rating\[1\] + 1 y\_idx = rating\[2\] + 1 rv = rating\[3\] W\_row = W\[:, x\_idx\] H\_row = H\[:, y\_idx\] pred = dot(W\_row, H\_row) diff = rv - pred W\_grad = -2 \* diff …

---

## [Large memory footprint using type dispatch within a loop](https://discourse.julialang.org/t/large-memory-footprint-using-type-dispatch-within-a-loop/9974)

<div class="topic-metadata">

**Author:** [@phrmoy](https://discourse.julialang.org/u/phrmoy)\
**Replies:** 7\
**Last updated:** [March 25, 2018, 11:50pm UTC](https://discourse.julialang.org/t/large-memory-footprint-using-type-dispatch-within-a-loop/9974 "2018-03-25T23:50:58Z")

</div>

Hi there, I am new to Julia and very excited about it. One of the things I have been excited about (other than performance) is the multiple dispatch. So I figured I would eliminate many of jammed zillion of if-else sta…

---

## [@time vs @btime](https://discourse.julialang.org/t/time-vs-btime/9879)

<div class="topic-metadata">

**Author:** [@leoc](https://discourse.julialang.org/u/leoc)\
**Replies:** 5\
**Last updated:** [March 22, 2018, 12:10pm UTC](https://discourse.julialang.org/t/time-vs-btime/9879 "2018-03-22T12:10:31Z")

</div>

Hi all, I know that @btime is better than builtin @time because latest compute some overhead. But in my scenario most of my code is computed only once, and I have to take into account this overhead. Also forcing @btime …

---

## [Can't figure out why these allocations are happening](https://discourse.julialang.org/t/cant-figure-out-why-these-allocations-are-happening/9850)

<div class="topic-metadata">

**Author:** [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Replies:** 4\
**Last updated:** [March 21, 2018, 12:18am UTC](https://discourse.julialang.org/t/cant-figure-out-why-these-allocations-are-happening/9850 "2018-03-21T00:18:46Z")

</div>

I can’t figure out why allocations are happening when that should simply destructively update zsum. Here’s the relevant portions of the allocated trace: 0 i = j 0 while i \<= nsync 185614…

---

## [Have a time issue, need advises on my parallel code](https://discourse.julialang.org/t/have-a-time-issue-need-advises-on-my-parallel-code/9686)

<div class="topic-metadata">

**Author:** [@ersoacc](https://discourse.julialang.org/u/ersoacc)\
**Replies:** 10\
**Last updated:** [March 20, 2018, 7:50am UTC](https://discourse.julialang.org/t/have-a-time-issue-need-advises-on-my-parallel-code/9686 "2018-03-20T07:50:35Z")

</div>

Hello everyone. I am working on a computation fluid dynamics code which needs to solve some subdomains parallel defined in function ASPINS1Sub. To do this, I wrote the code given below which consists of many if stateme…

---

## [Understanding generated assembly for simple loop](https://discourse.julialang.org/t/understanding-generated-assembly-for-simple-loop/9698)

<div class="topic-metadata">

**Author:** [@Bernard\_GODARD](https://discourse.julialang.org/u/Bernard_GODARD)\
**Replies:** 14\
**Last updated:** [March 19, 2018, 6:37pm UTC](https://discourse.julialang.org/t/understanding-generated-assembly-for-simple-loop/9698 "2018-03-19T18:37:18Z")

</div>

I am trying to understand how simple julia functions are converted into assembly. In this case, I am interested in summing the integer serie up to some argument: function foo(n) res = zero(n) …

---

## [Nested pmap() functions don not work as I expect](https://discourse.julialang.org/t/nested-pmap-functions-don-not-work-as-i-expect/9789)

<div class="topic-metadata">

**Author:** [@ersoacc](https://discourse.julialang.org/u/ersoacc)\
**Replies:** 3\
**Last updated:** [March 19, 2018, 12:36pm UTC](https://discourse.julialang.org/t/nested-pmap-functions-don-not-work-as-i-expect/9789 "2018-03-19T12:36:45Z")

</div>

Hello everyone. I am using pmap function to calculate and sum a function with different arguments such as: function gparal(nsubs) Gs = pmap(i -\> ASPINS1Sub(i, ...), 1:nsubs) return sum(G…

---

## [Array performance Julia 0.6 vs 0.5](https://discourse.julialang.org/t/array-performance-julia-0-6-vs-0-5/9796)

<div class="topic-metadata">

**Author:** [@leoc](https://discourse.julialang.org/u/leoc)\
**Replies:** 11\
**Last updated:** [March 19, 2018, 7:54am UTC](https://discourse.julialang.org/t/array-performance-julia-0-6-vs-0-5/9796 "2018-03-19T07:54:48Z")

</div>

Hello, a simple test return strange results … I’ve placed in a file speed05vs06.jl following code: function speedtest() a = \[1:10...\] b = 2\*a + 1 @show a @show b if (VERSION \< v"0.6.0") @time v = (a .\< 7) & (…

---

## [Writing an array too large to store in memory](https://discourse.julialang.org/t/writing-an-array-too-large-to-store-in-memory/9752)

<div class="topic-metadata">

**Author:** [@dsweber2](https://discourse.julialang.org/u/dsweber2)\
**Replies:** 2\
**Last updated:** [March 16, 2018, 12:53pm UTC](https://discourse.julialang.org/t/writing-an-array-too-large-to-store-in-memory/9752 "2018-03-16T12:53:30Z")

</div>

I am transforming a dataset, and the process of transforming it both takes a long time and takes up a large amount of memory. I really only need a single row of the matrix in memory at any given time, so is there some ef…

---

## [svdvals is alarmingly slow](https://discourse.julialang.org/t/svdvals-is-alarmingly-slow/9259)

<div class="topic-metadata">

**Author:** [@tobydriscoll](https://discourse.julialang.org/u/tobydriscoll)\
**Replies:** 31\
**Last updated:** [March 15, 2018, 1:04am UTC](https://discourse.julialang.org/t/svdvals-is-alarmingly-slow/9259 "2018-03-15T01:04:03Z")

</div>

Straightforward use of svdvals on a freshly restarted Julia session: using BenchmarkTools B=randn(100,100); @btime svdvals($B); versioninfo() Here’s the result. 10.423 ms (11 allocations: 138.20 KiB) Julia Version …

---

## [Poor time performance on Dict?](https://discourse.julialang.org/t/poor-time-performance-on-dict/9656)

<div class="topic-metadata">

**Author:** [@phrmoy](https://discourse.julialang.org/u/phrmoy)\
**Replies:** 26\
**Last updated:** [March 12, 2018, 3:35pm UTC](https://discourse.julialang.org/t/poor-time-performance-on-dict/9656 "2018-03-12T15:35:42Z")

</div>

So I conducted a very simple run-time test for both Array and Dict. And here are the results of the very simple test: Now, it was clear to me before the test that the allocated Array was going to be much faster. But t…

---

## [Making type stable code](https://discourse.julialang.org/t/making-type-stable-code/9610)

<div class="topic-metadata">

**Author:** [@davidavdav](https://discourse.julialang.org/u/davidavdav)\
**Replies:** 6\
**Last updated:** [March 12, 2018, 8:10am UTC](https://discourse.julialang.org/t/making-type-stable-code/9610 "2018-03-12T08:10:18Z")

</div>

Hello, I am struggling with making NamedArrays more type stable. I need to implement getindex() for the same range of slices that AbstractArray can handle. For the backing array that NamedArrays wraps, this is easy. …

---

## [Performance degradation of \`fill\` in latest Julia 0.7 Dev?](https://discourse.julialang.org/t/performance-degradation-of-fill-in-latest-julia-0-7-dev/9648)

<div class="topic-metadata">

**Author:** [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Replies:** 2\
**Last updated:** [March 11, 2018, 9:16pm UTC](https://discourse.julialang.org/t/performance-degradation-of-fill-in-latest-julia-0-7-dev/9648 "2018-03-11T21:16:25Z")

</div>

I’m not sure if this has already been observed by someone, but I searched and didn’t find anything. The performance of fill is very slow in 0.7 in comparison to 0.6.2 or an explicit loop. The following results are from 0…

---

## [3 different ways to create an array have different performance](https://discourse.julialang.org/t/3-different-ways-to-create-an-array-have-different-performance/9636)

<div class="topic-metadata">

**Author:** [@affans](https://discourse.julialang.org/u/affans)\
**Replies:** 1\
**Last updated:** [March 10, 2018, 8:36pm UTC](https://discourse.julialang.org/t/3-different-ways-to-create-an-array-have-different-performance/9636 "2018-03-10T20:36:36Z")

</div>

I am creating an array of size 100 using three different methods. But I don’t understand why the @time results are different between them. Here is the code Main\> @time dpc = \[Int(round(rand(PP\_DD))) for i=1:100\]; 0.0…

---

## [Evaluation of the error term in Stirling's formula for factorial](https://discourse.julialang.org/t/evaluation-of-the-error-term-in-stirlings-formula-for-factorial/9542)

<div class="topic-metadata">

**Author:** [@dmbates](https://discourse.julialang.org/u/dmbates)\
**Replies:** 4\
**Last updated:** [March 7, 2018, 2:28pm UTC](https://discourse.julialang.org/t/evaluation-of-the-error-term-in-stirlings-formula-for-factorial/9542 "2018-03-07T14:28:17Z")

</div>

Pull request #33 on the StatsFuns package provides a link to Catherine Loader’s note on evaluating the binomial and Poisson probability mass function. One central part to this is evaluating the error in Stirling’s appro…

---

## [When will a function specialize on types?](https://discourse.julialang.org/t/when-will-a-function-specialize-on-types/9534)

<div class="topic-metadata">

**Author:** [@jamii](https://discourse.julialang.org/u/jamii)\
**Replies:** 1\
**Last updated:** [March 6, 2018, 12:50pm UTC](https://discourse.julialang.org/t/when-will-a-function-specialize-on-types/9534 "2018-03-06T12:50:57Z")

</div>

Is there any documentation on what type a function will specialize on? My mental model was that it only depended on the types of the arguments, not on the method signature, but I ran into this counter-example: julia\> @n…

---

## [Maximum!(v, A) is slower than own implementation?](https://discourse.julialang.org/t/maximum-v-a-is-slower-than-own-implementation/9512)

<div class="topic-metadata">

**Author:** [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Replies:** 2\
**Last updated:** [March 5, 2018, 5:37pm UTC](https://discourse.julialang.org/t/maximum-v-a-is-slower-than-own-implementation/9512 "2018-03-05T17:37:23Z")

</div>

I noticed that maximum!(v, A) is slower than my following implementation, I couldn’t find its implementation in Base to check my self. function maximum2!(out,A) @inbounds for i = 1:length(out) out\[i\] = A\[i\] end …

---

## [Best approach for runtime dispatching inside a hot loop (heterogeneous tree structure)](https://discourse.julialang.org/t/best-approach-for-runtime-dispatching-inside-a-hot-loop-heterogeneous-tree-structure/9442)

<div class="topic-metadata">

**Author:** [@AleMorales](https://discourse.julialang.org/u/AleMorales)\
**Replies:** 18\
**Last updated:** [March 3, 2018, 10:46pm UTC](https://discourse.julialang.org/t/best-approach-for-runtime-dispatching-inside-a-hot-loop-heterogeneous-tree-structure/9442 "2018-03-03T22:46:17Z")

</div>

I am in the process of writing a ray tracing algorithm in Julia (not related to 3D rendering, but for physical simulations). The code is too complex and I have not been able to make a good MWE, but I will try to describe…

---

## [Why Julia is fast in interpreter but slow when dealing with files ](https://discourse.julialang.org/t/why-julia-is-fast-in-interpreter-but-slow-when-dealing-with-files/9385)

<div class="topic-metadata">

**Author:** [@arnuld](https://discourse.julialang.org/u/arnuld)\
**Replies:** 11\
**Last updated:** [March 1, 2018, 8:49pm UTC](https://discourse.julialang.org/t/why-julia-is-fast-in-interpreter-but-slow-when-dealing-with-files/9385 "2018-03-01T20:49:11Z")

</div>

I have this program written in a file: using HTTP using JSON function pingserver() const addr = "http://localhost:4212/" const bdata = """{"type":"PING"}""" res = HTTP.post(addr, body=bdata) println(St…

---

## [Adding \`@time\` to a function gets rid of type-instability and makes code run 6x fast?!](https://discourse.julialang.org/t/adding-time-to-a-function-gets-rid-of-type-instability-and-makes-code-run-6x-fast/9413)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 7\
**Last updated:** [March 1, 2018, 12:46pm UTC](https://discourse.julialang.org/t/adding-time-to-a-function-gets-rid-of-type-instability-and-makes-code-run-6x-fast/9413 "2018-03-01T12:46:43Z")

</div>

I am developing a function and I find it hard to boil down to MWE. But the weird thing is the function runs in about 13 seconds, so I try to @time various part of the program and the code runs in 2 seconds. There is not…

---

## [Parallelizing for loop in the computation of a gradient](https://discourse.julialang.org/t/parallelizing-for-loop-in-the-computation-of-a-gradient/9154)

<div class="topic-metadata">

**Author:** [@kmundnic](https://discourse.julialang.org/u/kmundnic)\
**Replies:** 19\
**Last updated:** [February 26, 2018, 1:06am UTC](https://discourse.julialang.org/t/parallelizing-for-loop-in-the-computation-of-a-gradient/9154 "2018-02-26T01:06:43Z")

</div>

I’ve ported some code from a Cython implementation that may be found here into Julia. This code is parallelized and currently runs ~0.4x faster on my machine compared to my best Julia implementation. The function that i…

---

## [How to lazily \`collect(zip(fn(a), b))\` for some function \`fn\`?](https://discourse.julialang.org/t/how-to-lazily-collect-zip-fn-a-b-for-some-function-fn/9244)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 2\
**Last updated:** [February 22, 2018, 10:51am UTC](https://discourse.julialang.org/t/how-to-lazily-collect-zip-fn-a-b-for-some-function-fn/9244 "2018-02-22T10:51:36Z")

</div>

I want to lazily collect a zip iterator. See MWE below where I applied pointer. to a before using a zip and collect, but pointer.(a) allocated a new vector, so I don’t want that. Is there a way to lazily do pointer.(a) s…

---

## [Normalizing the columns of an SMatrix](https://discourse.julialang.org/t/normalizing-the-columns-of-an-smatrix/9160)

<div class="topic-metadata">

**Author:** [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Replies:** 4\
**Last updated:** [February 19, 2018, 11:21pm UTC](https://discourse.julialang.org/t/normalizing-the-columns-of-an-smatrix/9160 "2018-02-19T23:21:58Z")

</div>

I have an SMatrix of dimension (D, k). What I want to do is to normalize each column of this matrix, as if they were individual vectors. What I do at the moment is always carry around with me a Vector\[SVector\], and do: …

---

## [Improve performance of function that produces and hcats SMatrices](https://discourse.julialang.org/t/improve-performance-of-function-that-produces-and-hcats-smatrices/9140)

<div class="topic-metadata">

**Author:** [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Replies:** 3\
**Last updated:** [February 18, 2018, 11:23am UTC](https://discourse.julialang.org/t/improve-performance-of-function-that-produces-and-hcats-smatrices/9140 "2018-02-18T11:23:00Z")

</div>

I have two functions, which for our MWE could be the following: using BenchmarkTools, StaticArrays @inline function f(x, p, n) @inbounds x1, x2, x3 = x\[1\], x\[2\], x\[3\] SVector( 3.8\*x1\*(1-x1) - 0.05\*(x2+0.35)\*(1-2…

---

## [Download error: 2148270088 ; Is posible to download this site?](https://discourse.julialang.org/t/download-error-2148270088-is-posible-to-download-this-site/9126)

<div class="topic-metadata">

**Author:** [@programista](https://discourse.julialang.org/u/programista)\
**Replies:** 0\
**Last updated:** [February 17, 2018, 10:05am UTC](https://discourse.julialang.org/t/download-error-2148270088-is-posible-to-download-this-site/9126 "2018-02-17T10:05:53Z")

</div>

Is posible to download this site ? julia\> download(“http://gazeta.pl”) ERROR: automatic download failed (error: 2148270088): http://gazeta.pl Stacktrace: \[1\] download(::String, ::String) at .\\interactiveutil.jl:598 …

---

## [Why this constructor is extremly slow? Infinity Loop in Varargs function](https://discourse.julialang.org/t/why-this-constructor-is-extremly-slow-infinity-loop-in-varargs-function/9101)

<div class="topic-metadata">

**Author:** [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Replies:** 2\
**Last updated:** [February 16, 2018, 5:32am UTC](https://discourse.julialang.org/t/why-this-constructor-is-extremly-slow-infinity-loop-in-varargs-function/9101 "2018-02-16T05:32:40Z")

</div>

This constructor receives a wrong type actually but I do not receive any error, it seems that the compiler is in some infinite loop… I cannot figure out why? I guess I made some mistake, cause this happens on both v0.6 a…

---

## [Plotting thousands of polygons](https://discourse.julialang.org/t/plotting-thousands-of-polygons/9066)

<div class="topic-metadata">

**Author:** [@mforets](https://discourse.julialang.org/u/mforets)\
**Replies:** 7\
**Last updated:** [February 15, 2018, 9:20pm UTC](https://discourse.julialang.org/t/plotting-thousands-of-polygons/9066 "2018-02-15T21:20:50Z")

</div>

Would you recommend some specific configuration for efficiently plotting a large number (say 20k) polygons? Now we use a custom Plots recipe with a seriestype := :shape and a loop like ... for i in indices # loop o…

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

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