# Performance

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

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

**Page:** 134

---

## [Feedforward NN using StaticArrays with no allocation](https://discourse.julialang.org/t/feedforward-nn-using-staticarrays-with-no-allocation/20036)

<div class="topic-metadata">

**Author:** [@bender9000](https://discourse.julialang.org/u/bender9000)\
**Replies:** 5\
**Last updated:** [January 24, 2019, 3:02pm UTC](https://discourse.julialang.org/t/feedforward-nn-using-staticarrays-with-no-allocation/20036 "2019-01-24T15:02:20Z")

</div>

I am writing a performance sensitive application that cannot have any allocations which also runs inference using a multi layered perceptron. The dimensions of each layers output in Neural Network are fairly small and be…

---

## [Could Transducers help here?](https://discourse.julialang.org/t/could-transducers-help-here/19986)

<div class="topic-metadata">

**Author:** [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Replies:** 4\
**Last updated:** [January 23, 2019, 9:02pm UTC](https://discourse.julialang.org/t/could-transducers-help-here/19986 "2019-01-23T21:02:00Z")

</div>

I’m trying to get a finer understanding of where Transducers.jl can help, especially by comparison to explicit loops and iterators. Here is a small example (freely adapted from advent of code, day 6, part2). A version …

---

## [ANN: Anyone need my 2.7x faster factorial (or gamma) function?](https://discourse.julialang.org/t/ann-anyone-need-my-2-7x-faster-factorial-or-gamma-function/19926)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 22\
**Last updated:** [January 23, 2019, 6:23pm UTC](https://discourse.julialang.org/t/ann-anyone-need-my-2-7x-faster-factorial-or-gamma-function/19926 "2019-01-23T18:23:16Z")

</div>

I was looking into faster code generation (not factorial specifically, but started with that function). It took a lot longer than it seemed it would at first. Anyway the Julia PR was closed, but I have more recent code,…

---

## [Precompile() for function with kwargs](https://discourse.julialang.org/t/precompile-for-function-with-kwargs/19857)

<div class="topic-metadata">

**Author:** [@orange\_si](https://discourse.julialang.org/u/orange_si)\
**Replies:** 4\
**Last updated:** [January 23, 2019, 11:10am UTC](https://discourse.julialang.org/t/precompile-for-function-with-kwargs/19857 "2019-01-23T11:10:15Z")

</div>

hi everyone, I am using julia 1.0.2, and try to precompile for function. precompile() works for function with args(no kwargs), but when have kwargs, it seems not worked, so how to precompile for function with kwargs? …

---

## [How to resolve type ambiguity with Optim results?](https://discourse.julialang.org/t/how-to-resolve-type-ambiguity-with-optim-results/19856)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 6\
**Last updated:** [January 22, 2019, 6:28am UTC](https://discourse.julialang.org/t/how-to-resolve-type-ambiguity-with-optim-results/19856 "2019-01-22T06:28:39Z")

</div>

I am optimizing a function inside another function. I need to obtain and save the results of that optimization. However the compiler does not infer the type of those results. I am obtaining these instances of Any in the @…

---

## [Performance with nested QuadGK integrals](https://discourse.julialang.org/t/performance-with-nested-quadgk-integrals/19889)

<div class="topic-metadata">

**Author:** [@hjabird](https://discourse.julialang.org/u/hjabird)\
**Replies:** 2\
**Last updated:** [January 21, 2019, 9:49pm UTC](https://discourse.julialang.org/t/performance-with-nested-quadgk-integrals/19889 "2019-01-21T21:49:43Z")

</div>

I encountered a performance issue whilst working. I’ve managed to produce a minimal example of my code that reproduces a performance issue. I have a file bug.jl: import QuadGK function inner\_integrand() function in…

---

## [Writing a SIMD friendly iterate function](https://discourse.julialang.org/t/writing-a-simd-friendly-iterate-function/19472)

<div class="topic-metadata">

**Author:** [@rgankema](https://discourse.julialang.org/u/rgankema)\
**Replies:** 6\
**Last updated:** [January 17, 2019, 4:51pm UTC](https://discourse.julialang.org/t/writing-a-simd-friendly-iterate-function/19472 "2019-01-17T16:51:58Z")

</div>

Hi everyone, For a project I’m working on I have a datastructure with an AbstractArray interface that internally stores its data in a Vector of Vectors (more precisly, it uses a fixed-size arrays, but that doesn’t matte…

---

## [Vector of matrices vs. multidimensional arrays](https://discourse.julialang.org/t/vector-of-matrices-vs-multidimensional-arrays/9602)

<div class="topic-metadata">

**Author:** [@plapplop](https://discourse.julialang.org/u/plapplop)\
**Replies:** 13\
**Last updated:** [January 17, 2019, 12:05pm UTC](https://discourse.julialang.org/t/vector-of-matrices-vs-multidimensional-arrays/9602 "2019-01-17T12:05:24Z")

</div>

I have to deal with 3 dimensional structures, I was hesitating between vectors of vectors of vectors, vectors of matrices or tridimensional arrays. For performance comparison, I wrote this small test: julia\> L = M = N =…

---

## [Work around splatting to avoid unecessary allocations](https://discourse.julialang.org/t/work-around-splatting-to-avoid-unecessary-allocations/19708)

<div class="topic-metadata">

**Author:** [@konkam](https://discourse.julialang.org/u/konkam)\
**Replies:** 2\
**Last updated:** [January 16, 2019, 4:48pm UTC](https://discourse.julialang.org/t/work-around-splatting-to-avoid-unecessary-allocations/19708 "2019-01-16T16:48:19Z")

</div>

Hello everyone, I am trying to call Base.Iterators.product on a number of arguments which is not fixed in advance, i.e. to call the following function on integer vectors of arbitrary length. function indices\_below(Λ\_ma…

---

## [Avoid recalculating X^q when f(p): X.^1 ... X.^p](https://discourse.julialang.org/t/avoid-recalculating-x-q-when-f-p-x-1-x-p/19491)

<div class="topic-metadata">

**Author:** [@taqtiqa-mark](https://discourse.julialang.org/u/taqtiqa-mark)\
**Replies:** 7\
**Last updated:** [January 16, 2019, 4:36am UTC](https://discourse.julialang.org/t/avoid-recalculating-x-q-when-f-p-x-1-x-p/19491 "2019-01-16T04:36:10Z")

</div>

Wasn’t sure if this belongs in first-steps or performance - happy to move it… What is best practice implementation of the following in Julia. The objective is to minimize run time. There is no requirement that this be…

---

## [Poor performance due to memory allocations?](https://discourse.julialang.org/t/poor-performance-due-to-memory-allocations/19629)

<div class="topic-metadata">

**Author:** [@mirzadeh](https://discourse.julialang.org/u/mirzadeh)\
**Replies:** 17\
**Last updated:** [January 15, 2019, 6:36pm UTC](https://discourse.julialang.org/t/poor-performance-due-to-memory-allocations/19629 "2019-01-15T18:36:13Z")

</div>

Hello! I have recently started using Julia and decided to do a simple example to test my understanding of the language and performance pitfalls. The example is a simple Jacobi relaxation for solving the Poisson’s equati…

---

## [Help understanding failed optimization when defining Base.similar for AbstractArray interface](https://discourse.julialang.org/t/help-understanding-failed-optimization-when-defining-base-similar-for-abstractarray-interface/19625)

<div class="topic-metadata">

**Author:** [@raminammour](https://discourse.julialang.org/u/raminammour)\
**Replies:** 1\
**Last updated:** [January 14, 2019, 5:00pm UTC](https://discourse.julialang.org/t/help-understanding-failed-optimization-when-defining-base-similar-for-abstractarray-interface/19625 "2019-01-14T17:00:31Z")

</div>

Hello, I encountered this behavior that I don’t understand. I am defining a wrapper around an array and using the AbstractArray interface: abstract type aw{T,N} \<: AbstractArray{T,N} end struct wrap2{T,N} \<: aw{T,N} …

---

## [Performance of matrix division](https://discourse.julialang.org/t/performance-of-matrix-division/19477)

<div class="topic-metadata">

**Author:** [@judober](https://discourse.julialang.org/u/judober)\
**Replies:** 8\
**Last updated:** [January 12, 2019, 10:15pm UTC](https://discourse.julialang.org/t/performance-of-matrix-division/19477 "2019-01-12T22:15:26Z")

</div>

I have a question regarding the performance of matrix division (/). During some calculations, I noticed a huge impact of 3x3-Matrix divisions compared to expectations I had from a similar matlab program. Therefore, I ma…

---

## [Comparison performance with \`any\`](https://discourse.julialang.org/t/comparison-performance-with-any/19478)

<div class="topic-metadata">

**Author:** [@MLackner](https://discourse.julialang.org/u/MLackner)\
**Replies:** 5\
**Last updated:** [January 11, 2019, 11:20am UTC](https://discourse.julialang.org/t/comparison-performance-with-any/19478 "2019-01-11T11:20:43Z")

</div>

Hey! How can I prevent this loop from allocating memory on every iteration? If I interchange @view b\[i-1:i\] with just b the loop does not allocate but that’s not what I want :wink:. I don’t really understand this behav…

---

## [Efficient looping statement in Julia](https://discourse.julialang.org/t/efficient-looping-statement-in-julia/19420)

<div class="topic-metadata">

**Author:** [@chuljang](https://discourse.julialang.org/u/chuljang)\
**Replies:** 15\
**Last updated:** [January 10, 2019, 1:04am UTC](https://discourse.julialang.org/t/efficient-looping-statement-in-julia/19420 "2019-01-10T01:04:15Z")

</div>

Happy new year to all. I have a quick question about writing effcient looping code. To describe a problem, let me use a simple for looping statement which check if a number is even and store that number into an array (r…

---

## [Interpolation of callbacks is slow and blows up memory in DifferentialEquations.jl](https://discourse.julialang.org/t/interpolation-of-callbacks-is-slow-and-blows-up-memory-in-differentialequations-jl/19251)

<div class="topic-metadata">

**Author:** [@michaelkyu](https://discourse.julialang.org/u/michaelkyu)\
**Replies:** 4\
**Last updated:** [January 7, 2019, 9:20am UTC](https://discourse.julialang.org/t/interpolation-of-callbacks-is-slow-and-blows-up-memory-in-differentialequations-jl/19251 "2019-01-07T09:20:17Z")

</div>

I’ve found that the interpolation in the Callbacks interface of DifferentialEquations.jl can slow down performance and blow up the memory allocations. To demonstrate, I’ll use the cosine/sine example from the Callbacks…

---

## [Combining @pure and @inline](https://discourse.julialang.org/t/combining-pure-and-inline/19331)

<div class="topic-metadata">

**Author:** [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Replies:** 1\
**Last updated:** [January 6, 2019, 9:16pm UTC](https://discourse.julialang.org/t/combining-pure-and-inline/19331 "2019-01-06T21:16:24Z")

</div>

If I use @pure, would @inline be superfluous? If not, in which order should they be used? @pure @inline or @inline @pure

---

## [No typeinference for object call syntax](https://discourse.julialang.org/t/no-typeinference-for-object-call-syntax/19322)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 2\
**Last updated:** [January 6, 2019, 1:30pm UTC](https://discourse.julialang.org/t/no-typeinference-for-object-call-syntax/19322 "2019-01-06T13:30:37Z")

</div>

I have problems getting type-inference to work when replacing a function with a function object. The purpose is to add an extra AbstractType to improve dispatch. However nothing I tried so far works. Any help is highly…

---

## [SharedArrays. Stability](https://discourse.julialang.org/t/sharedarrays-stability/19304)

<div class="topic-metadata">

**Author:** [@xanfus](https://discourse.julialang.org/u/xanfus)\
**Replies:** 2\
**Last updated:** [January 5, 2019, 2:39pm UTC](https://discourse.julialang.org/t/sharedarrays-stability/19304 "2019-01-05T14:39:09Z")

</div>

I’ve conducted package upgrade from official repositories on 21 Dec. I ran Julia v0.7.0 and i’d noticed one of my SharedArray’s had returned procs(S)=Int64\[0\]. I’d migrated to Julia v1.0.3. Same thing. I’d put @info’s a…

---

## [Performance of generator expressions and higher order functions](https://discourse.julialang.org/t/performance-of-generator-expressions-and-higher-order-functions/19189)

<div class="topic-metadata">

**Author:** [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Replies:** 7\
**Last updated:** [January 4, 2019, 11:56pm UTC](https://discourse.julialang.org/t/performance-of-generator-expressions-and-higher-order-functions/19189 "2019-01-04T23:56:15Z")

</div>

Hello, while trying to optimize some Julia code I wrote, I encountered several performance issues all following the same kind of pattern, related to using higher-order functions and generator expressions nested within a…

---

## [Power function not inlined optimally](https://discourse.julialang.org/t/power-function-not-inlined-optimally/19264)

<div class="topic-metadata">

**Author:** [@Bernard\_GODARD](https://discourse.julialang.org/u/Bernard_GODARD)\
**Replies:** 5\
**Last updated:** [January 4, 2019, 4:26pm UTC](https://discourse.julialang.org/t/power-function-not-inlined-optimally/19264 "2019-01-04T16:26:18Z")

</div>

The following function: julia\> f(x)=x^5, x^3 f (generic function with 1 method) is compiled into: julia\> @code\_llvm f(2) ; Function f ; Location: REPL\[10\]:1 define void @julia\_f\_35717(\[2 x i64\]\* noalias nocapture sre…

---

## [Implementing own \`size()\` function for a \`struct\` and its performance](https://discourse.julialang.org/t/implementing-own-size-function-for-a-struct-and-its-performance/19008)

<div class="topic-metadata">

**Author:** [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Replies:** 14\
**Last updated:** [January 4, 2019, 8:45am UTC](https://discourse.julialang.org/t/implementing-own-size-function-for-a-struct-and-its-performance/19008 "2019-01-04T08:45:20Z")

</div>

I am trying to have a struct for one of my types, that (among others for the nonMWE) keeps an array as a value. I would like to have a size function that works on the encapsulated array. The MWE is as follows import Bas…

---

## [Prefered pattern for generators?](https://discourse.julialang.org/t/prefered-pattern-for-generators/18749)

<div class="topic-metadata">

**Author:** [@ninjaaron](https://discourse.julialang.org/u/ninjaaron)\
**Replies:** 12\
**Last updated:** [January 3, 2019, 5:40pm UTC](https://discourse.julialang.org/t/prefered-pattern-for-generators/18749 "2019-01-03T17:40:53Z")

</div>

Hi. First thread. we all know the generator pattern from Python and elsewhere. def mygenerator(): for i in range(10): yield i I know the “proper” way to do this is to write a struct with a method on Base.i…

---

## [Type stability issues when using StaticArrays](https://discourse.julialang.org/t/type-stability-issues-when-using-staticarrays/19126)

<div class="topic-metadata">

**Author:** [@aortizb](https://discourse.julialang.org/u/aortizb)\
**Replies:** 24\
**Last updated:** [January 3, 2019, 3:36pm UTC](https://discourse.julialang.org/t/type-stability-issues-when-using-staticarrays/19126 "2019-01-03T15:36:34Z")

</div>

Hi all: looking at some piece of a code I am developing, I wanted to make sure that there is no type stability issues. So, in the process of reviewing of my code I found a type stability issue when using StaticArrays. Be…

---

## [How to use getproperty efficiently?](https://discourse.julialang.org/t/how-to-use-getproperty-efficiently/19177)

<div class="topic-metadata">

**Author:** [@anon43133060](https://discourse.julialang.org/u/anon43133060)\
**Replies:** 10\
**Last updated:** [January 2, 2019, 4:11pm UTC](https://discourse.julialang.org/t/how-to-use-getproperty-efficiently/19177 "2019-01-02T16:11:15Z")

</div>

Inspired by Zero-Cost Abstractions I tried to implement field based access for a dictionary. It kinda works, but could it be improved? Why isn’t the last function working as fast as it should? I’m using julia v1.0.3. us…

---

## [Type stable code is more expensive than type unstable code. Why?](https://discourse.julialang.org/t/type-stable-code-is-more-expensive-than-type-unstable-code-why/19171)

<div class="topic-metadata">

**Author:** [@aortizb](https://discourse.julialang.org/u/aortizb)\
**Replies:** 4\
**Last updated:** [January 1, 2019, 9:00pm UTC](https://discourse.julialang.org/t/type-stable-code-is-more-expensive-than-type-unstable-code-why/19171 "2019-01-01T21:00:27Z")

</div>

I wrote a small code (following the advices I got from other post) just for learning some things about type stability. The two first definitions of foo() are type stable. The third definition is not. However, the type un…

---

## [Optimizing iteration over slices of multiple matrices](https://discourse.julialang.org/t/optimizing-iteration-over-slices-of-multiple-matrices/19096)

<div class="topic-metadata">

**Author:** [@mateuszbaran](https://discourse.julialang.org/u/mateuszbaran)\
**Replies:** 14\
**Last updated:** [December 30, 2018, 6:03pm UTC](https://discourse.julialang.org/t/optimizing-iteration-over-slices-of-multiple-matrices/19096 "2018-12-30T18:03:49Z")

</div>

I’m trying to optimize some of my code. A common pattern is performing an operation column-wise or row-wise across multiple arrays. Here is a very simplified piece of code: using BenchmarkTools using LinearAlgebra func…

---

## [Jacobian of StaticArray function becoming type-unstable](https://discourse.julialang.org/t/jacobian-of-staticarray-function-becoming-type-unstable/19045)

<div class="topic-metadata">

**Author:** [@xor0110](https://discourse.julialang.org/u/xor0110)\
**Replies:** 3\
**Last updated:** [December 28, 2018, 9:44am UTC](https://discourse.julialang.org/t/jacobian-of-staticarray-function-becoming-type-unstable/19045 "2018-12-28T09:44:16Z")

</div>

I’m trying to remove allocations from this optimization code where I’m using ForwardDiff to calculate a Jacobian matrix, and I seem to have found some corner case where the Jacobian becomes type-unstable even though each…

---

## [How to use @inbounds?](https://discourse.julialang.org/t/how-to-use-inbounds/19048)

<div class="topic-metadata">

**Author:** [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Replies:** 2\
**Last updated:** [December 28, 2018, 2:29am UTC](https://discourse.julialang.org/t/how-to-use-inbounds/19048 "2018-12-28T02:29:29Z")

</div>

julia\> f(x,y) = sqrt( x^2 + y^2 ); julia\> xset= 10:11; yset= 12:13; i= 1; julia\> m= Matrix{Float64}(undef, length(xset)\*length(yset), 3); size(m) (4,3) julia\> for x in xset for y in yset glo…

---

## [Unnecessary allocations happening at big StaticArray expression](https://discourse.julialang.org/t/unnecessary-allocations-happening-at-big-staticarray-expression/19005)

<div class="topic-metadata">

**Author:** [@xor0110](https://discourse.julialang.org/u/xor0110)\
**Replies:** 3\
**Last updated:** [December 27, 2018, 6:41pm UTC](https://discourse.julialang.org/t/unnecessary-allocations-happening-at-big-staticarray-expression/19005 "2018-12-27T18:41:07Z")

</div>

I’m thinking this might actually be a bug report… I am working with matrix exponentiation, adapting the original Julia function first to be able to use ForwardDiff, and now trying to optimize the code as much as I can. M…

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

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