# Performance

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

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

**Page:** 117

---

## [Type instability with StaticArrays.jl and "type alias"](https://discourse.julialang.org/t/type-instability-with-staticarrays-jl-and-type-alias/39763)

<div class="topic-metadata">

**Author:** [@ranocha](https://discourse.julialang.org/u/ranocha)\
**Replies:** 6\
**Last updated:** [May 20, 2020, 4:03am UTC](https://discourse.julialang.org/t/type-instability-with-staticarrays-jl-and-type-alias/39763 "2020-05-20T04:03:33Z")

</div>

I see the following type instability in current Julia v1.4 and master (commit cebd4fa959). julia\> using StaticArrays \[ Info: Precompiling StaticArrays \[90137ffa-7385-5640-81b9-e52037218182\] julia\> struct Foo{N} end ju…

---

## [Unused \`where T\` causes a function to become very slow](https://discourse.julialang.org/t/unused-where-t-causes-a-function-to-become-very-slow/39727)

<div class="topic-metadata">

**Author:** [@mabokhamis](https://discourse.julialang.org/u/mabokhamis)\
**Replies:** 12\
**Last updated:** [May 19, 2020, 5:07pm UTC](https://discourse.julialang.org/t/unused-where-t-causes-a-function-to-become-very-slow/39727 "2020-05-19T17:07:41Z")

</div>

We noticed that an unused where T in a function declaration can cause the function to become much slower and to allocate a lot more memory. Consider for example the following two functions which are identical except that…

---

## [Efficient representation and operations on symmetric zero-diagonal tensors](https://discourse.julialang.org/t/efficient-representation-and-operations-on-symmetric-zero-diagonal-tensors/39751)

<div class="topic-metadata">

**Author:** [@hessammehr](https://discourse.julialang.org/u/hessammehr)\
**Replies:** 0\
**Last updated:** [May 19, 2020, 1:17pm UTC](https://discourse.julialang.org/t/efficient-representation-and-operations-on-symmetric-zero-diagonal-tensors/39751 "2020-05-19T13:17:56Z")

</div>

I am looking for an efficient way of representing symmetric tensors with all zero diagonals (any combination of two indices, that is). Since these tensors are going to be fairly small, a fair number of entries are going …

---

## [Trying to optimize system of SDE's](https://discourse.julialang.org/t/trying-to-optimize-system-of-sdes/39648)

<div class="topic-metadata">

**Author:** [@Ignacio\_Perez\_Ipina](https://discourse.julialang.org/u/Ignacio_Perez_Ipina)\
**Replies:** 6\
**Last updated:** [May 18, 2020, 8:34pm UTC](https://discourse.julialang.org/t/trying-to-optimize-system-of-sdes/39648 "2020-05-18T20:34:41Z")

</div>

Hello! I’ve been introduced to Julia very recently, and I’ve been trying to adapt my already tested system of equations, with additive noise, based on a Takens-Bogdanov bifurcation. I’ve got this far trying to impro…

---

## [Fast in.(x, Ref(y))](https://discourse.julialang.org/t/fast-in-x-ref-y/39701)

<div class="topic-metadata">

**Author:** [@robsmith11](https://discourse.julialang.org/u/robsmith11)\
**Replies:** 4\
**Last updated:** [May 18, 2020, 3:26pm UTC](https://discourse.julialang.org/t/fast-in-x-ref-y/39701 "2020-05-18T15:26:50Z")

</div>

I often want to filter a large Dataframe by checking whether the values of a column are elements of another large vector. Naively broadcasting in across the first vector is very slow: julia\> n = 10^5; @time in.(rand(1:…

---

## [Help make my ideal gas simulation ideally fast](https://discourse.julialang.org/t/help-make-my-ideal-gas-simulation-ideally-fast/39141)

<div class="topic-metadata">

**Author:** [@jgreener64](https://discourse.julialang.org/u/jgreener64)\
**Replies:** 13\
**Last updated:** [May 18, 2020, 11:10am UTC](https://discourse.julialang.org/t/help-make-my-ideal-gas-simulation-ideally-fast/39141 "2020-05-18T11:10:04Z")

</div>

I have been meaning to speed up some of the non-bonded force calculation in Molly.jl and I had a play with it today, but found I hit a ceiling. I have extracted a simplistic molecular dynamics simulation of a Lennard Jo…

---

## [How do I speed this up?](https://discourse.julialang.org/t/how-do-i-speed-this-up/39577)

<div class="topic-metadata">

**Author:** [@scotts](https://discourse.julialang.org/u/scotts)\
**Replies:** 6\
**Last updated:** [May 17, 2020, 11:22am UTC](https://discourse.julialang.org/t/how-do-i-speed-this-up/39577 "2020-05-17T11:22:57Z")

</div>

I’ve translated some code from a Matlab script into Julia, but I’m finding it running much slower… The culprit loop is: for i::Int16 = 1 : n\_acts n\_ages::Int16 = m\["max\_age"\]\[i\] if n\_ages \> 1 idx…

---

## [Fast floating point quantisation / rounding](https://discourse.julialang.org/t/fast-floating-point-quantisation-rounding/39439)

<div class="topic-metadata">

**Author:** [@jackf](https://discourse.julialang.org/u/jackf)\
**Replies:** 3\
**Last updated:** [May 17, 2020, 8:51am UTC](https://discourse.julialang.org/t/fast-floating-point-quantisation-rounding/39439 "2020-05-17T08:51:07Z")

</div>

I have a large number of Float32s in an array. I want to apply the transformation f(x) = round(Int16, x \* a + b, RoundToZero) where a and b are constants. I also need to apply the inverse transform (but multiplication by…

---

## [To factor or not to factor? Functions with small differences within loops](https://discourse.julialang.org/t/to-factor-or-not-to-factor-functions-with-small-differences-within-loops/39532)

<div class="topic-metadata">

**Author:** [@Dr.Merkwuedigliebe](https://discourse.julialang.org/u/Dr.Merkwuedigliebe)\
**Replies:** 4\
**Last updated:** [May 16, 2020, 1:25pm UTC](https://discourse.julialang.org/t/to-factor-or-not-to-factor-functions-with-small-differences-within-loops/39532 "2020-05-16T13:25:18Z")

</div>

I have a number of functions that perform updates on a number of large arrays in the same loop. Previously, I learned that this is often a good idea for performance. Now, I am facing another issue: I need a few variants …

---

## [Reducing allocations for repeatedly generating MvNormal distributions](https://discourse.julialang.org/t/reducing-allocations-for-repeatedly-generating-mvnormal-distributions/39483)

<div class="topic-metadata">

**Author:** [@ArnoStrouwen](https://discourse.julialang.org/u/ArnoStrouwen)\
**Replies:** 2\
**Last updated:** [May 16, 2020, 2:25am UTC](https://discourse.julialang.org/t/reducing-allocations-for-repeatedly-generating-mvnormal-distributions/39483 "2020-05-16T02:25:25Z")

</div>

I have to repeatedly generate few random numbers from many different bivariate normal distributions. I want to do this with as few allocations as possible. A simplified example of my code: using Distributions using Rand…

---

## [Loading only what you need](https://discourse.julialang.org/t/loading-only-what-you-need/39465)

<div class="topic-metadata">

**Author:** [@tlienart](https://discourse.julialang.org/u/tlienart)\
**Replies:** 6\
**Last updated:** [May 14, 2020, 7:53pm UTC](https://discourse.julialang.org/t/loading-only-what-you-need/39465 "2020-05-14T19:53:00Z")

</div>

I was looking at SpecialFunctions.jl which contains a bunch of functions which are fairly independent and thinking: if I just want to only use one or two specific functions, what’s the overhead vs just copy-pasting that …

---

## [Having trouble parallelizing a system of ODEs](https://discourse.julialang.org/t/having-trouble-parallelizing-a-system-of-odes/39442)

<div class="topic-metadata">

**Author:** [@Lachlan-Bn](https://discourse.julialang.org/u/Lachlan-Bn)\
**Replies:** 1\
**Last updated:** [May 14, 2020, 3:28am UTC](https://discourse.julialang.org/t/having-trouble-parallelizing-a-system-of-odes/39442 "2020-05-14T03:28:32Z")

</div>

Allow me to preface this by saying I have limited programming experience beyond the relatively short time I’ve been using Julia, so if you see I’ve made some kind of coding faux pas, please point it out! I have a non-li…

---

## [Missing epsilon](https://discourse.julialang.org/t/missing-epsilon/39430)

<div class="topic-metadata">

**Author:** [@Jul](https://discourse.julialang.org/u/Jul)\
**Replies:** 2\
**Last updated:** [May 13, 2020, 9:21pm UTC](https://discourse.julialang.org/t/missing-epsilon/39430 "2020-05-13T21:21:51Z")

</div>

Hello, I’m trying to write small epsilon in Julia 1.4.1 (\\ epsilon) but instead epsilon character I see small box (box character or something like that- small, empty rectangle). Anyone had similar problem?

---

## [Benchmarks game](https://discourse.julialang.org/t/benchmarks-game/38544)

<div class="topic-metadata">

**Author:** [@apieum](https://discourse.julialang.org/u/apieum)\
**Replies:** 20\
**Last updated:** [May 13, 2020, 5:20pm UTC](https://discourse.julialang.org/t/benchmarks-game/38544 "2020-05-13T17:20:07Z")

</div>

Hi, this blog post shows bad results for julia in benchmarks game: Which programming language is fastest? In comments the author said “One problem with Julia benchmarks on the Benchmarks Game is that improved Julia prog…

---

## [Function not faster than global scope](https://discourse.julialang.org/t/function-not-faster-than-global-scope/39389)

<div class="topic-metadata">

**Author:** [@JasonHall](https://discourse.julialang.org/u/JasonHall)\
**Replies:** 7\
**Last updated:** [May 13, 2020, 12:39pm UTC](https://discourse.julialang.org/t/function-not-faster-than-global-scope/39389 "2020-05-13T12:39:34Z")

</div>

I am following along in Adrian Salceanu’s book “Julia Programming Projects”. He is on Julia 1.0 and I am using 1.4. He says that running in the global scope is slower than wrapping in a function because the function is…

---

## [Iterating over the columns of a matrix](https://discourse.julialang.org/t/iterating-over-the-columns-of-a-matrix/39385)

<div class="topic-metadata">

**Author:** [@BMO](https://discourse.julialang.org/u/BMO)\
**Replies:** 3\
**Last updated:** [May 13, 2020, 10:49am UTC](https://discourse.julialang.org/t/iterating-over-the-columns-of-a-matrix/39385 "2020-05-13T10:49:12Z")

</div>

I want to iterate a function whose argument is a vector. The vectors to iterate on are the columns of a matrix. I was “slicing” the matrix into columns following Converting a matrix into an array of arrays and then itera…

---

## [Size vs length](https://discourse.julialang.org/t/size-vs-length/37101)

<div class="topic-metadata">

**Author:** [@isentropic](https://discourse.julialang.org/u/isentropic)\
**Replies:** 13\
**Last updated:** [May 12, 2020, 1:28pm UTC](https://discourse.julialang.org/t/size-vs-length/37101 "2020-05-12T13:28:45Z")

</div>

I wonder why the performance of size is so much faster when it comes to matrices: julia\> a = rand(100,2) 100×2 Array{Float64,2}: 0.47076 0.605881 0.0432887 0.318102 0.12271 0.121367 0.0737559 0.885239 0.389…

---

## [How fast can Plots.jl work after being compiled with PackageCompiler?](https://discourse.julialang.org/t/how-fast-can-plots-jl-work-after-being-compiled-with-packagecompiler/39314)

<div class="topic-metadata">

**Author:** [@Xing\_Shi\_Cai](https://discourse.julialang.org/u/Xing_Shi_Cai)\
**Replies:** 13\
**Last updated:** [May 12, 2020, 12:47pm UTC](https://discourse.julialang.org/t/how-fast-can-plots-jl-work-after-being-compiled-with-packagecompiler/39314 "2020-05-12T12:47:37Z")

</div>

I just tried using PackageComipler on Plots.jl. With precompiled images, I got julia\> @time using Plots 0.891786 seconds (1.26 M allocations: 59.289 MiB, 16.97% gc time) julia\> @time (p = plot(rand(5), rand(5)); disp…

---

## [Monte Carlo particle simulations are very slow](https://discourse.julialang.org/t/monte-carlo-particle-simulations-are-very-slow/39239)

<div class="topic-metadata">

**Author:** [@edwinb-ai](https://discourse.julialang.org/u/edwinb-ai)\
**Replies:** 9\
**Last updated:** [May 11, 2020, 5:15pm UTC](https://discourse.julialang.org/t/monte-carlo-particle-simulations-are-very-slow/39239 "2020-05-11T17:15:40Z")

</div>

Hello everyone, I’m still learning Julia by doing some standard physics simulations in Julia. I used to have all of my code base in C and Fortran, and just recently attempted to migrate everything to Julia. In particul…

---

## [Any benchmark about memory consumption?](https://discourse.julialang.org/t/any-benchmark-about-memory-consumption/17270)

<div class="topic-metadata">

**Author:** [@Juan](https://discourse.julialang.org/u/Juan)\
**Replies:** 11\
**Last updated:** [May 11, 2020, 4:02pm UTC](https://discourse.julialang.org/t/any-benchmark-about-memory-consumption/17270 "2020-05-11T16:02:36Z")

</div>

There are some benchmarks testing the time to compute several tasks compared to other languages. But what about memory consumption? For example how well does Julia reshape a dataset from long to wide format compared to…

---

## [Why accessing a Float property allocates memory?](https://discourse.julialang.org/t/why-accessing-a-float-property-allocates-memory/39235)

<div class="topic-metadata">

**Author:** [@emancu](https://discourse.julialang.org/u/emancu)\
**Replies:** 2\
**Last updated:** [May 10, 2020, 7:01pm UTC](https://discourse.julialang.org/t/why-accessing-a-float-property-allocates-memory/39235 "2020-05-10T19:01:14Z")

</div>

Hello community! I’m running a simulation which requires millions of iterations, and the memory consumption (even temporary) is huge and I would like to reduce it. Pursuing this, I found something that I wasn’t expectin…

---

## [Improve perfromance of DifferentialEquations, when odefun is evaluated repeatedly and many timepoints are required](https://discourse.julialang.org/t/improve-perfromance-of-differentialequations-when-odefun-is-evaluated-repeatedly-and-many-timepoints-are-required/39110)

<div class="topic-metadata">

**Author:** [@user22](https://discourse.julialang.org/u/user22)\
**Replies:** 8\
**Last updated:** [May 10, 2020, 8:05am UTC](https://discourse.julialang.org/t/improve-perfromance-of-differentialequations-when-odefun-is-evaluated-repeatedly-and-many-timepoints-are-required/39110 "2020-05-10T08:05:05Z")

</div>

Is it possible to improve the performance of an ODE system solving, if we have to evaluate the equation many times with different parameters (not in a Monte Carlo manner, but sequentially), and if we want to evaluate par…

---

## [Revise cannot transform my dataset](https://discourse.julialang.org/t/revise-cannot-transform-my-dataset/39177)

<div class="topic-metadata">

**Author:** [@chedieck](https://discourse.julialang.org/u/chedieck)\
**Replies:** 23\
**Last updated:** [May 9, 2020, 9:17pm UTC](https://discourse.julialang.org/t/revise-cannot-transform-my-dataset/39177 "2020-05-09T21:17:58Z")

</div>

I am trying to solve the “Predict Data Sales” on kaggle, using the DataFrames, Plots and CSV packages. Here is my code, named processdata.jl, so far: @time using CSV, DataFrames, Plots println("finished importing") # # …

---

## [Will decreasing the precision of intermediate variables improve performance of code?](https://discourse.julialang.org/t/will-decreasing-the-precision-of-intermediate-variables-improve-performance-of-code/39166)

<div class="topic-metadata">

**Author:** [@SambitMishra98](https://discourse.julialang.org/u/SambitMishra98)\
**Replies:** 12\
**Last updated:** [May 9, 2020, 9:47am UTC](https://discourse.julialang.org/t/will-decreasing-the-precision-of-intermediate-variables-improve-performance-of-code/39166 "2020-05-09T09:47:48Z")

</div>

I found from a Youtube video that half-precision is significantly faster than single and double precision. \[JuliaCon 2018 | Keynote - Tricks and Tips in Numerical Computing | Nick Higham - YouTube\](2018 | Keynote - Trick…

---

## [Speeding up summation inside comprehension](https://discourse.julialang.org/t/speeding-up-summation-inside-comprehension/39119)

<div class="topic-metadata">

**Author:** [@gobs](https://discourse.julialang.org/u/gobs)\
**Replies:** 5\
**Last updated:** [May 8, 2020, 6:30pm UTC](https://discourse.julialang.org/t/speeding-up-summation-inside-comprehension/39119 "2020-05-08T18:30:27Z")

</div>

I currently do something similar to the code below (though I have axis arrays instead of regular arrays): A = 1:100 B = 1:200 C = 1:300 x = rand(length(A),length(B),length(C)) y = rand(length(B),length(C)) z = \[ s…

---

## [Making efficient some small subroutines](https://discourse.julialang.org/t/making-efficient-some-small-subroutines/38917)

<div class="topic-metadata">

**Author:** [@O\_Julia](https://discourse.julialang.org/u/O_Julia)\
**Replies:** 22\
**Last updated:** [May 8, 2020, 10:10am UTC](https://discourse.julialang.org/t/making-efficient-some-small-subroutines/38917 "2020-05-08T10:10:31Z")

</div>

Hi, I am trying to convert some Python+numpy subroutines to Julia. These subroutines are most important part of my main progam and take much time. In the current version these codes are run faster in non-optimized Python…

---

## [Is it possible to make this function faster?](https://discourse.julialang.org/t/is-it-possible-to-make-this-function-faster/38434)

<div class="topic-metadata">

**Author:** [@alvrg](https://discourse.julialang.org/u/alvrg)\
**Replies:** 11\
**Last updated:** [May 7, 2020, 9:32pm UTC](https://discourse.julialang.org/t/is-it-possible-to-make-this-function-faster/38434 "2020-05-07T21:32:45Z")

</div>

Hi all: I have a function foo that iterates through a ComplexF64 vector A. For each element A\[i\], it computes all distances |A\[i\] - A\[j\]| in the complex plane and then stores in B\[i\] the ratio of the minimum distance by…

---

## [Julia or Python: Which is faster for Deep Learning](https://discourse.julialang.org/t/julia-or-python-which-is-faster-for-deep-learning/38935)

<div class="topic-metadata">

**Author:** [@Eldho.Ashna](https://discourse.julialang.org/u/Eldho.Ashna)\
**Replies:** 3\
**Last updated:** [May 7, 2020, 11:11am UTC](https://discourse.julialang.org/t/julia-or-python-which-is-faster-for-deep-learning/38935 "2020-05-07T11:11:04Z")

</div>

Hi everyone. Is there any difference in the time taken by a julia code and python code to complete 100 epochs? For example, suppose I’m trying to do mnist classification for 100 epochs. I wrote the code in python using…

---

## [\`varinfo()\` on a large SimpleGraph or DataFrame is prohibitively slow](https://discourse.julialang.org/t/varinfo-on-a-large-simplegraph-or-dataframe-is-prohibitively-slow/38851)

<div class="topic-metadata">

**Author:** [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Replies:** 0\
**Last updated:** [May 6, 2020, 12:53am UTC](https://discourse.julialang.org/t/varinfo-on-a-large-simplegraph-or-dataframe-is-prohibitively-slow/38851 "2020-05-06T00:53:53Z")

</div>

The only time I use varinfo is when I have a large object in memory and I want to know how much space it is taking. Unfortunately, in many scenarios varinfo runtime goes through the roof for large objects, so it’s imposs…

---

## [Difficulty figuring out when to use pmap, @sync, @async, @distributed](https://discourse.julialang.org/t/difficulty-figuring-out-when-to-use-pmap-sync-async-distributed/38794)

<div class="topic-metadata">

**Author:** [@JedPhillips](https://discourse.julialang.org/u/JedPhillips)\
**Replies:** 1\
**Last updated:** [May 5, 2020, 2:54pm UTC](https://discourse.julialang.org/t/difficulty-figuring-out-when-to-use-pmap-sync-async-distributed/38794 "2020-05-05T14:54:26Z")

</div>

I’m trying to optimize some code running in parallel. I’m struggling to figure out the best way to lay out this approach, and where to use pmap(), sync, async, distributed etc. I am applying a null model randomization t…

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

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