# Performance

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

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

**Page:** 120

---

## [Performance of power as function input](https://discourse.julialang.org/t/performance-of-power-as-function-input/35852)

<div class="topic-metadata">

**Author:** [@MrUrq](https://discourse.julialang.org/u/MrUrq)\
**Replies:** 3\
**Last updated:** [March 12, 2020, 7:54am UTC](https://discourse.julialang.org/t/performance-of-power-as-function-input/35852 "2020-03-12T07:54:01Z")

</div>

Hi, I have a performance regression when including the power of a function as an input argument. I have boiled it down to something like this: function f1(X) n,d = size(X) dist = 0.0 for i = 2:n fo…

---

## [Unexpected allocations in looped vs broadcasted functions on tuples of arrays](https://discourse.julialang.org/t/unexpected-allocations-in-looped-vs-broadcasted-functions-on-tuples-of-arrays/35855)

<div class="topic-metadata">

**Author:** [@jlchan](https://discourse.julialang.org/u/jlchan)\
**Replies:** 4\
**Last updated:** [March 12, 2020, 7:09am UTC](https://discourse.julialang.org/t/unexpected-allocations-in-looped-vs-broadcasted-functions-on-tuples-of-arrays/35855 "2020-03-12T07:09:53Z")

</div>

I have a function which operates on tuples of arrays using broadcasting, but I’m rewriting it because it doesn’t play well with ForwardDiff.jl. However, I’ve noticed that version which loops through array entries is slo…

---

## [Division isn't auto-vectorized when function inlined](https://discourse.julialang.org/t/division-isnt-auto-vectorized-when-function-inlined/35818)

<div class="topic-metadata">

**Author:** [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Replies:** 12\
**Last updated:** [March 11, 2020, 1:54pm UTC](https://discourse.julialang.org/t/division-isnt-auto-vectorized-when-function-inlined/35818 "2020-03-11T13:54:34Z")

</div>

I’m attempting to rewrite the benchmarks game spectralnorm implementation without relying on llvmcall for vectorization. I got close to the performance, but it requires awkwardly doing division in a helper function annot…

---

## [Can I make this function even faster?](https://discourse.julialang.org/t/can-i-make-this-function-even-faster/35813)

<div class="topic-metadata">

**Author:** [@zxjroger](https://discourse.julialang.org/u/zxjroger)\
**Replies:** 5\
**Last updated:** [March 10, 2020, 10:43pm UTC](https://discourse.julialang.org/t/can-i-make-this-function-even-faster/35813 "2020-03-10T22:43:38Z")

</div>

I have the following function which will be evaluated thousands of times in a for loop. This function will generate a vector. Each element in this vector is computed by some algebra of some elements in two different matr…

---

## [How can I improve the speed of large matrix multiplication](https://discourse.julialang.org/t/how-can-i-improve-the-speed-of-large-matrix-multiplication/35616)

<div class="topic-metadata">

**Author:** [@zxjroger](https://discourse.julialang.org/u/zxjroger)\
**Replies:** 6\
**Last updated:** [March 10, 2020, 5:17pm UTC](https://discourse.julialang.org/t/how-can-i-improve-the-speed-of-large-matrix-multiplication/35616 "2020-03-10T17:17:28Z")

</div>

I have some functions involving large matrix multiplication in my code. A sample code is as follows. function foo1() temp = Array\[\] for i = 1:1000 push!(temp, randn(400,400)\*randn(400,1000)) end end …

---

## [Strange codegen for type with small union fields](https://discourse.julialang.org/t/strange-codegen-for-type-with-small-union-fields/35773)

<div class="topic-metadata">

**Author:** [@Christian\_Rorvik](https://discourse.julialang.org/u/Christian_Rorvik)\
**Replies:** 0\
**Last updated:** [March 9, 2020, 9:43pm UTC](https://discourse.julialang.org/t/strange-codegen-for-type-with-small-union-fields/35773 "2020-03-09T21:43:00Z")

</div>

Context Working on an intrusive containers package, for users (like me) who need allocation free datastructures. Putting together the very beginnings of some expertiments I spotted some strange codegen behavior. Julia V…

---

## [Custom Type for lazy kernel operations on AbstractArrays, ho can i improve it?](https://discourse.julialang.org/t/custom-type-for-lazy-kernel-operations-on-abstractarrays-ho-can-i-improve-it/35764)

<div class="topic-metadata">

**Author:** [@francesco.alemanno](https://discourse.julialang.org/u/francesco.alemanno)\
**Replies:** 3\
**Last updated:** [March 9, 2020, 8:05pm UTC](https://discourse.julialang.org/t/custom-type-for-lazy-kernel-operations-on-abstractarrays-ho-can-i-improve-it/35764 "2020-03-09T20:05:01Z")

</div>

Hi guys is there any way to make this performant? it looks like a super useful type see Example of usage Type Definition struct KernelOp{T,N,S} \<: AbstractArray{T,N} parent::S op::Function opdims::CartesianI…

---

## [Pushing a function to its performance limit](https://discourse.julialang.org/t/pushing-a-function-to-its-performance-limit/35647)

<div class="topic-metadata">

**Author:** [@jmcastro2109](https://discourse.julialang.org/u/jmcastro2109)\
**Replies:** 16\
**Last updated:** [March 9, 2020, 12:20pm UTC](https://discourse.julialang.org/t/pushing-a-function-to-its-performance-limit/35647 "2020-03-09T12:20:40Z")

</div>

Hi! I am trying to push this code to be as efficient as possible. If I could achieve any performance gain it would be great because I am calling this function thousands of time. The problem is essentially a problem of b…

---

## [Keyword versus positional arguments](https://discourse.julialang.org/t/keyword-versus-positional-arguments/35538)

<div class="topic-metadata">

**Author:** [@aerdely](https://discourse.julialang.org/u/aerdely)\
**Replies:** 2\
**Last updated:** [March 7, 2020, 8:13pm UTC](https://discourse.julialang.org/t/keyword-versus-positional-arguments/35538 "2020-03-07T20:13:32Z")

</div>

Reviewing @avik Sengupta’s book «Julia High Performance» 2nd edition, it says that performance of functions with positional arguments is better than those with keyword (named) arguments, giving the following example: us…

---

## [Vararg vs Tuple{Vararg} performance](https://discourse.julialang.org/t/vararg-vs-tuple-vararg-performance/35670)

<div class="topic-metadata">

**Author:** [@SnoopyDoowop](https://discourse.julialang.org/u/SnoopyDoowop)\
**Replies:** 4\
**Last updated:** [March 7, 2020, 12:30am UTC](https://discourse.julialang.org/t/vararg-vs-tuple-vararg-performance/35670 "2020-03-07T00:30:09Z")

</div>

Hello! While trying out some things in the julia REPL to see how a\[i…\] = x is transformed into setindex!(a, x, i…). I came across multiple questions : I am wondering why the prototype of setindex! is setindex!(A::Abstr…

---

## [Working with MulAddMul](https://discourse.julialang.org/t/working-with-muladdmul/35668)

<div class="topic-metadata">

**Author:** [@bjack205](https://discourse.julialang.org/u/bjack205)\
**Replies:** 0\
**Last updated:** [March 6, 2020, 10:34pm UTC](https://discourse.julialang.org/t/working-with-muladdmul/35668 "2020-03-06T22:34:51Z")

</div>

I’m trying to implement the 5-argument mul! made available in Julia v1.3 on StaticArrays, and SizedArrays in particular. I’m trying to make use of LinearAlgebra.MulAddMul that is used throughout the matrix multiplication…

---

## [Varinfo() slow if variable large](https://discourse.julialang.org/t/varinfo-slow-if-variable-large/35585)

<div class="topic-metadata">

**Author:** [@Usor](https://discourse.julialang.org/u/Usor)\
**Replies:** 4\
**Last updated:** [March 6, 2020, 2:02pm UTC](https://discourse.julialang.org/t/varinfo-slow-if-variable-large/35585 "2020-03-06T14:02:36Z")

</div>

I’ve often had not-so-large DataFrames loaded, and performance with varinfo() was good. When a DataFrame exceeds a certain size, e.g. beyond 100 MB, varinfo() is very slow. (I didn’t check the exact size, but the one lo…

---

## [Why is Julia's generated assembly more complicated than Swift's for a simple function?](https://discourse.julialang.org/t/why-is-julias-generated-assembly-more-complicated-than-swifts-for-a-simple-function/35549)

<div class="topic-metadata">

**Author:** [@Aremk](https://discourse.julialang.org/u/Aremk)\
**Replies:** 16\
**Last updated:** [March 6, 2020, 3:10am UTC](https://discourse.julialang.org/t/why-is-julias-generated-assembly-more-complicated-than-swifts-for-a-simple-function/35549 "2020-03-06T03:10:47Z")

</div>

Consider the following example in swift, from: Redirecting to Google Groups func f() -\> \[Int\] { return \[0, 1\] } func testMe() -\> Int { var r = 0 for x in f() { r += x } return r } Accordi…

---

## [Guidance on profiling / benchmarking I/O opperations on sparse dataset](https://discourse.julialang.org/t/guidance-on-profiling-benchmarking-i-o-opperations-on-sparse-dataset/35483)

<div class="topic-metadata">

**Author:** [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Replies:** 11\
**Last updated:** [March 5, 2020, 2:12pm UTC](https://discourse.julialang.org/t/guidance-on-profiling-benchmarking-i-o-opperations-on-sparse-dataset/35483 "2020-03-05T14:12:20Z")

</div>

I have a specific data reading problem that I’m trying to improve. I’m not sure if the details are important or not, but here’s the gist: I have some number (high hundreds to low thousands) of indiviudual CSV files. Ea…

---

## [Getting all digits from a BigInt](https://discourse.julialang.org/t/getting-all-digits-from-a-bigint/35528)

<div class="topic-metadata">

**Author:** [@dmoura](https://discourse.julialang.org/u/dmoura)\
**Replies:** 3\
**Last updated:** [March 4, 2020, 5:54pm UTC](https://discourse.julialang.org/t/getting-all-digits-from-a-bigint/35528 "2020-03-04T17:54:23Z")

</div>

I am trying to collect and then sum all the digits from a BigInt. Example: sum all digits of 2^1000000 Intuitively, my first solution was using the digits function: @time sum(digits(BigInt(2)^1000000)) 29.189925 seco…

---

## [Slow parallel fractals](https://discourse.julialang.org/t/slow-parallel-fractals/35479)

<div class="topic-metadata">

**Author:** [@eaubanel](https://discourse.julialang.org/u/eaubanel)\
**Replies:** 7\
**Last updated:** [March 4, 2020, 12:25pm UTC](https://discourse.julialang.org/t/slow-parallel-fractals/35479 "2020-03-04T12:25:20Z")

</div>

Trying @threads and @distributed with my favourite parallel test case. Can’t figure out why @threads is so slow and allocates so much memory and why @distributed is so slow. function genFractal(α, n=100) niter = 255…

---

## [Composing a constructor causes tons of allocations](https://discourse.julialang.org/t/composing-a-constructor-causes-tons-of-allocations/35405)

<div class="topic-metadata">

**Author:** [@jules](https://discourse.julialang.org/u/jules)\
**Replies:** 2\
**Last updated:** [March 2, 2020, 8:14pm UTC](https://discourse.julialang.org/t/composing-a-constructor-causes-tons-of-allocations/35405 "2020-03-02T20:14:12Z")

</div>

I’m trying to build a pipeline of transformations and noticed this weird behavior when I plugged a Point2f0 constructor into the pipeline. I’ve removed the rest of the test pipeline and replaced it with the identity func…

---

## [Push! vs pushfirst! performance](https://discourse.julialang.org/t/push-vs-pushfirst-performance/35402)

<div class="topic-metadata">

**Author:** [@anon94023334](https://discourse.julialang.org/u/anon94023334)\
**Replies:** 5\
**Last updated:** [March 2, 2020, 8:07pm UTC](https://discourse.julialang.org/t/push-vs-pushfirst-performance/35402 "2020-03-02T20:07:21Z")

</div>

I was surprised at this performance: julia\> function p(x, n) for i = 1:n push!(x, i) end x end p (generic function with 1 method) julia\> function pf(x, n) …

---

## [Why does Julia not optimize this code when C++ (LLVM) can?](https://discourse.julialang.org/t/why-does-julia-not-optimize-this-code-when-c-llvm-can/35314)

<div class="topic-metadata">

**Author:** [@kdheepak](https://discourse.julialang.org/u/kdheepak)\
**Replies:** 14\
**Last updated:** [February 29, 2020, 7:08pm UTC](https://discourse.julialang.org/t/why-does-julia-not-optimize-this-code-when-c-llvm-can/35314 "2020-02-29T19:08:32Z")

</div>

When using a C++ compiler with LLVM version 6.0.0, the following code bool isEven(int n) { bool ret = true; for (int i = 0; i \< n; i ++) { ret = !ret; } return ret; } emits the LLVM IR define z…

---

## [Submatrix multiply](https://discourse.julialang.org/t/submatrix-multiply/35309)

<div class="topic-metadata">

**Author:** [@hytonwons](https://discourse.julialang.org/u/hytonwons)\
**Replies:** 7\
**Last updated:** [February 29, 2020, 7:14am UTC](https://discourse.julialang.org/t/submatrix-multiply/35309 "2020-02-29T07:14:48Z")

</div>

Hi, my algorithm involves a lot of submatrix multiply. I got inspired by the use of view, but the speedup of doing so is not that satisfying. Below is some sample code: If we just try slicing the matrix, the speedup is …

---

## [How would I parallelize a for loop that's iterating over columns of a dataframe](https://discourse.julialang.org/t/how-would-i-parallelize-a-for-loop-thats-iterating-over-columns-of-a-dataframe/35249)

<div class="topic-metadata">

**Author:** [@Julia1](https://discourse.julialang.org/u/Julia1)\
**Replies:** 5\
**Last updated:** [February 28, 2020, 7:37pm UTC](https://discourse.julialang.org/t/how-would-i-parallelize-a-for-loop-thats-iterating-over-columns-of-a-dataframe/35249 "2020-02-28T19:37:10Z")

</div>

Hi how’s it going? I’ve read up on Distributed.jl, adprocs, and @everywhere. I tried implementing parallelization of a function I have by making sure all the necessary packages, functions, and variables were preceded by…

---

## [Lightweight tasks, Julia vs Elixir/OTP](https://discourse.julialang.org/t/lightweight-tasks-julia-vs-elixir-otp/35082)

<div class="topic-metadata">

**Author:** [@pbayer](https://discourse.julialang.org/u/pbayer)\
**Replies:** 21\
**Last updated:** [February 27, 2020, 6:37pm UTC](https://discourse.julialang.org/t/lightweight-tasks-julia-vs-elixir-otp/35082 "2020-02-27T18:37:37Z")

</div>

I wanted to know, whether Julia can cope with Elixir/OTP lightweight tasks and made a comparison for chaining a lot of them following the example from “Programming in Elixir”. My Julia code is: function counter(next::…

---

## [Fast type-stable tensor products](https://discourse.julialang.org/t/fast-type-stable-tensor-products/35159)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 18\
**Last updated:** [February 27, 2020, 9:56am UTC](https://discourse.julialang.org/t/fast-type-stable-tensor-products/35159 "2020-02-27T09:56:51Z")

</div>

Let A and B be two multi-dimensional arrays. I want to form a product of them that contracts the last n dimensions of A with the first n dimensions of B. Calling this product C, one way to do it is with the following cod…

---

## [How to avoid unneccessary memory allocation for inplace estimation of \`mean\`?](https://discourse.julialang.org/t/how-to-avoid-unneccessary-memory-allocation-for-inplace-estimation-of-mean/35146)

<div class="topic-metadata">

**Author:** [@vpetukhov](https://discourse.julialang.org/u/vpetukhov)\
**Replies:** 12\
**Last updated:** [February 27, 2020, 12:13am UTC](https://discourse.julialang.org/t/how-to-avoid-unneccessary-memory-allocation-for-inplace-estimation-of-mean/35146 "2020-02-27T00:13:58Z")

</div>

I’m doing micro-optimization of my code, and current bottleneck is a place, where I call mean millions of times on small 2d arrays. And it leads to huge number of allocations. Simply re-implementing mean removes them all…

---

## [First time call of (precompiled) functions](https://discourse.julialang.org/t/first-time-call-of-precompiled-functions/35179)

<div class="topic-metadata">

**Author:** [@zhaoli-IHEP](https://discourse.julialang.org/u/zhaoli-IHEP)\
**Replies:** 0\
**Last updated:** [February 26, 2020, 3:54pm UTC](https://discourse.julialang.org/t/first-time-call-of-precompiled-functions/35179 "2020-02-26T15:54:06Z")

</div>

I have created a simple function in a module file “test.jl” module test export test0 function test0( s::Float64 )::Float64 return s\*100 end end Then I create another script main.jl to run this function using …

---

## [ForwardDiff.jacobian of softmax vs analytic Jacobian](https://discourse.julialang.org/t/forwarddiff-jacobian-of-softmax-vs-analytic-jacobian/35147)

<div class="topic-metadata">

**Author:** [@zxzkja](https://discourse.julialang.org/u/zxzkja)\
**Replies:** 0\
**Last updated:** [February 26, 2020, 1:18am UTC](https://discourse.julialang.org/t/forwarddiff-jacobian-of-softmax-vs-analytic-jacobian/35147 "2020-02-26T01:18:24Z")

</div>

I am trying out automatic differentiation on part of my code in place of the analytic derivative, but ForwardDiff.jacobian of softmax seems to take twice as long as the analytic Jacobian. I’m not sure if this is an expec…

---

## [Performance issue when storing function in a struct as a field](https://discourse.julialang.org/t/performance-issue-when-storing-function-in-a-struct-as-a-field/35122)

<div class="topic-metadata">

**Author:** [@Xing\_Shi\_Cai](https://discourse.julialang.org/u/Xing_Shi_Cai)\
**Replies:** 2\
**Last updated:** [February 25, 2020, 4:34pm UTC](https://discourse.julialang.org/t/performance-issue-when-storing-function-in-a-struct-as-a-field/35122 "2020-02-25T16:34:19Z")

</div>

I have a bit of code like this. In the function simulation, I generate a random tree and count the size of each subtree. Then I sim.func to the subtree sizes and add it up. I mostly need sim.func=log. But to have some f…

---

## [What's the best way to work with millions of rows of data?](https://discourse.julialang.org/t/whats-the-best-way-to-work-with-millions-of-rows-of-data/35075)

<div class="topic-metadata">

**Author:** [@Julia1](https://discourse.julialang.org/u/Julia1)\
**Replies:** 7\
**Last updated:** [February 24, 2020, 8:38pm UTC](https://discourse.julialang.org/t/whats-the-best-way-to-work-with-millions-of-rows-of-data/35075 "2020-02-24T20:38:44Z")

</div>

Hi how’s it going? I made a prototype of an app using the DataFrames.jl package. The data was about 100,000 rows. I need to scale this up to millions, possibly hundreds of millions of rows. I don’t know too much about h…

---

## [How can I reduce memory allocation and execution time while ray tracing using VoxelRayTracers package?](https://discourse.julialang.org/t/how-can-i-reduce-memory-allocation-and-execution-time-while-ray-tracing-using-voxelraytracers-package/34971)

<div class="topic-metadata">

**Author:** [@Manu\_Francis](https://discourse.julialang.org/u/Manu_Francis)\
**Replies:** 4\
**Last updated:** [February 23, 2020, 9:55am UTC](https://discourse.julialang.org/t/how-can-i-reduce-memory-allocation-and-execution-time-while-ray-tracing-using-voxelraytracers-package/34971 "2020-02-23T09:55:16Z")

</div>

Hi, I am trying to use VoxelRayTracers.jl package to trace a ray through cubic voxels. I want to improve the performance of ray tracing by reducing execution time because in my application I have to use many rays in th…

---

## [Is there a more elegant solution than \`sortperm(sortperm(...))\`](https://discourse.julialang.org/t/is-there-a-more-elegant-solution-than-sortperm-sortperm/35015)

<div class="topic-metadata">

**Author:** [@pfarndt](https://discourse.julialang.org/u/pfarndt)\
**Replies:** 6\
**Last updated:** [February 22, 2020, 3:38pm UTC](https://discourse.julialang.org/t/is-there-a-more-elegant-solution-than-sortperm-sortperm/35015 "2020-02-22T15:38:36Z")

</div>

Say I have two vectors of identifiers - the second one being a shuffled version of the first one - like this: using Random, Test a = \[ randstring(5) for \_ in 1:20 \] b = shuffle(a) and now I want to loop through a such …

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

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