# Performance

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

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

**Page:** 133

---

## [Custom indices range for arrays](https://discourse.julialang.org/t/custom-indices-range-for-arrays/21203)

<div class="topic-metadata">

**Author:** [@MrRobot](https://discourse.julialang.org/u/MrRobot)\
**Replies:** 3\
**Last updated:** [February 26, 2019, 8:59am UTC](https://discourse.julialang.org/t/custom-indices-range-for-arrays/21203 "2019-02-26T08:59:54Z")

</div>

The Julia manual talks about being able to define custom unit ranges Arrays with custom indices · The Julia Language. There are at least 3 packages that deal with this. 1) GitHub - JuliaArrays/CustomUnitRanges.jl: Packa…

---

## [Disable fast-math for a specific function](https://discourse.julialang.org/t/disable-fast-math-for-a-specific-function/21160)

<div class="topic-metadata">

**Author:** [@robsmith11](https://discourse.julialang.org/u/robsmith11)\
**Replies:** 6\
**Last updated:** [February 25, 2019, 4:05pm UTC](https://discourse.julialang.org/t/disable-fast-math-for-a-specific-function/21160 "2019-02-25T16:05:45Z")

</div>

I’ve written a large numeric simulation that benefits substantially from starting Julia with --math-mode=fast (79% speed-up). I know this flag can be dangerous, but up until now, everything has worked well. I’d now l…

---

## [Buffering streams in Julia?](https://discourse.julialang.org/t/buffering-streams-in-julia/21129)

<div class="topic-metadata">

**Author:** [@Olof\_Salberger](https://discourse.julialang.org/u/Olof_Salberger)\
**Replies:** 1\
**Last updated:** [February 24, 2019, 1:26am UTC](https://discourse.julialang.org/t/buffering-streams-in-julia/21129 "2019-02-24T01:26:15Z")

</div>

Julia has a builtin API for streams. Is there an existing library that provides something similar to the bufio API in Go’s standard library, which makes it easy to add a buffering layer to encapsulate any given stream? T…

---

## [Julia slower in Windows](https://discourse.julialang.org/t/julia-slower-in-windows/21027)

<div class="topic-metadata">

**Author:** [@donquicote](https://discourse.julialang.org/u/donquicote)\
**Replies:** 16\
**Last updated:** [February 23, 2019, 8:56am UTC](https://discourse.julialang.org/t/julia-slower-in-windows/21027 "2019-02-23T08:56:10Z")

</div>

Hello, I’m running this simple piece of code in two different computers: using BenchmarkTools function testing() rand(1000000) end @btime testing() HP EliteBook 840 G3. i5-6300U 2.4Ghz. 16GB DRR4. Windows 10. 4…

---

## [Closure bug (#15276) hits again with multi-threading, but why?!](https://discourse.julialang.org/t/closure-bug-15276-hits-again-with-multi-threading-but-why/21082)

<div class="topic-metadata">

**Author:** [@raminammour](https://discourse.julialang.org/u/raminammour)\
**Replies:** 1\
**Last updated:** [February 22, 2019, 9:18pm UTC](https://discourse.julialang.org/t/closure-bug-15276-hits-again-with-multi-threading-but-why/21082 "2019-02-22T21:18:12Z")

</div>

Hello, Below is a MWE of what I am seeing in an application: function foo(v) #uncomment for Box size(v) == (10,10) && error() ss=zeros(Float64,Threads.nthreads()) #this does not lead to Box #si…

---

## [mul! much slower than \* for QRCompactWYQ](https://discourse.julialang.org/t/mul-much-slower-than-for-qrcompactwyq/17258)

<div class="topic-metadata">

**Author:** [@nrontsis](https://discourse.julialang.org/u/nrontsis)\
**Replies:** 5\
**Last updated:** [February 22, 2019, 11:01am UTC](https://discourse.julialang.org/t/mul-much-slower-than-for-qrcompactwyq/17258 "2019-02-22T11:01:11Z")

</div>

Suppose I have generated the following QRCompactWYQ: Q = qr(randn(500, 10)).Q; and I want to do in-place multiplication of Q with x = randn(500) to y = randn(500) i.e. @btime mul!(y, Q, x) This runs in 2.9s in my…

---

## [Julia messes up integer exponents?](https://discourse.julialang.org/t/julia-messes-up-integer-exponents/20773)

<div class="topic-metadata">

**Author:** [@MrRobot](https://discourse.julialang.org/u/MrRobot)\
**Replies:** 106\
**Last updated:** [February 21, 2019, 11:59pm UTC](https://discourse.julialang.org/t/julia-messes-up-integer-exponents/20773 "2019-02-21T23:59:02Z")

</div>

I was using avogadro’s number in a calculation and couldn’t figure out why the results were not matching my matlab or python code… Turns out using integers as exponents gets you in trouble in Julia?They start off innoce…

---

## [Poor performance of abspath](https://discourse.julialang.org/t/poor-performance-of-abspath/20853)

<div class="topic-metadata">

**Author:** [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Replies:** 7\
**Last updated:** [February 21, 2019, 3:35pm UTC](https://discourse.julialang.org/t/poor-performance-of-abspath/20853 "2019-02-21T15:35:47Z")

</div>

I’m running some stress tests on Genie apps and literally, the first thing that broke the app was a repeated call to abspath. I’m not sure if this can be improved, but if not, maybe the docs can point to the fact that it…

---

## [\[Solved\] Determinant and random matrix generation](https://discourse.julialang.org/t/solved-determinant-and-random-matrix-generation/20975)

<div class="topic-metadata">

**Author:** [@gdestouet](https://discourse.julialang.org/u/gdestouet)\
**Replies:** 6\
**Last updated:** [February 19, 2019, 2:45pm UTC](https://discourse.julialang.org/t/solved-determinant-and-random-matrix-generation/20975 "2019-02-19T14:45:48Z")

</div>

Hello, I was playing with random matrices when I noticed this strange behaviour : julia\> using LinearAlgebra julia\> a=randn(10,11); julia\> isposdef(a\*a') true julia\> isposdef(a'\*a) false I expected to have either w…

---

## [Can I make my code faster with parallelism, or just plain better coding?](https://discourse.julialang.org/t/can-i-make-my-code-faster-with-parallelism-or-just-plain-better-coding/20613)

<div class="topic-metadata">

**Author:** [@MrRobot](https://discourse.julialang.org/u/MrRobot)\
**Replies:** 33\
**Last updated:** [February 19, 2019, 7:00am UTC](https://discourse.julialang.org/t/can-i-make-my-code-faster-with-parallelism-or-just-plain-better-coding/20613 "2019-02-19T07:00:12Z")

</div>

I am trying to optimize a lennard-jones force calculation. When I first wrote it, It used millions of allocations and over 1 giB of memory, and these both increased if I looped over the algorithm. I have gotten it down t…

---

## [How to measure cache misses in Julia?](https://discourse.julialang.org/t/how-to-measure-cache-misses-in-julia/20875)

<div class="topic-metadata">

**Author:** [@phrmoy](https://discourse.julialang.org/u/phrmoy)\
**Replies:** 11\
**Last updated:** [February 18, 2019, 5:03am UTC](https://discourse.julialang.org/t/how-to-measure-cache-misses-in-julia/20875 "2019-02-18T05:03:05Z")

</div>

Hi there! Do we have a tool or the means for measuring cache misses in Julia? If we had a macro for this would really set Julia apart in the HPC world. I did search around here but did not find anything, thank you. Ped…

---

## [Writing efficient code in monadic style](https://discourse.julialang.org/t/writing-efficient-code-in-monadic-style/20756)

<div class="topic-metadata">

**Author:** [@jonathan-laurent](https://discourse.julialang.org/u/jonathan-laurent)\
**Replies:** 1\
**Last updated:** [February 14, 2019, 7:36am UTC](https://discourse.julialang.org/t/writing-efficient-code-in-monadic-style/20756 "2019-02-14T07:36:54Z")

</div>

Hi everyone, I have been trying to write some Julia code in monadic style while keeping it as efficient as possible. I am running in a problem that can be illustrated by the following minimal example: # Simple implemen…

---

## [Reduce allocations for shaped views](https://discourse.julialang.org/t/reduce-allocations-for-shaped-views/20757)

<div class="topic-metadata">

**Author:** [@Egwene\_al\_Vere](https://discourse.julialang.org/u/Egwene_al_Vere)\
**Replies:** 9\
**Last updated:** [February 13, 2019, 11:57pm UTC](https://discourse.julialang.org/t/reduce-allocations-for-shaped-views/20757 "2019-02-13T23:57:00Z")

</div>

tl;dr Reduce the allocation for foo(u,...): Inside the function, given an array u of size m\*1, get the first n=d\*d\*p elements of u where n\<m is guaranteed, and reshape it as an array f of d-by-d matrices (access as f\[j\],…

---

## [JuliaDB Benchmarks](https://discourse.julialang.org/t/juliadb-benchmarks/20710)

<div class="topic-metadata">

**Author:** [@joshday](https://discourse.julialang.org/u/joshday)\
**Replies:** 4\
**Last updated:** [February 12, 2019, 8:11pm UTC](https://discourse.julialang.org/t/juliadb-benchmarks/20710 "2019-02-12T20:11:55Z")

</div>

I’ve started gathering some reproducible benchmarks at GitHub - JuliaData/JuliaDB\_Benchmarks: Reproducible benchmarks for JuliaDB (huge shout out to https://github.com/oxinabox/DataDeps.jl for simplifying the reproducibl…

---

## [CPU cycles and syscalls](https://discourse.julialang.org/t/cpu-cycles-and-syscalls/20702)

<div class="topic-metadata">

**Author:** [@varleg](https://discourse.julialang.org/u/varleg)\
**Replies:** 4\
**Last updated:** [February 12, 2019, 4:19pm UTC](https://discourse.julialang.org/t/cpu-cycles-and-syscalls/20702 "2019-02-12T16:19:54Z")

</div>

Hello. I am doing a project on Julias performance compared to assembly, C and FPGA rpogramming. The thing I have noticed thus far is: Julia uses 300,000,000 cycles and 130.7 msec to calculate 2+2 C uses 290,000 cycles…

---

## [Poor performance while multithreading (Julia 1.0)](https://discourse.julialang.org/t/poor-performance-while-multithreading-julia-1-0/20325)

<div class="topic-metadata">

**Author:** [@dkiese](https://discourse.julialang.org/u/dkiese)\
**Replies:** 28\
**Last updated:** [February 11, 2019, 9:38am UTC](https://discourse.julialang.org/t/poor-performance-while-multithreading-julia-1-0/20325 "2019-02-11T09:38:14Z")

</div>

Hello everyone, this is my first post (although not my first encounter with Julia), so please bear with me if I am doing everything wrong. Okay, so now here is my Problem. I have a working code, that solves a set of co…

---

## [Way to speed up a 2x2 block matrix solver?](https://discourse.julialang.org/t/way-to-speed-up-a-2x2-block-matrix-solver/20628)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 0\
**Last updated:** [February 10, 2019, 7:31pm UTC](https://discourse.julialang.org/t/way-to-speed-up-a-2x2-block-matrix-solver/20628 "2019-02-10T19:31:33Z")

</div>

Hi All, So I made a package that solves a 2x2 block system, according to: This assumes that you have some matrix that is predominantly banded. Using BandedMatrix.jl, I tried to take a crack at optimizing the solver…

---

## [Finite differences with Julia](https://discourse.julialang.org/t/finite-differences-with-julia/20591)

<div class="topic-metadata">

**Author:** [@pnavaro](https://discourse.julialang.org/u/pnavaro)\
**Replies:** 5\
**Last updated:** [February 9, 2019, 7:25pm UTC](https://discourse.julialang.org/t/finite-differences-with-julia/20591 "2019-02-09T19:25:05Z")

</div>

Dear Julia users, Is there a way to improve performance of this kind of code without devectorizing (use loops). All variables are 2d arrays. I solve a PDE problem with finite differences method. Thanks for your help 99…

---

## [What's in the .mem files?](https://discourse.julialang.org/t/whats-in-the-mem-files/20592)

<div class="topic-metadata">

**Author:** [@tanhevg](https://discourse.julialang.org/u/tanhevg)\
**Replies:** 1\
**Last updated:** [February 8, 2019, 9:19pm UTC](https://discourse.julialang.org/t/whats-in-the-mem-files/20592 "2019-02-08T21:19:02Z")

</div>

Hello, I have run julia with --track-allocation=all, and it has generated a bunch of .mem files for my code. Some of my lines are annotated with numbers on the left hand side. What exactly do those numbers mean? Are the…

---

## [Reduce allocations for matrix differential equations function](https://discourse.julialang.org/t/reduce-allocations-for-matrix-differential-equations-function/20520)

<div class="topic-metadata">

**Author:** [@Egwene\_al\_Vere](https://discourse.julialang.org/u/Egwene_al_Vere)\
**Replies:** 10\
**Last updated:** [February 8, 2019, 2:41am UTC](https://discourse.julialang.org/t/reduce-allocations-for-matrix-differential-equations-function/20520 "2019-02-08T02:41:38Z")

</div>

Here’s a sample function for use with a differential equation solver to solve a system of matrices equations, d M\_i / dt =f(M\_{1...n}). The matrix M\_i is represented by m\[:,:,i\], and its time derivative is stored in dm. …

---

## [Efficiently compute X\[sub,:\]\*X\[sub,:\]'](https://discourse.julialang.org/t/efficiently-compute-x-sub-x-sub/20480)

<div class="topic-metadata">

**Author:** [@maximerischard](https://discourse.julialang.org/u/maximerischard)\
**Replies:** 1\
**Last updated:** [February 5, 2019, 6:30pm UTC](https://discourse.julialang.org/t/efficiently-compute-x-sub-x-sub/20480 "2019-02-05T18:30:30Z")

</div>

X is a matrix and sub is a subset of columns. I’m trying to find the most efficient way to compute X’X for the submatrix. What I find is that first allocating X\[sub,:\] is significantly faster than using view(X,sub,:), bu…

---

## [Inner function overhead](https://discourse.julialang.org/t/inner-function-overhead/20394)

<div class="topic-metadata">

**Author:** [@ShnitzelKiller](https://discourse.julialang.org/u/ShnitzelKiller)\
**Replies:** 2\
**Last updated:** [February 3, 2019, 9:57pm UTC](https://discourse.julialang.org/t/inner-function-overhead/20394 "2019-02-03T21:57:53Z")

</div>

I have found that using a small nested function to handle repeated code has resulted in unwanted allocations. I tried to simplify the below function: function compute\_distance(grid::Matrix{T}, I::CartesianIndex{2}, Ifir…

---

## [Memory allocation of keyword arguments](https://discourse.julialang.org/t/memory-allocation-of-keyword-arguments/20389)

<div class="topic-metadata">

**Author:** [@srikar\_sastry](https://discourse.julialang.org/u/srikar_sastry)\
**Replies:** 5\
**Last updated:** [February 3, 2019, 1:52pm UTC](https://discourse.julialang.org/t/memory-allocation-of-keyword-arguments/20389 "2019-02-03T13:52:45Z")

</div>

Hello, I was looking into keyword function arguments. I tried using @time to check the memory allocation for the function, and found that one single keyword argument of type Bool adds half an MB of memory. Is that expec…

---

## [Trivial code change causes vectorization failure](https://discourse.julialang.org/t/trivial-code-change-causes-vectorization-failure/20299)

<div class="topic-metadata">

**Author:** [@robsmith11](https://discourse.julialang.org/u/robsmith11)\
**Replies:** 3\
**Last updated:** [February 1, 2019, 9:03am UTC](https://discourse.julialang.org/t/trivial-code-change-causes-vectorization-failure/20299 "2019-02-01T09:03:11Z")

</div>

I am porting a few approximate math functions that I’ve used before that vectorized well, but noticed that with Julia the direct translation fails to vectorize. However, a trivial change (expanding s = f \* f) makes Juli…

---

## [Slow insert at end of large array (Solved)](https://discourse.julialang.org/t/slow-insert-at-end-of-large-array-solved/20264)

<div class="topic-metadata">

**Author:** [@robsmith11](https://discourse.julialang.org/u/robsmith11)\
**Replies:** 7\
**Last updated:** [January 30, 2019, 9:14am UTC](https://discourse.julialang.org/t/slow-insert-at-end-of-large-array-solved/20264 "2019-01-30T09:14:07Z")

</div>

Why is inserting an element at the end of an array (with enough room – as evidenced by the lack of allocations) so slow? julia\> a0 = repeat(\[1\], 10^9); julia\> @btime insert!(a,1,10^9 + 1) evals=1 setup=(a=sizehint!(dee…

---

## [Performance help for this short matrix function?](https://discourse.julialang.org/t/performance-help-for-this-short-matrix-function/20240)

<div class="topic-metadata">

**Author:** [@evanfields](https://discourse.julialang.org/u/evanfields)\
**Replies:** 11\
**Last updated:** [January 30, 2019, 7:50am UTC](https://discourse.julialang.org/t/performance-help-for-this-short-matrix-function/20240 "2019-01-30T07:50:39Z")

</div>

I’m computing regularized optimal transport distances as described in https://papers.nips.cc/paper/4927-sinkhorn-distances-lightspeed-computation-of-optimal-transport.pdf The code is quite short: using LinearAlgebra f…

---

## [Calling guard function causes millions of allocs while running inner function doesn't](https://discourse.julialang.org/t/calling-guard-function-causes-millions-of-allocs-while-running-inner-function-doesnt/20228)

<div class="topic-metadata">

**Author:** [@ShnitzelKiller](https://discourse.julialang.org/u/ShnitzelKiller)\
**Replies:** 4\
**Last updated:** [January 30, 2019, 1:16am UTC](https://discourse.julialang.org/t/calling-guard-function-causes-millions-of-allocs-while-running-inner-function-doesnt/20228 "2019-01-30T01:16:46Z")

</div>

I’ve followed the performance tips to implement a function guard for setting up objects to be accessed in the inner loop of an algorithm, as follows: function fast\_marching!(grid::Matrix{T}, h::Real, maxdist::Real=1) wh…

---

## [Forcing @inline](https://discourse.julialang.org/t/forcing-inline/20225)

<div class="topic-metadata">

**Author:** [@rgankema](https://discourse.julialang.org/u/rgankema)\
**Replies:** 4\
**Last updated:** [January 29, 2019, 2:05pm UTC](https://discourse.julialang.org/t/forcing-inline/20225 "2019-01-29T14:05:15Z")

</div>

I’ve got a relatively large function, that I’d like to be inlined. Although I used the @inline annotation, the compiler apparently still decides that it’s not worth inlining. It might be right, but I really want to at le…

---

## [Specifying keyword argument results in much slower code](https://discourse.julialang.org/t/specifying-keyword-argument-results-in-much-slower-code/20189)

<div class="topic-metadata">

**Author:** [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Replies:** 2\
**Last updated:** [January 29, 2019, 8:02am UTC](https://discourse.julialang.org/t/specifying-keyword-argument-results-in-much-slower-code/20189 "2019-01-29T08:02:57Z")

</div>

Hi, I noticed the performance regression in this simple test program of my package PseudoArcLengthContinuation.jl. I have a keyword argument which is only used for printing purposes so it should not affect the computati…

---

## [How to efficiently splat values into argument list?](https://discourse.julialang.org/t/how-to-efficiently-splat-values-into-argument-list/20177)

<div class="topic-metadata">

**Author:** [@ShnitzelKiller](https://discourse.julialang.org/u/ShnitzelKiller)\
**Replies:** 3\
**Last updated:** [January 28, 2019, 11:42pm UTC](https://discourse.julialang.org/t/how-to-efficiently-splat-values-into-argument-list/20177 "2019-01-28T23:42:17Z")

</div>

I’ve found that using generator syntax in argument lists seems to cause unwanted allocations. For example, I have a piece of code that does something very simple, taking the slices of a 3D array and turning them into RG…

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

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