# Performance

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

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

**Page:** 82

---

## [How can I eliminate allocations here?](https://discourse.julialang.org/t/how-can-i-eliminate-allocations-here/68859)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 5\
**Last updated:** [September 29, 2021, 12:28pm UTC](https://discourse.julialang.org/t/how-can-i-eliminate-allocations-here/68859 "2021-09-29T12:28:15Z")

</div>

How can I eliminate allocations here? I understand I am allocating in shares1 = copy(shares), but where else? function logit(x; min=0, max=1) (max - min) \* (1/(1 + exp(-x))) + min end function \_cessum(x, shares, r)…

---

## [FLoops composable way of multithreading nested loops?](https://discourse.julialang.org/t/floops-composable-way-of-multithreading-nested-loops/68832)

<div class="topic-metadata">

**Author:** [@PatrickMcFarlane](https://discourse.julialang.org/u/PatrickMcFarlane)\
**Replies:** 2\
**Last updated:** [September 28, 2021, 12:23pm UTC](https://discourse.julialang.org/t/floops-composable-way-of-multithreading-nested-loops/68832 "2021-09-28T12:23:04Z")

</div>

I’m writing an algorithm for a discrete time dynamic programming problem in economics. The algorithm involves nested looping over 4 state variables - 2 exogenous, 2 endogenous. The solution to the problem 4 dimensional…

---

## [Is there any package similar to python's decimal in Julia? Where we can use any precision?](https://discourse.julialang.org/t/is-there-any-package-similar-to-pythons-decimal-in-julia-where-we-can-use-any-precision/68834)

<div class="topic-metadata">

**Author:** [@aburousan](https://discourse.julialang.org/u/aburousan)\
**Replies:** 10\
**Last updated:** [September 28, 2021, 12:12pm UTC](https://discourse.julialang.org/t/is-there-any-package-similar-to-pythons-decimal-in-julia-where-we-can-use-any-precision/68834 "2021-09-28T12:12:11Z")

</div>

I have written this piece of code in python. from decimal import \* def pi\_chudn(n): getcontext().prec = n+50 k=0 pi\_chud = 0 while k\<n: pi\_chud+=(((Decimal(-1))\*\*k ) \* (Decimal(mp.factorial(6\*k))…

---

## [Symbolics.jl: Speed of derivative computations vs. SymEngine.jl](https://discourse.julialang.org/t/symbolics-jl-speed-of-derivative-computations-vs-symengine-jl/68803)

<div class="topic-metadata">

**Author:** [@ranocha](https://discourse.julialang.org/u/ranocha)\
**Replies:** 2\
**Last updated:** [September 27, 2021, 6:24pm UTC](https://discourse.julialang.org/t/symbolics-jl-speed-of-derivative-computations-vs-symengine-jl/68803 "2021-09-27T18:24:24Z")

</div>

I benchmarked some derivative computations using Symbolics.jl, SymEngine.jl, and SymPy.jl. As expected, SymPy.jl was the slowest solution in my case. However, SymEngine.jl was significantly faster than Symbolics.jl. Here…

---

## [Agent-based model performance](https://discourse.julialang.org/t/agent-based-model-performance/68758)

<div class="topic-metadata">

**Author:** [@Peter\_Uhl](https://discourse.julialang.org/u/Peter_Uhl)\
**Replies:** 14\
**Last updated:** [September 27, 2021, 5:39am UTC](https://discourse.julialang.org/t/agent-based-model-performance/68758 "2021-09-27T05:39:14Z")

</div>

Hi all, I am working to improve the performance of an agent-based model. The model is of two bacterial species whose growth and death probabilities are determined by the amount of a nutrient available locally. I’m aware…

---

## [Sum of doubles](https://discourse.julialang.org/t/sum-of-doubles/68747)

<div class="topic-metadata">

**Author:** [@HexxCube](https://discourse.julialang.org/u/HexxCube)\
**Replies:** 16\
**Last updated:** [September 26, 2021, 9:02pm UTC](https://discourse.julialang.org/t/sum-of-doubles/68747 "2021-09-26T21:02:55Z")

</div>

I am trying to speed up my solution to the following exercise: Given a Array of int values (from 1 to p), return the sum of doubles. If one of the values occurs only once, it does not count towards the sum. loneSum(\[1…

---

## [Why is this @tullio example failing with a range error?](https://discourse.julialang.org/t/why-is-this-tullio-example-failing-with-a-range-error/68748)

<div class="topic-metadata">

**Author:** [@Chiil](https://discourse.julialang.org/u/Chiil)\
**Replies:** 2\
**Last updated:** [September 26, 2021, 7:52pm UTC](https://discourse.julialang.org/t/why-is-this-tullio-example-failing-with-a-range-error/68748 "2021-09-26T19:52:25Z")

</div>

I am experimenting with Tullio in order to write fast nested loops. I have arrays on which I perform computations on a subset. I do not know why this is failing, as all indices get a range provided. using Tullio itot =…

---

## [Optional parameter causes type instability](https://discourse.julialang.org/t/optional-parameter-causes-type-instability/68768)

<div class="topic-metadata">

**Author:** [@Joris\_Pinkse](https://discourse.julialang.org/u/Joris_Pinkse)\
**Replies:** 1\
**Last updated:** [September 26, 2021, 3:19am UTC](https://discourse.julialang.org/t/optional-parameter-causes-type-instability/68768 "2021-09-26T03:19:50Z")

</div>

Using @code\_warntype, function f(x::Float64, T=Float64 ) T(x) end passes with flying colors, but function f(x::Float64; T=Float64) T(x) end causes mayhem. Why?

---

## [Fastest data structure for a priority queue](https://discourse.julialang.org/t/fastest-data-structure-for-a-priority-queue/68472)

<div class="topic-metadata">

**Author:** [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Replies:** 23\
**Last updated:** [September 24, 2021, 11:20pm UTC](https://discourse.julialang.org/t/fastest-data-structure-for-a-priority-queue/68472 "2021-09-24T23:20:34Z")

</div>

… depends on the number of events to be handled. I could not use the PQs I’ve seen in Julia because they did not handle multiple identical event times, so took this as an exercise. My events have the following structur…

---

## [Passing boolean settings to module to parse fast kernels via macros](https://discourse.julialang.org/t/passing-boolean-settings-to-module-to-parse-fast-kernels-via-macros/68702)

<div class="topic-metadata">

**Author:** [@Chiil](https://discourse.julialang.org/u/Chiil)\
**Replies:** 7\
**Last updated:** [September 24, 2021, 6:53pm UTC](https://discourse.julialang.org/t/passing-boolean-settings-to-module-to-parse-fast-kernels-via-macros/68702 "2021-09-24T18:53:27Z")

</div>

I have a module that builds high performance kernels, based on user settings. I would like to construct them using settings that are provided by the user that imports the Kernels module. What would be the most logical wa…

---

## [Why lu() factorization is not reducing the execution time?](https://discourse.julialang.org/t/why-lu-factorization-is-not-reducing-the-execution-time/68664)

<div class="topic-metadata">

**Author:** [@Amro](https://discourse.julialang.org/u/Amro)\
**Replies:** 10\
**Last updated:** [September 24, 2021, 5:24pm UTC](https://discourse.julialang.org/t/why-lu-factorization-is-not-reducing-the-execution-time/68664 "2021-09-24T17:24:39Z")

</div>

I am using lu() to reduce the computation time but it turned out not as expected. Any idea why is that? julia\> A = \[1 3 3 2;2 6 9 7; -1 -3 3 4\] 3×4 Matrix{Int64}: 1 3 3 2 2 6 9 7 -1 -3 3 4 julia\> lu(A,c…

---

## [Function sub typing of Functors](https://discourse.julialang.org/t/function-sub-typing-of-functors/68658)

<div class="topic-metadata">

**Author:** [@jdlara-berkeley](https://discourse.julialang.org/u/jdlara-berkeley)\
**Replies:** 1\
**Last updated:** [September 23, 2021, 10:55pm UTC](https://discourse.julialang.org/t/function-sub-typing-of-functors/68658 "2021-09-23T22:55:14Z")

</div>

When defining a functor should the struct be subtyped from Function? For instance struct foo \<: Function a b end function (functor::foo)(x, y) return functor.a\*x + functor.b\*y end or just is fine? struct…

---

## [Updated micro benchmark plot](https://discourse.julialang.org/t/updated-micro-benchmark-plot/68631)

<div class="topic-metadata">

**Author:** [@grasph](https://discourse.julialang.org/u/grasph)\
**Replies:** 1\
**Last updated:** [September 23, 2021, 4:46pm UTC](https://discourse.julialang.org/t/updated-micro-benchmark-plot/68631 "2021-09-23T16:46:12Z")

</div>

Hello, On Julia Micro-Benchmarks it’s written the numbers for Julia in the shown micro-benchmark plot were obtained with Julia version 1.0.0. Is there an update of the plot and do we expect newer Julia versions to perf…

---

## [Type instability in FLoop reduction](https://discourse.julialang.org/t/type-instability-in-floop-reduction/68598)

<div class="topic-metadata">

**Author:** [@smillerc](https://discourse.julialang.org/u/smillerc)\
**Replies:** 6\
**Last updated:** [September 23, 2021, 1:41pm UTC](https://discourse.julialang.org/t/type-instability-in-floop-reduction/68598 "2021-09-23T13:41:33Z")

</div>

I’m attempting to speed up a residual computation function with FLoops but am getting some type instability. The resid\_simple function is the version that uses LinearAlgebra the allocations make it slow. The Floops versi…

---

## [Advanced iteration interface in Julia](https://discourse.julialang.org/t/advanced-iteration-interface-in-julia/68618)

<div class="topic-metadata">

**Author:** [@ettersi](https://discourse.julialang.org/u/ettersi)\
**Replies:** 5\
**Last updated:** [September 23, 2021, 9:39am UTC](https://discourse.julialang.org/t/advanced-iteration-interface-in-julia/68618 "2021-09-23T09:39:15Z")

</div>

I’m working on a function to simplify iterating over binary trees. Ideally, this function should have the following signature: walk\_down( tree, starting\_vertex; two\_children, # Function vertex -\> Union{Val(:le…

---

## [Inline macro](https://discourse.julialang.org/t/inline-macro/68595)

<div class="topic-metadata">

**Author:** [@eliascarv](https://discourse.julialang.org/u/eliascarv)\
**Replies:** 7\
**Last updated:** [September 22, 2021, 7:11pm UTC](https://discourse.julialang.org/t/inline-macro/68595 "2021-09-22T19:11:35Z")

</div>

When should I use the @inline macro to optimize performance?

---

## [Slow compiling of many AxisArrays](https://discourse.julialang.org/t/slow-compiling-of-many-axisarrays/68596)

<div class="topic-metadata">

**Author:** [@klowrey](https://discourse.julialang.org/u/klowrey)\
**Replies:** 0\
**Last updated:** [September 22, 2021, 6:16pm UTC](https://discourse.julialang.org/t/slow-compiling-of-many-axisarrays/68596 "2021-09-22T18:16:59Z")

</div>

I’ve scratched my head on this for a few days and suspect there may not be a good solution but wanted the community’s input. We have a package that wraps a C-library MuJoCo and as added feature of using it through Julia,…

---

## [Error in Pre-Compiling](https://discourse.julialang.org/t/error-in-pre-compiling/68563)

<div class="topic-metadata">

**Author:** [@pafloxy](https://discourse.julialang.org/u/pafloxy)\
**Replies:** 5\
**Last updated:** [September 22, 2021, 7:48am UTC](https://discourse.julialang.org/t/error-in-pre-compiling/68563 "2021-09-22T07:48:25Z")

</div>

Hi! I am facing problem importing DynamicalSystems.jl library in jupyter environment by using DynamicalSystems . I recently installed version 1.2.2. of the library. The following error message appears. However no…

---

## [How to divide block threads in warps?](https://discourse.julialang.org/t/how-to-divide-block-threads-in-warps/68562)

<div class="topic-metadata">

**Author:** [@fza\_ch](https://discourse.julialang.org/u/fza_ch)\
**Replies:** 0\
**Last updated:** [September 22, 2021, 2:52am UTC](https://discourse.julialang.org/t/how-to-divide-block-threads-in-warps/68562 "2021-09-22T02:52:12Z")

</div>

I have watched you tutorial video GPU programming in Julia | Workshop | JuliaCon 2021 - YouTube. I have clear the concept, how to assign blocks and thread. But I want to get video about Streaming process(SP).how can war…

---

## [Speed up a loop with matrix operations](https://discourse.julialang.org/t/speed-up-a-loop-with-matrix-operations/68533)

<div class="topic-metadata">

**Author:** [@HJWang](https://discourse.julialang.org/u/HJWang)\
**Replies:** 4\
**Last updated:** [September 21, 2021, 4:37pm UTC](https://discourse.julialang.org/t/speed-up-a-loop-with-matrix-operations/68533 "2021-09-21T16:37:16Z")

</div>

Hello: I am working on a maximum simulated likelihood estimation on a multi-layer (group/firm/time) model. There are three random variables and I have to do simulation draws for two of them. The estimation is very slow …

---

## [How can I prevent the memory distributed in Julia?](https://discourse.julialang.org/t/how-can-i-prevent-the-memory-distributed-in-julia/68426)

<div class="topic-metadata">

**Author:** [@Lyupinpin](https://discourse.julialang.org/u/Lyupinpin)\
**Replies:** 8\
**Last updated:** [September 20, 2021, 8:18pm UTC](https://discourse.julialang.org/t/how-can-i-prevent-the-memory-distributed-in-julia/68426 "2021-09-20T20:18:11Z")

</div>

I want to use julia to write a code parallel reading data from txt file and saved into a big matrix. However, I found the matrix seems to be distributed to each CPU and I need each CPU to be tremedous big. How can I pre…

---

## [Speed up multidimensional code without Base.Cartesian](https://discourse.julialang.org/t/speed-up-multidimensional-code-without-base-cartesian/68328)

<div class="topic-metadata">

**Author:** [@stakaz](https://discourse.julialang.org/u/stakaz)\
**Replies:** 19\
**Last updated:** [September 20, 2021, 9:54am UTC](https://discourse.julialang.org/t/speed-up-multidimensional-code-without-base-cartesian/68328 "2021-09-20T09:54:20Z")

</div>

Hello, I wonder if someone could help me speeding up my arbitrary dimension code to run as fast as the explicit version but without using Base.Cartesian Consider the following examples using Random using BenchmarkTool…

---

## [Vector of arrays initialization](https://discourse.julialang.org/t/vector-of-arrays-initialization/68402)

<div class="topic-metadata">

**Author:** [@henry2004y](https://discourse.julialang.org/u/henry2004y)\
**Replies:** 3\
**Last updated:** [September 19, 2021, 2:45pm UTC](https://discourse.julialang.org/t/vector-of-arrays-initialization/68402 "2021-09-19T14:45:14Z")

</div>

Hi, I have a case where I want to create a container for a list of arrays with known sizes but different types. The first thing that comes to mind is vector of vectors, like this: nv = 2 T = \[Float32, Int32\] nsize = \[4…

---

## [Performance of cld vs ceil](https://discourse.julialang.org/t/performance-of-cld-vs-ceil/68309)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 3\
**Last updated:** [September 17, 2021, 1:28pm UTC](https://discourse.julialang.org/t/performance-of-cld-vs-ceil/68309 "2021-09-17T13:28:36Z")

</div>

For floating-point arguments, julia\> x = 5.5; y = 2.2; julia\> @btime cld($(Ref(x))\[\], $(Ref(y))\[\]) 23.836 ns (0 allocations: 0 bytes) 3.0 julia\> @btime ceil(($(Ref(x))\[\] / $(Ref(y))\[\])) 2.682 ns (0 allocations: 0 …

---

## [Performance of select! on a DataFrame](https://discourse.julialang.org/t/performance-of-select-on-a-dataframe/68343)

<div class="topic-metadata">

**Author:** [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Replies:** 2\
**Last updated:** [September 17, 2021, 4:12pm UTC](https://discourse.julialang.org/t/performance-of-select-on-a-dataframe/68343 "2021-09-17T16:12:50Z")

</div>

Naively I would expect that dropping columns (in place) from a DataFrame with select! would be a very cheap operation, on the order of nanoseconds. But I’m getting times in the microsecond range: julia\> using DataFrames…

---

## [Threaded loop far slower than sequential loop (+ high compilation time)](https://discourse.julialang.org/t/threaded-loop-far-slower-than-sequential-loop-high-compilation-time/68338)

<div class="topic-metadata">

**Author:** [@StefanMathis](https://discourse.julialang.org/u/StefanMathis)\
**Replies:** 3\
**Last updated:** [September 17, 2021, 3:16pm UTC](https://discourse.julialang.org/t/threaded-loop-far-slower-than-sequential-loop-high-compilation-time/68338 "2021-09-17T15:16:32Z")

</div>

Hello, when trying to parallelize a loop, the performance got absolutely thrashed - roundabout by a factor of 1000. I tried to replicate the problem with a MWE and found something interesting: main() = loop(Vector{Floa…

---

## [Julia Performance - Help Needed](https://discourse.julialang.org/t/julia-performance-help-needed/68004)

<div class="topic-metadata">

**Author:** [@way2toronto](https://discourse.julialang.org/u/way2toronto)\
**Replies:** 40\
**Last updated:** [September 17, 2021, 11:37am UTC](https://discourse.julialang.org/t/julia-performance-help-needed/68004 "2021-09-17T11:37:59Z")

</div>

Hello. Given the promises of performance, I’ve started my Julia work with a translation of a simple deep learning algo to Julia. My Julia code is below and the original Python code network.py is from the book by Michael …

---

## [Faster sorting of DataFrames.jl via background ordering](https://discourse.julialang.org/t/faster-sorting-of-dataframes-jl-via-background-ordering/45084)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 0\
**Last updated:** [August 17, 2020, 8:18am UTC](https://discourse.julialang.org/t/faster-sorting-of-dataframes-jl-via-background-ordering/45084 "2020-08-17T08:18:08Z")

</div>

I have had this idea for a long time, now I finally gave it a go and the results are amazing. So here’s the idea. Here sorting a large dataframe the algorithm roughly goes like this Perform a sortperm on the columns t…

---

## [How can I arrange to only use @threads if the number of iteration is higher than minimum?](https://discourse.julialang.org/t/how-can-i-arrange-to-only-use-threads-if-the-number-of-iteration-is-higher-than-minimum/68177)

<div class="topic-metadata">

**Author:** [@Amro](https://discourse.julialang.org/u/Amro)\
**Replies:** 17\
**Last updated:** [September 16, 2021, 11:02pm UTC](https://discourse.julialang.org/t/how-can-i-arrange-to-only-use-threads-if-the-number-of-iteration-is-higher-than-minimum/68177 "2021-09-16T23:02:23Z")

</div>

I need to run @threads before “for loop” only if the number of iteration is bigger than a predetermined value (called min\_iter here ), such as @threads min\_iter for i in ..., Any idea?

---

## [Why with @threads, the execution time is worse?](https://discourse.julialang.org/t/why-with-threads-the-execution-time-is-worse/68160)

<div class="topic-metadata">

**Author:** [@Amro](https://discourse.julialang.org/u/Amro)\
**Replies:** 19\
**Last updated:** [September 16, 2021, 9:44pm UTC](https://discourse.julialang.org/t/why-with-threads-the-execution-time-is-worse/68160 "2021-09-16T21:44:37Z")

</div>

I am running the below code on 6 physical core computer: using SparseArrays; using LinearAlgebra; using .Threads using BenchmarkTools dt = 0.001; tmin = 0; tmax = 5; timeSim = tmin:dt:tmax; NodeVoltage = zeros(…

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

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