# Performance

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

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

**Page:** 125

---

## [Compiler determines return value(!) but still generates additional code](https://discourse.julialang.org/t/compiler-determines-return-value-but-still-generates-additional-code/27117)

<div class="topic-metadata">

**Author:** [@martink](https://discourse.julialang.org/u/martink)\
**Replies:** 1\
**Last updated:** [November 2, 2019, 12:48am UTC](https://discourse.julialang.org/t/compiler-determines-return-value-but-still-generates-additional-code/27117 "2019-11-02T00:48:15Z")

</div>

Hello This is my first contribution to this Julia forum. I hope my issue belongs to the “Performance” category, if not i would be glad if someone can tell me a more appropriate place. I ran into an issue with a functio…

---

## [Loading Images is very slow, is there a work around?](https://discourse.julialang.org/t/loading-images-is-very-slow-is-there-a-work-around/30529)

<div class="topic-metadata">

**Author:** [@onetonfoot](https://discourse.julialang.org/u/onetonfoot)\
**Replies:** 2\
**Last updated:** [October 31, 2019, 10:06am UTC](https://discourse.julialang.org/t/loading-images-is-very-slow-is-there-a-work-around/30529 "2019-10-31T10:06:04Z")

</div>

Loading images seems to be very slow? Comparing my Julia code to Python using BenchmarkTools, FileIO path = "/home/dom/Pictures/sd1/jpegs/DSCF0201.jpg" @btime load(path); # 1.890 s (245 allocations: 206.01 MiB) Vs f…

---

## [How to prevent type instability in for loops?](https://discourse.julialang.org/t/how-to-prevent-type-instability-in-for-loops/30508)

<div class="topic-metadata">

**Author:** [@Ronneesley](https://discourse.julialang.org/u/Ronneesley)\
**Replies:** 13\
**Last updated:** [October 30, 2019, 10:00pm UTC](https://discourse.julialang.org/t/how-to-prevent-type-instability-in-for-loops/30508 "2019-10-30T22:00:28Z")

</div>

When we create a for loop with range, Julia alert a type of instability in the range created. Using the code below. v = \[1, 2, 3\] function f(v::Array{Int, 1}) s = 0 for i = 1:length(v) s += v\[i\] end…

---

## [Blas dot doing weird things depending on size](https://discourse.julialang.org/t/blas-dot-doing-weird-things-depending-on-size/30430)

<div class="topic-metadata">

**Author:** [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Replies:** 3\
**Last updated:** [October 29, 2019, 12:56pm UTC](https://discourse.julialang.org/t/blas-dot-doing-weird-things-depending-on-size/30430 "2019-10-29T12:56:34Z")

</div>

I’m working on some by hand matrix multiplication. function slowMult!(A::AbstractMatrix{T},B::AbstractMatrix{T}) where T\<:Number C = Matrix{T}(undef,size(A,1),size(B,2)) for i in 1:size(A,1) for j in 1:s…

---

## [Euler project - P 164](https://discourse.julialang.org/t/euler-project-p-164/30135)

<div class="topic-metadata">

**Author:** [@AlexanderChen](https://discourse.julialang.org/u/AlexanderChen)\
**Replies:** 30\
**Last updated:** [October 27, 2019, 4:31pm UTC](https://discourse.julialang.org/t/euler-project-p-164/30135 "2019-10-27T16:31:49Z")

</div>

Hi, I am doing some small algorithmic puzzles from the Euler Project. I have a working solution in code for P164 but it is so slow that I fear that I am doing something wrong. Could someone give me tips how to make my c…

---

## [Type stability with a vector of abstracts inside struct](https://discourse.julialang.org/t/type-stability-with-a-vector-of-abstracts-inside-struct/30353)

<div class="topic-metadata">

**Author:** [@abelsiqueira](https://discourse.julialang.org/u/abelsiqueira)\
**Replies:** 7\
**Last updated:** [October 28, 2019, 4:32am UTC](https://discourse.julialang.org/t/type-stability-with-a-vector-of-abstracts-inside-struct/30353 "2019-10-28T04:32:31Z")

</div>

Hi all, I appreciate any help in making the following code type stable: abstract type Something{T} end Base.eltype(:: Something{T}) where T = T mutable struct OneThing{T} \<: Something{T} α :: T end # HERE mutable s…

---

## [Iterate and intersect on BitSet vs Int](https://discourse.julialang.org/t/iterate-and-intersect-on-bitset-vs-int/30345)

<div class="topic-metadata">

**Author:** [@jeremiedb](https://discourse.julialang.org/u/jeremiedb)\
**Replies:** 11\
**Last updated:** [October 27, 2019, 9:23pm UTC](https://discourse.julialang.org/t/iterate-and-intersect-on-bitset-vs-int/30345 "2019-10-27T21:23:41Z")

</div>

I noticed that looping on a BitSet resulted in a significant slowdown (~10X) compared to the equivalent loop on Int64. This is resulting in undesirable performance tradeoff as intersect on the BitSets is significantly fa…

---

## [Brew a Parallel RNG?](https://discourse.julialang.org/t/brew-a-parallel-rng/30286)

<div class="topic-metadata">

**Author:** [@HaoLi111](https://discourse.julialang.org/u/HaoLi111)\
**Replies:** 20\
**Last updated:** [October 27, 2019, 8:31am UTC](https://discourse.julialang.org/t/brew-a-parallel-rng/30286 "2019-10-27T08:31:22Z")

</div>

RNGs cannot be parallelized without modification, as the effectiveness of the randomness representation ceases if the sequences are related. Previous discussions have been found from But can we use some alternative so…

---

## [Memory Error](https://discourse.julialang.org/t/memory-error/30251)

<div class="topic-metadata">

**Author:** [@natgeo-wong](https://discourse.julialang.org/u/natgeo-wong)\
**Replies:** 9\
**Last updated:** [October 24, 2019, 1:06pm UTC](https://discourse.julialang.org/t/memory-error/30251 "2019-10-24T13:06:16Z")

</div>

Hi! I am currently using Julia to download, extract and resort data. The procedure is as follows: For each day a) Download data for every hour b) Extract hourly data and combine into a single matrix c) From that s…

---

## [Data structures for threaded computing](https://discourse.julialang.org/t/data-structures-for-threaded-computing/30131)

<div class="topic-metadata">

**Author:** [@dataDiver](https://discourse.julialang.org/u/dataDiver)\
**Replies:** 23\
**Last updated:** [October 23, 2019, 7:32am UTC](https://discourse.julialang.org/t/data-structures-for-threaded-computing/30131 "2019-10-23T07:32:25Z")

</div>

I have noticed that I am not getting the correct multiple speedups I should be getting when using threads in Julia v1.3 rc4 for what are essentially independent calculations. When I try breaking up the matrices into arra…

---

## [Documentation for parallel computing - clarification](https://discourse.julialang.org/t/documentation-for-parallel-computing-clarification/30057)

<div class="topic-metadata">

**Author:** [@BioTurboNick](https://discourse.julialang.org/u/BioTurboNick)\
**Replies:** 3\
**Last updated:** [October 22, 2019, 4:43pm UTC](https://discourse.julialang.org/t/documentation-for-parallel-computing-clarification/30057 "2019-10-22T16:43:07Z")

</div>

Two bits of clarification. Are these two statements correct? All parallel functions require that the user has started worker processes separately with addprocs(). You need to add at least 2 worker processes to see …

---

## [Why does Juno make my code run slower than in VScode?](https://discourse.julialang.org/t/why-does-juno-make-my-code-run-slower-than-in-vscode/7846)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 18\
**Last updated:** [October 20, 2019, 9:29am UTC](https://discourse.julialang.org/t/why-does-juno-make-my-code-run-slower-than-in-vscode/7846 "2019-10-20T09:29:56Z")

</div>

I have the below code and I run it in Juno it takes 3.7 seconds and I run it in VScode it’s 1.48 seconds. Is the issue Juno? Does Juno intercept the results in such a way to make it run slower? Both are running Julia 0…

---

## [Code loading with workers and modules](https://discourse.julialang.org/t/code-loading-with-workers-and-modules/30064)

<div class="topic-metadata">

**Author:** [@BioTurboNick](https://discourse.julialang.org/u/BioTurboNick)\
**Replies:** 7\
**Last updated:** [October 19, 2019, 2:07pm UTC](https://discourse.julialang.org/t/code-loading-with-workers-and-modules/30064 "2019-10-19T14:07:10Z")

</div>

I’m a bit lost on how to load code into worker processes. I’m getting the error: KeyError: key \[mypackagename\] \[502b64d0-c436-11e9-3033-a3ceb19233e3\] not found This is resulting from a pmap call inside a function in an…

---

## [Managing Single and Multithreaded Implementations](https://discourse.julialang.org/t/managing-single-and-multithreaded-implementations/30083)

<div class="topic-metadata">

**Author:** [@sjkelly](https://discourse.julialang.org/u/sjkelly)\
**Replies:** 1\
**Last updated:** [October 19, 2019, 4:07pm UTC](https://discourse.julialang.org/t/managing-single-and-multithreaded-implementations/30083 "2019-10-19T16:07:13Z")

</div>

As a library maintainer what are some good idioms for managing implementations of single threaded and multi threaded algorithm implementations? Yesterday I implemented an algorithm three ways, with channels, locks, and …

---

## [Xor performance](https://discourse.julialang.org/t/xor-performance/29830)

<div class="topic-metadata">

**Author:** [@lalvim](https://discourse.julialang.org/u/lalvim)\
**Replies:** 3\
**Last updated:** [October 18, 2019, 6:40pm UTC](https://discourse.julialang.org/t/xor-performance/29830 "2019-10-18T18:40:08Z")

</div>

Hello. I am developing a method that uses a compact representation of bitwise arrays instead of using boolean or even float vectors. One of the advantages, besides compression, is the xor operation that operates efficien…

---

## [Parallelizing a force assembly function](https://discourse.julialang.org/t/parallelizing-a-force-assembly-function/29752)

<div class="topic-metadata">

**Author:** [@touste](https://discourse.julialang.org/u/touste)\
**Replies:** 11\
**Last updated:** [October 17, 2019, 7:59pm UTC](https://discourse.julialang.org/t/parallelizing-a-force-assembly-function/29752 "2019-10-17T19:59:20Z")

</div>

Hello, I am writing a physical simulation code that I’m trying to optimize. The most critical function, called at every integration step, is the force assembly: for every triangle of the mesh, given the nodal positions,…

---

## [Using Makie.jl multithreaded](https://discourse.julialang.org/t/using-makie-jl-multithreaded/29968)

<div class="topic-metadata">

**Author:** [@fishy](https://discourse.julialang.org/u/fishy)\
**Replies:** 0\
**Last updated:** [October 16, 2019, 2:43am UTC](https://discourse.julialang.org/t/using-makie-jl-multithreaded/29968 "2019-10-16T02:43:01Z")

</div>

I am using Julia for a 6DOF vehicle simulation which is just fast enough to run in real-time. After performing a simulation I am visualising the results using Makie.jl. To demo the simulator I have modified it to accept…

---

## [Benchmark MATLAB & Julia for Matrix Operations](https://discourse.julialang.org/t/benchmark-matlab-julia-for-matrix-operations/2000)

<div class="topic-metadata">

**Author:** [@RoyiAvital](https://discourse.julialang.org/u/RoyiAvital)\
**Replies:** 148\
**Last updated:** [October 15, 2019, 8:00pm UTC](https://discourse.julialang.org/t/benchmark-matlab-julia-for-matrix-operations/2000 "2019-10-15T20:00:15Z")

</div>

Hi, My first try with Julia was to compare its speed on Matrix Operations (Linear Algebra oriented) to MATLAB. Benchmark MATLAB & Julia for Matrix Operations As any test, it is far from being perfect, but it is tellin…

---

## [Numpy 10x faster than Julia ?! What am I doing wrong ?! \[solved - julia faster now\]](https://discourse.julialang.org/t/numpy-10x-faster-than-julia-what-am-i-doing-wrong-solved-julia-faster-now/29922)

<div class="topic-metadata">

**Author:** [@joak](https://discourse.julialang.org/u/joak)\
**Replies:** 37\
**Last updated:** [October 15, 2019, 11:52am UTC](https://discourse.julialang.org/t/numpy-10x-faster-than-julia-what-am-i-doing-wrong-solved-julia-faster-now/29922 "2019-10-15T11:52:25Z")

</div>

With numpy I get ~100ns per element With julia ~1200ns I must be missing something… How can I reach same speed with julia ? Code below: Python: import time import numpy as np from numpy import sin, cos def f(p): …

---

## [Good Practises for making performant DSL's? (My Dissertation Topic)](https://discourse.julialang.org/t/good-practises-for-making-performant-dsls-my-dissertation-topic/29832)

<div class="topic-metadata">

**Author:** [@Specs](https://discourse.julialang.org/u/Specs)\
**Replies:** 2\
**Last updated:** [October 12, 2019, 10:21pm UTC](https://discourse.julialang.org/t/good-practises-for-making-performant-dsls-my-dissertation-topic/29832 "2019-10-12T22:21:18Z")

</div>

Hiya, I’m currently a final year student and my supervisor is into scientific computing. He has a tool that makes heavy use of a DSL written into python and he wants me to investigate whether writing DSL’s in Julia are …

---

## [Performance of (a::AbstractType)(args...) function declarations](https://discourse.julialang.org/t/performance-of-a-abstracttype-args-function-declarations/29825)

<div class="topic-metadata">

**Author:** [@grahamas](https://discourse.julialang.org/u/grahamas)\
**Replies:** 3\
**Last updated:** [October 12, 2019, 6:45pm UTC](https://discourse.julialang.org/t/performance-of-a-abstracttype-args-function-declarations/29825 "2019-10-12T18:45:12Z")

</div>

I just finished refactoring my code to replace a lot of function calls of the form f(a::AbstractType, args…) with (a::AbstractType)(args…) since I can do that in 1.3, and it works out to slightly cleaner code. However, …

---

## [Bad performance in simple array broadcast operations](https://discourse.julialang.org/t/bad-performance-in-simple-array-broadcast-operations/29771)

<div class="topic-metadata">

**Author:** [@tomas.bolano](https://discourse.julialang.org/u/tomas.bolano)\
**Replies:** 5\
**Last updated:** [October 12, 2019, 11:40am UTC](https://discourse.julialang.org/t/bad-performance-in-simple-array-broadcast-operations/29771 "2019-10-12T11:40:37Z")

</div>

Hi, I was rewriting some Matlab code into Julia, and I noticed that one function which used array broadcasting operations ran several times slower on Julia. I though this was really strange and I made a simple test func…

---

## [Performance comparison with C++](https://discourse.julialang.org/t/performance-comparison-with-c/29682)

<div class="topic-metadata">

**Author:** [@gcalderone](https://discourse.julialang.org/u/gcalderone)\
**Replies:** 8\
**Last updated:** [October 10, 2019, 8:39am UTC](https://discourse.julialang.org/t/performance-comparison-with-c/29682 "2019-10-10T08:39:40Z")

</div>

I found a very simple task where the Julia performances are unexpectedly and significantly worse than C++. The core function to be benchmarked is as follows: function subr!(d1, nx, ny, d2) for iy in 1:ny fo…

---

## [Consistent 2x Slowdown with v1.2](https://discourse.julialang.org/t/consistent-2x-slowdown-with-v1-2/29535)

<div class="topic-metadata">

**Author:** [@swishmas](https://discourse.julialang.org/u/swishmas)\
**Replies:** 6\
**Last updated:** [October 10, 2019, 5:55am UTC](https://discourse.julialang.org/t/consistent-2x-slowdown-with-v1-2/29535 "2019-10-10T05:55:54Z")

</div>

Hi there, I have been working on some code (~4,000 lines) for a while, and I was excited about the upcoming changes to the parallelization in v1.3. I felt I had very efficient code on v1.1(.1), but when I run the code …

---

## [Transducers, paralelism and feedback loop](https://discourse.julialang.org/t/transducers-paralelism-and-feedback-loop/28189)

<div class="topic-metadata">

**Author:** [@Janis\_Erdmanis](https://discourse.julialang.org/u/Janis_Erdmanis)\
**Replies:** 13\
**Last updated:** [October 9, 2019, 3:26am UTC](https://discourse.julialang.org/t/transducers-paralelism-and-feedback-loop/28189 "2019-10-09T03:26:30Z")

</div>

After watching the JuliaCon talk on Transducers.jl, I started to wonder about multiple cases where iterators are not optimal. One of the instances that seem suited for transducers are the systems with a feedback loop. L…

---

## [Consistent performance difference but identical LLVM IR](https://discourse.julialang.org/t/consistent-performance-difference-but-identical-llvm-ir/29620)

<div class="topic-metadata">

**Author:** [@milesf](https://discourse.julialang.org/u/milesf)\
**Replies:** 4\
**Last updated:** [October 8, 2019, 12:20am UTC](https://discourse.julialang.org/t/consistent-performance-difference-but-identical-llvm-ir/29620 "2019-10-08T00:20:35Z")

</div>

I am attempting to write a high-performance round-up function that treats Int64 and UInt64 identically. The compiled output is the same, but performance is always worse with UInt. It’s only a 10% difference, but it’s sur…

---

## [OpenBLAS vs. "for loops" demo](https://discourse.julialang.org/t/openblas-vs-for-loops-demo/29581)

<div class="topic-metadata">

**Author:** [@Iulian.Cioarca](https://discourse.julialang.org/u/Iulian.Cioarca)\
**Replies:** 6\
**Last updated:** [October 7, 2019, 2:07pm UTC](https://discourse.julialang.org/t/openblas-vs-for-loops-demo/29581 "2019-10-07T14:07:12Z")

</div>

I am preparing a presentation/demo for an upcoming meetup and want to showcase that “for loops” in Julia are fast. How fast? Fast enough to write simple code that compares to BLAS routines. So I decided to implement a “…

---

## [Compare julia sum to a cpp implementation - julia is extremely slow?!](https://discourse.julialang.org/t/compare-julia-sum-to-a-cpp-implementation-julia-is-extremely-slow/29398)

<div class="topic-metadata">

**Author:** [@stakaz](https://discourse.julialang.org/u/stakaz)\
**Replies:** 35\
**Last updated:** [October 7, 2019, 9:18am UTC](https://discourse.julialang.org/t/compare-julia-sum-to-a-cpp-implementation-julia-is-extremely-slow/29398 "2019-10-07T09:18:29Z")

</div>

Hello, I am about to test the speed of a simple summation function of a 2D array in cpp and julia. However I see that julia code is becoming slower as the array increases while cpp code remains const in time. Could some…

---

## [Situations where mutable struct is more performant than immutable struct](https://discourse.julialang.org/t/situations-where-mutable-struct-is-more-performant-than-immutable-struct/29504)

<div class="topic-metadata">

**Author:** [@milesf](https://discourse.julialang.org/u/milesf)\
**Replies:** 6\
**Last updated:** [October 5, 2019, 8:44pm UTC](https://discourse.julialang.org/t/situations-where-mutable-struct-is-more-performant-than-immutable-struct/29504 "2019-10-05T20:44:08Z")

</div>

Wanted to highlight a situation where mutable structs offer better performance than immutable structs. If sorting an array of structs with many isbits fields, the immutable copy cost outweighs the mutable indirection co…

---

## [Large programs: structuring modules & include such that to increase performance and readability](https://discourse.julialang.org/t/large-programs-structuring-modules-include-such-that-to-increase-performance-and-readability/29102)

<div class="topic-metadata">

**Author:** [@JosephPollacco](https://discourse.julialang.org/u/JosephPollacco)\
**Replies:** 14\
**Last updated:** [October 4, 2019, 9:43am UTC](https://discourse.julialang.org/t/large-programs-structuring-modules-include-such-that-to-increase-performance-and-readability/29102 "2019-10-04T09:43:59Z")

</div>

I am writing a large hydrological model for which I require to divide the program in many modules incorporated in individual files. I am questioning what will be an efficient and readable approach to share the modules a…

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

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