# Performance

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

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

**Page:** 89

---

## [Distributed Differential Equations with large matrix](https://discourse.julialang.org/t/distributed-differential-equations-with-large-matrix/64665)

<div class="topic-metadata">

**Author:** [@albertomercurio](https://discourse.julialang.org/u/albertomercurio)\
**Replies:** 12\
**Last updated:** [July 16, 2021, 7:11pm UTC](https://discourse.julialang.org/t/distributed-differential-equations-with-large-matrix/64665 "2021-07-16T19:11:07Z")

</div>

Hello, I’m trying to increase the performances for my differential equation system, where the differential function is function drho\_dt(rho, p, t) global L, L\_t A, w\_l = p return (L + A \* sin(w\_l \* t) \* L\_t…

---

## [Create Template without version control](https://discourse.julialang.org/t/create-template-without-version-control/64450)

<div class="topic-metadata">

**Author:** [@Dustin\_Hess](https://discourse.julialang.org/u/Dustin_Hess)\
**Replies:** 10\
**Last updated:** [July 15, 2021, 3:22am UTC](https://discourse.julialang.org/t/create-template-without-version-control/64450 "2021-07-15T03:22:19Z")

</div>

I read through the doc for PkgTemplates and cannot figure out how to create a package that dose not have a .git folder. I need this way because because I am using Bitbucket and packages are private. Bitbucket will create…

---

## [Reducing memory allocations when storing vectors to fields of a mutable type](https://discourse.julialang.org/t/reducing-memory-allocations-when-storing-vectors-to-fields-of-a-mutable-type/64623)

<div class="topic-metadata">

**Author:** [@LionMod](https://discourse.julialang.org/u/LionMod)\
**Replies:** 6\
**Last updated:** [July 14, 2021, 2:43pm UTC](https://discourse.julialang.org/t/reducing-memory-allocations-when-storing-vectors-to-fields-of-a-mutable-type/64623 "2021-07-14T14:43:53Z")

</div>

I have a mutable type called Data mutable struct Data data\_a::Vector{Int64} data\_b::Vector{Int64} end I get two vectors that are of type Vector{Float64} from a solution of an ODE and want to construct t…

---

## [Memory allocation with function passed as arguments](https://discourse.julialang.org/t/memory-allocation-with-function-passed-as-arguments/64575)

<div class="topic-metadata">

**Author:** [@aaraujo71](https://discourse.julialang.org/u/aaraujo71)\
**Replies:** 4\
**Last updated:** [July 13, 2021, 7:15pm UTC](https://discourse.julialang.org/t/memory-allocation-with-function-passed-as-arguments/64575 "2021-07-13T19:15:00Z")

</div>

When I call test() twice after compiling code fn = (x -\> 2\*exp(x), x -\> 2\*sin(x)) function test\_calc(x, fn1, fn2) @. x = x + fn1(x) + fn2(x) end function test() A = Float64.(collect(1:10)) @time test\_calc(…

---

## [Data type for a “stupid” binary search tree](https://discourse.julialang.org/t/data-type-for-a-stupid-binary-search-tree/64474)

<div class="topic-metadata">

**Author:** [@circonflexe](https://discourse.julialang.org/u/circonflexe)\
**Replies:** 4\
**Last updated:** [July 13, 2021, 3:59am UTC](https://discourse.julialang.org/t/data-type-for-a-stupid-binary-search-tree/64474 "2021-07-13T03:59:51Z")

</div>

I need a data type for a collection of objects (stored in a given order) which supports both O(log n) insertion and deletion methods, as well as some way to perform a dichotomic search (where I provide the left-or-right …

---

## [Support \`@threads\` for a lazy object](https://discourse.julialang.org/t/support-threads-for-a-lazy-object/64458)

<div class="topic-metadata">

**Author:** [@jling](https://discourse.julialang.org/u/jling)\
**Replies:** 0\
**Last updated:** [July 11, 2021, 11:39am UTC](https://discourse.julialang.org/t/support-threads-for-a-lazy-object/64458 "2021-07-11T11:39:01Z")

</div>

Say I have a big LazyArray with size 10^5 and the underlying structure is that every 5000 entries are in a “chunk” and one has to read and decompress a chunk together. I have implemented getindex() for LazyArray and it …

---

## [Increase performance in string comparison with sub-dataframes or sub-arrays](https://discourse.julialang.org/t/increase-performance-in-string-comparison-with-sub-dataframes-or-sub-arrays/64392)

<div class="topic-metadata">

**Author:** [@bojusemo](https://discourse.julialang.org/u/bojusemo)\
**Replies:** 5\
**Last updated:** [July 11, 2021, 10:30am UTC](https://discourse.julialang.org/t/increase-performance-in-string-comparison-with-sub-dataframes-or-sub-arrays/64392 "2021-07-11T10:30:14Z")

</div>

Hello, I am new at programming and hope you guys can give me a hand, please. I have three plain text files with columns called ID\_# File a Header Header Header Header Header ID\_1 ID\_5 ID\_6 ID\_7 ID\_8 File b ID\_…

---

## [Fastest way of contracting arrays](https://discourse.julialang.org/t/fastest-way-of-contracting-arrays/64415)

<div class="topic-metadata">

**Author:** [@Frisus95](https://discourse.julialang.org/u/Frisus95)\
**Replies:** 8\
**Last updated:** [July 10, 2021, 5:44pm UTC](https://discourse.julialang.org/t/fastest-way-of-contracting-arrays/64415 "2021-07-10T17:44:43Z")

</div>

Good afternoon everyone! I have the following piece of code, which essentially contracts some multidimensional arrays along specific dimensions (this is a no-sense example, which has the only purpose of illustrating cle…

---

## [LoopVectorization almost doubles execution time?](https://discourse.julialang.org/t/loopvectorization-almost-doubles-execution-time/64333)

<div class="topic-metadata">

**Author:** [@Salmon](https://discourse.julialang.org/u/Salmon)\
**Replies:** 6\
**Last updated:** [July 9, 2021, 4:28pm UTC](https://discourse.julialang.org/t/loopvectorization-almost-doubles-execution-time/64333 "2021-07-09T16:28:58Z")

</div>

Hi everyone, I am testing LoopVectorization in my program and since it did not produce any change in speed, I boiled it down to an exemplary function. Here I found something which puzzled me because although the functio…

---

## [Gathering monomial coefficients of orthogonal polynomials using SpecialPolynomials.jl](https://discourse.julialang.org/t/gathering-monomial-coefficients-of-orthogonal-polynomials-using-specialpolynomials-jl/63554)

<div class="topic-metadata">

**Author:** [@BambOoxX](https://discourse.julialang.org/u/BambOoxX)\
**Replies:** 34\
**Last updated:** [July 9, 2021, 11:56am UTC](https://discourse.julialang.org/t/gathering-monomial-coefficients-of-orthogonal-polynomials-using-specialpolynomials-jl/63554 "2021-07-09T11:56:23Z")

</div>

While using SpecialPolynomials.jl I want to gather the monomial coefficients of multiple orthogonal polynomials of increasing size in a matrix. My current implementation is using LinearAlgebra,SpecialPolynomials,Polyno…

---

## [Union splitting vs C++](https://discourse.julialang.org/t/union-splitting-vs-c/61772)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 22\
**Last updated:** [July 9, 2021, 12:32am UTC](https://discourse.julialang.org/t/union-splitting-vs-c/61772 "2021-07-09T00:32:18Z")

</div>

This is a continuation from this thread: Performance drawback with subtyping - #31 by paulmelis Here we have two codes, which compute someting simple (the sum of the values of a field of a type in an array of mixed type…

---

## [Row vs. column major for arrays of coordinate vectors](https://discourse.julialang.org/t/row-vs-column-major-for-arrays-of-coordinate-vectors/64297)

<div class="topic-metadata">

**Author:** [@pavanakumar](https://discourse.julialang.org/u/pavanakumar)\
**Replies:** 7\
**Last updated:** [July 8, 2021, 8:47pm UTC](https://discourse.julialang.org/t/row-vs-column-major-for-arrays-of-coordinate-vectors/64297 "2021-07-08T20:47:02Z")

</div>

There is one advantage that I can think of with column major storage for geometry (coordinate storage). 1D, 2D and 3D coordinates can be represented without hassle. A row-major format will require variable stride (1 in 1…

---

## [Handling functions that have "constant" sub-expressions when looping over arguments](https://discourse.julialang.org/t/handling-functions-that-have-constant-sub-expressions-when-looping-over-arguments/64181)

<div class="topic-metadata">

**Author:** [@nchisholm](https://discourse.julialang.org/u/nchisholm)\
**Replies:** 3\
**Last updated:** [July 8, 2021, 7:26pm UTC](https://discourse.julialang.org/t/handling-functions-that-have-constant-sub-expressions-when-looping-over-arguments/64181 "2021-07-08T19:26:10Z")

</div>

Very commonly, I want to define some function mainfunc and then evaluate it many times in a loop where some of the arguments are constant during looping but others vary with each iteration. Here is an example of what I …

---

## [Multiplying by booleans faster than if/else](https://discourse.julialang.org/t/multiplying-by-booleans-faster-than-if-else/64117)

<div class="topic-metadata">

**Author:** [@PatrickMcFarlane](https://discourse.julialang.org/u/PatrickMcFarlane)\
**Replies:** 23\
**Last updated:** [July 8, 2021, 6:06pm UTC](https://discourse.julialang.org/t/multiplying-by-booleans-faster-than-if-else/64117 "2021-07-08T18:06:41Z")

</div>

I have been using @btime to check the speed of various little functions I’m working on that involve conditionals. I’ve found that multiplying by booleans instead of using if/else statements seems to be much faster. But…

---

## [Boxing of integer when looping vector over 512 index](https://discourse.julialang.org/t/boxing-of-integer-when-looping-vector-over-512-index/64259)

<div class="topic-metadata">

**Author:** [@dpinol](https://discourse.julialang.org/u/dpinol)\
**Replies:** 2\
**Last updated:** [July 8, 2021, 10:40am UTC](https://discourse.julialang.org/t/boxing-of-integer-when-looping-vector-over-512-index/64259 "2021-07-08T10:40:06Z")

</div>

Weird allocation that depends on array contents · Issue #36751 · JuliaLang/julia · GitHub & memory allocation increases unexpectedly in sparse getindex at a threshold · Issue #18051 · JuliaLang/julia · GitHub mention llv…

---

## [Interact.jl custom layout to @manipulate macro](https://discourse.julialang.org/t/interact-jl-custom-layout-to-manipulate-macro/51757)

<div class="topic-metadata">

**Author:** [@floswald](https://discourse.julialang.org/u/floswald)\
**Replies:** 7\
**Last updated:** [July 7, 2021, 10:53pm UTC](https://discourse.julialang.org/t/interact-jl-custom-layout-to-manipulate-macro/51757 "2021-07-07T22:53:06Z")

</div>

based on this example from the Interact.jl docs function mycolorpicker() r = slider(0:255, label = "red") g = slider(0:255, label = "green") b = slider(0:255, label = "blue") output = Interact.@map Color…

---

## [Pkg.test() is orders of magnitude slower than include("test/runtests.jl")](https://discourse.julialang.org/t/pkg-test-is-orders-of-magnitude-slower-than-include-test-runtests-jl/64235)

<div class="topic-metadata">

**Author:** [@Brad\_Carman](https://discourse.julialang.org/u/Brad_Carman)\
**Replies:** 4\
**Last updated:** [July 7, 2021, 9:23pm UTC](https://discourse.julialang.org/t/pkg-test-is-orders-of-magnitude-slower-than-include-test-runtests-jl/64235 "2021-07-07T21:23:37Z")

</div>

If I run the following (starting Julia with only --project switch) include("test/runtests.jl") @time of my function gives 0.030818 seconds (130.79 k allocations: 7.158 MiB) But, if I run using Pkg; Pkg.test(;julia…

---

## [Typestable caching of multiple arrays with different eltype](https://discourse.julialang.org/t/typestable-caching-of-multiple-arrays-with-different-eltype/64197)

<div class="topic-metadata">

**Author:** [@hexaeder](https://discourse.julialang.org/u/hexaeder)\
**Replies:** 3\
**Last updated:** [July 7, 2021, 12:48pm UTC](https://discourse.julialang.org/t/typestable-caching-of-multiple-arrays-with-different-eltype/64197 "2021-07-07T12:48:05Z")

</div>

Hello, i was wondering, whether it is possible to code some kind of cache pool, where i can request cache arrays of various types. Each type of cache array should be only created once. I’ve tried # cache arbitrary arra…

---

## [StaticArrays being used with DifferentialEquation callbacks](https://discourse.julialang.org/t/staticarrays-being-used-with-differentialequation-callbacks/64178)

<div class="topic-metadata">

**Author:** [@LionMod](https://discourse.julialang.org/u/LionMod)\
**Replies:** 3\
**Last updated:** [July 7, 2021, 9:47am UTC](https://discourse.julialang.org/t/staticarrays-being-used-with-differentialequation-callbacks/64178 "2021-07-07T09:47:50Z")

</div>

I’ve been improving performance of my differential equations with @SVector and @MVectorbut I’ve got stuck when it comes to using it with callbacks specifically PresetTimeCallback. The idea is there is a large spike in v…

---

## [Function return type depends on an input flag : Bad?](https://discourse.julialang.org/t/function-return-type-depends-on-an-input-flag-bad/63486)

<div class="topic-metadata">

**Author:** [@rakeshvar](https://discourse.julialang.org/u/rakeshvar)\
**Replies:** 15\
**Last updated:** [July 7, 2021, 8:14am UTC](https://discourse.julialang.org/t/function-return-type-depends-on-an-input-flag-bad/63486 "2021-07-07T08:14:53Z")

</div>

I have a function that calculates ‘sky’ loss and optionally its gradient. function \_sky\_loss\_gradient(x, loss\_only::Bool) # calculation loss\_only && return loss # more calculation return loss, grad end …

---

## [Compiler optimizations on integer exponentation](https://discourse.julialang.org/t/compiler-optimizations-on-integer-exponentation/64185)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 3\
**Last updated:** [July 7, 2021, 12:48am UTC](https://discourse.julialang.org/t/compiler-optimizations-on-integer-exponentation/64185 "2021-07-07T00:48:29Z")

</div>

The following code contains two functions that compute Lennard-Jones potentials, U(r) = 4\\varepsilon \\left(\\frac{\\sigma^{12}}{r^{12}} - \\frac{\\sigma^6}{r^6}\\right) for all pairs of a set of 1000 particles. The first fun…

---

## [Starting GLMakie takes very long](https://discourse.julialang.org/t/starting-glmakie-takes-very-long/64106)

<div class="topic-metadata">

**Author:** [@peteole](https://discourse.julialang.org/u/peteole)\
**Replies:** 28\
**Last updated:** [July 6, 2021, 4:50pm UTC](https://discourse.julialang.org/t/starting-glmakie-takes-very-long/64106 "2021-07-06T16:50:22Z")

</div>

Hi, I am getting started with Makie. The functionality is cool. However I am really annoyed by the startup time: It takes over a minute to open the first plot in GLMakie. After that plotting works instantly, but the st…

---

## [Julia slowdown on long running programs with many allocations](https://discourse.julialang.org/t/julia-slowdown-on-long-running-programs-with-many-allocations/63516)

<div class="topic-metadata">

**Author:** [@scottjordan](https://discourse.julialang.org/u/scottjordan)\
**Replies:** 6\
**Last updated:** [July 6, 2021, 2:22pm UTC](https://discourse.julialang.org/t/julia-slowdown-on-long-running-programs-with-many-allocations/63516 "2021-07-06T14:22:24Z")

</div>

Currently, I am benchmarking flux code compared to python code for different configurations of data and network sizes. However, I noticed that execution slows as more models have been trained with different configuration…

---

## [Memory usage data for getproperty function](https://discourse.julialang.org/t/memory-usage-data-for-getproperty-function/64139)

<div class="topic-metadata">

**Author:** [@jsjie](https://discourse.julialang.org/u/jsjie)\
**Replies:** 3\
**Last updated:** [July 6, 2021, 10:56am UTC](https://discourse.julialang.org/t/memory-usage-data-for-getproperty-function/64139 "2021-07-06T10:56:09Z")

</div>

I’m analysing memory usage as described in julia manual , and I found that getproperty functions seem to be related to large numbers. The following lines is taken from the result .mem file: - function Base.getp…

---

## [ForwardDiff.derivative! of inplace functions](https://discourse.julialang.org/t/forwarddiff-derivative-of-inplace-functions/54014)

<div class="topic-metadata">

**Author:** [@jokasimr](https://discourse.julialang.org/u/jokasimr)\
**Replies:** 1\
**Last updated:** [July 5, 2021, 10:17pm UTC](https://discourse.julialang.org/t/forwarddiff-derivative-of-inplace-functions/54014 "2021-07-05T22:17:43Z")

</div>

I’m learning how to use the FiniteDifference.jl package without allocating, and I want to implement a function for doing Jacobian vector products inplace. :slight\_smile: The goal is to accomplish the same as jvp\_finite…

---

## [\`@code\_native\` shows an algorithm that appears to be O(N), but benchmarking suggests that it's actually O(1)](https://discourse.julialang.org/t/code-native-shows-an-algorithm-that-appears-to-be-o-n-but-benchmarking-suggests-that-its-actually-o-1/63834)

<div class="topic-metadata">

**Author:** [@seamsay](https://discourse.julialang.org/u/seamsay)\
**Replies:** 12\
**Last updated:** [July 5, 2021, 2:16pm UTC](https://discourse.julialang.org/t/code-native-shows-an-algorithm-that-appears-to-be-o-n-but-benchmarking-suggests-that-its-actually-o-1/63834 "2021-07-05T14:16:22Z")

</div>

I hope this is an OK category to put this under, I couldn’t see anything that matched better :grimacing: I’m trying to get better at reading assembly output by looking at some interesting optimisations. I’m currently lo…

---

## [Control where mutables are allocated in a very special case: a large number of mutables of the same type](https://discourse.julialang.org/t/control-where-mutables-are-allocated-in-a-very-special-case-a-large-number-of-mutables-of-the-same-type/63971)

<div class="topic-metadata">

**Author:** [@zsunberg](https://discourse.julialang.org/u/zsunberg)\
**Replies:** 11\
**Last updated:** [July 4, 2021, 5:41am UTC](https://discourse.julialang.org/t/control-where-mutables-are-allocated-in-a-very-special-case-a-large-number-of-mutables-of-the-same-type/63971 "2021-07-04T05:41:36Z")

</div>

In my research, I often find myself incrementally creating large graphs or trees where each node has some properties that might get updated later. Semantically, it makes the most sense for each node to be represented by…

---

## [Large memory consumption when reading multiple HDF5 files](https://discourse.julialang.org/t/large-memory-consumption-when-reading-multiple-hdf5-files/63992)

<div class="topic-metadata">

**Author:** [@useJulia](https://discourse.julialang.org/u/useJulia)\
**Replies:** 3\
**Last updated:** [July 3, 2021, 6:30pm UTC](https://discourse.julialang.org/t/large-memory-consumption-when-reading-multiple-hdf5-files/63992 "2021-07-03T18:30:55Z")

</div>

I found this large memory consumption running the following code. Memory usage n=1 0.003026944 GB Memory usage n=2 0.136589312 GB Memory usage n=4 0.27860992 GB Memory usage n=8 0.60479488 GB Memory usage n=16 1.2072632…

---

## [Tools/patterns to reduce latency with strategy pattern](https://discourse.julialang.org/t/tools-patterns-to-reduce-latency-with-strategy-pattern/63985)

<div class="topic-metadata">

**Author:** [@DrChainsaw](https://discourse.julialang.org/u/DrChainsaw)\
**Replies:** 0\
**Last updated:** [July 3, 2021, 12:15pm UTC](https://discourse.julialang.org/t/tools-patterns-to-reduce-latency-with-strategy-pattern/63985 "2021-07-03T12:15:56Z")

</div>

I’m looking into redesigning some code I wrote long ago which implements a strategy pattern. A mockup example: struct StrategyX{T1,T2, V} \<: AbstractStrategy strategyparam1::T1 strategyparam2::T2 applyto:…

---

## [Parallelization of estimation loop or using GPU for bayesian neural ODE](https://discourse.julialang.org/t/parallelization-of-estimation-loop-or-using-gpu-for-bayesian-neural-ode/63162)

<div class="topic-metadata">

**Author:** [@minou92](https://discourse.julialang.org/u/minou92)\
**Replies:** 1\
**Last updated:** [July 2, 2021, 4:05pm UTC](https://discourse.julialang.org/t/parallelization-of-estimation-loop-or-using-gpu-for-bayesian-neural-ode/63162 "2021-07-02T16:05:39Z")

</div>

I would like to improve the speed process of this following loop using wether gpu or CPU. in case using CPU, What is the best way nowadays to parallelize it ? Could you please help to include it in the code ? Regards f…

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

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