# Performance

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

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

**Page:** 14

---

## [Broadcasting performance](https://discourse.julialang.org/t/broadcasting-performance/123392)

<div class="topic-metadata">

**Author:** [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Replies:** 13\
**Last updated:** [January 6, 2025, 9:39am UTC](https://discourse.julialang.org/t/broadcasting-performance/123392 "2025-01-06T09:39:27Z")

</div>

f(x) = sin(x)cos(x)tan(x)exp(x)sin(x)cos(x)tan(x)exp(x) X = randn(100\_000\_000) @time f.(X) # 4 seconds @time @threads for x in X; f(x) end # .8 seconds 16 threads @time @turbo f.(X) …

---

## [For loop performance vs "functional" performance](https://discourse.julialang.org/t/for-loop-performance-vs-functional-performance/124351)

<div class="topic-metadata">

**Author:** [@rocco\_sprmnt21](https://discourse.julialang.org/u/rocco_sprmnt21)\
**Replies:** 17\
**Last updated:** [January 4, 2025, 11:33am UTC](https://discourse.julialang.org/t/for-loop-performance-vs-functional-performance/124351 "2025-01-04T11:33:34Z")

</div>

The part 2 of the problem of day 19 of the AOC 2024 requires calculating the number of partitions of a string that are subsets of a given set of substrings. This is repeated for a list of strings and to obtain the total…

---

## [Performance of for loop](https://discourse.julialang.org/t/performance-of-for-loop/124240)

<div class="topic-metadata">

**Author:** [@jgr](https://discourse.julialang.org/u/jgr)\
**Replies:** 7\
**Last updated:** [January 1, 2025, 2:06pm UTC](https://discourse.julialang.org/t/performance-of-for-loop/124240 "2025-01-01T14:06:52Z")

</div>

Hi, I want to run a for loop for matrix M with size (200,200,5). I have been told that for the sake of performance, it is better to loop from the outer to the inner (that is, dimension 3 → dim 2 → 1). But here the size …

---

## [QML and Examples not working](https://discourse.julialang.org/t/qml-and-examples-not-working/124293)

<div class="topic-metadata">

**Author:** [@Jake](https://discourse.julialang.org/u/Jake)\
**Replies:** 2\
**Last updated:** [December 31, 2024, 1:18pm UTC](https://discourse.julialang.org/t/qml-and-examples-not-working/124293 "2024-12-31T13:18:31Z")

</div>

The discussion on GUI’s and in particular QML made me interested in trying it out to get a flavour of what it does and how to do it. So I went to the QML.jl page to try some examples. The first time through the gui.jl …

---

## [How is it possible that parallelized code causes fewer allocations?](https://discourse.julialang.org/t/how-is-it-possible-that-parallelized-code-causes-fewer-allocations/124161)

<div class="topic-metadata">

**Author:** [@Leo\_I](https://discourse.julialang.org/u/Leo_I)\
**Replies:** 19\
**Last updated:** [December 30, 2024, 5:41pm UTC](https://discourse.julialang.org/t/how-is-it-possible-that-parallelized-code-causes-fewer-allocations/124161 "2024-12-30T17:41:58Z")

</div>

This case baffles me: using StructArrays n, s = 10^5, 100; llp = \[rand(1:n,s) for \_=1:n\]; llw = \[rand(-1:0.001:1,s) for \_=1:n\] function sort\_vec!(pp::Vector{tp}, ww::Vector{tw}, by::Function=first) ::Nothing where {tp\<…

---

## [Optimization of the use of observables and globals in Makie (from script to @main function)](https://discourse.julialang.org/t/optimization-of-the-use-of-observables-and-globals-in-makie-from-script-to-main-function/124258)

<div class="topic-metadata">

**Author:** [@oscarvdvelde](https://discourse.julialang.org/u/oscarvdvelde)\
**Replies:** 3\
**Last updated:** [December 29, 2024, 8:54pm UTC](https://discourse.julialang.org/t/optimization-of-the-use-of-observables-and-globals-in-makie-from-script-to-main-function/124258 "2024-12-29T20:54:33Z")

</div>

I am trying to make my Makie GUI run faster and allocate less. I have just upgraded to Julia 1.11.2 and thought it was a good opportunity to use function (@main) in other words, wrap all my global scope code into a funct…

---

## [Recursion base vs hand-made recursion](https://discourse.julialang.org/t/recursion-base-vs-hand-made-recursion/124235)

<div class="topic-metadata">

**Author:** [@rocco\_sprmnt21](https://discourse.julialang.org/u/rocco_sprmnt21)\
**Replies:** 13\
**Last updated:** [December 29, 2024, 6:07pm UTC](https://discourse.julialang.org/t/recursion-base-vs-hand-made-recursion/124235 "2024-12-29T18:07:17Z")

</div>

Trying to solve the problem d17 of this year’s AOC, I found that, among the proposed solutions, the most efficient seems to be the one that uses recursion. for example, compared to an iterative one that works on the sam…

---

## [Julia runs slower after many loop iterations (solve ODE problem)](https://discourse.julialang.org/t/julia-runs-slower-after-many-loop-iterations-solve-ode-problem/124238)

<div class="topic-metadata">

**Author:** [@chooron](https://discourse.julialang.org/u/chooron)\
**Replies:** 3\
**Last updated:** [December 29, 2024, 4:00am UTC](https://discourse.julialang.org/t/julia-runs-slower-after-many-loop-iterations-solve-ode-problem/124238 "2024-12-29T04:00:38Z")

</div>

Hello, I need to perform optimization of many groups of ODE problems. The optimization time required for the first few groups is about 20 minutes, but after completing multiple optimizations, the time required gradually …

---

## [Accelerating calling a Julia function from Python via juliacall and ctypes](https://discourse.julialang.org/t/accelerating-calling-a-julia-function-from-python-via-juliacall-and-ctypes/124143)

<div class="topic-metadata">

**Author:** [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Replies:** 7\
**Last updated:** [December 24, 2024, 2:27pm UTC](https://discourse.julialang.org/t/accelerating-calling-a-julia-function-from-python-via-juliacall-and-ctypes/124143 "2024-12-24T14:27:54Z")

</div>

I was creating an example of using a Julia function from Python via pyjuliacall, but I noticed the overhead was quite high. Below I outline how to reduce the overhead of calling the Julia function from Python by using Ju…

---

## [What is the most performant way to create an array of functions?](https://discourse.julialang.org/t/what-is-the-most-performant-way-to-create-an-array-of-functions/124055)

<div class="topic-metadata">

**Author:** [@stefkuypers](https://discourse.julialang.org/u/stefkuypers)\
**Replies:** 2\
**Last updated:** [December 21, 2024, 10:58am UTC](https://discourse.julialang.org/t/what-is-the-most-performant-way-to-create-an-array-of-functions/124055 "2024-12-21T10:58:56Z")

</div>

Is there a performant way to create an array of functions over which I can iterate? I’ve noticed that creating a Vector{Function}() has quite a performance hit due to the abstract Function type. I cannot use the concrete…

---

## [Getting rid of ForwardDiff.jacobian! allocations when using closures](https://discourse.julialang.org/t/getting-rid-of-forwarddiff-jacobian-allocations-when-using-closures/123939)

<div class="topic-metadata">

**Author:** [@franckgaga](https://discourse.julialang.org/u/franckgaga)\
**Replies:** 6\
**Last updated:** [December 19, 2024, 7:30pm UTC](https://discourse.julialang.org/t/getting-rid-of-forwarddiff-jacobian-allocations-when-using-closures/123939 "2024-12-19T19:30:38Z")

</div>

I’m trying to get rid of the memory allocations in jacobian!. For this, I need to pass a cfg argument with a pre-allocated JacobianConfig to the function. According to the doc, its constructor expects to receive the func…

---

## [Is there a specific reason why the const keyword cannot be used within the scope of a function?](https://discourse.julialang.org/t/is-there-a-specific-reason-why-the-const-keyword-cannot-be-used-within-the-scope-of-a-function/123986)

<div class="topic-metadata">

**Author:** [@stefkuypers](https://discourse.julialang.org/u/stefkuypers)\
**Replies:** 4\
**Last updated:** [December 19, 2024, 10:52am UTC](https://discourse.julialang.org/t/is-there-a-specific-reason-why-the-const-keyword-cannot-be-used-within-the-scope-of-a-function/123986 "2024-12-19T10:52:01Z")

</div>

I noticed that trying to use the const keyword in a local scope results in a compilation error. Is there a specific reason for this? I wanted to define an anonymous function in a local scope (see Creating an anonymous fu…

---

## [Get long type information for struct definition](https://discourse.julialang.org/t/get-long-type-information-for-struct-definition/123900)

<div class="topic-metadata">

**Author:** [@linwaytin](https://discourse.julialang.org/u/linwaytin)\
**Replies:** 9\
**Last updated:** [December 17, 2024, 4:52pm UTC](https://discourse.julialang.org/t/get-long-type-information-for-struct-definition/123900 "2024-12-17T16:52:43Z")

</div>

Sometimes I want to wrap a struct which has long type information in another struct. For example, I want to wrap an interpolator like this one: julia\> using Interpolations julia\> cubic\_spline\_interpolation(0:0.1:0.2, z…

---

## [Improving Efficiency of Embarassingly Parallel Problem Using \`Threads\`](https://discourse.julialang.org/t/improving-efficiency-of-embarassingly-parallel-problem-using-threads/123897)

<div class="topic-metadata">

**Author:** [@freestatelabs](https://discourse.julialang.org/u/freestatelabs)\
**Replies:** 7\
**Last updated:** [December 17, 2024, 1:32pm UTC](https://discourse.julialang.org/t/improving-efficiency-of-embarassingly-parallel-problem-using-threads/123897 "2024-12-17T13:32:31Z")

</div>

I recently upgraded my workstation and have been benchmarking a code I had written that I consider to be “embarrassingly parallel”, implemented via the Threads module. However, I found that I was getting far greater loss…

---

## [Creating an anonymous function at the local level. Conflict with const resulting in performance issues](https://discourse.julialang.org/t/creating-an-anonymous-function-at-the-local-level-conflict-with-const-resulting-in-performance-issues/123921)

<div class="topic-metadata">

**Author:** [@stefkuypers](https://discourse.julialang.org/u/stefkuypers)\
**Replies:** 4\
**Last updated:** [December 17, 2024, 1:23pm UTC](https://discourse.julialang.org/t/creating-an-anonymous-function-at-the-local-level-conflict-with-const-resulting-in-performance-issues/123921 "2024-12-17T13:23:36Z")

</div>

I’m building a simulation framework and am running into the following problem: I have a initialisation function init\_model(x::InitType) where x is a structure containing the information needed for initialisation of a mo…

---

## [Speeding up Zygote autodiff for numerical loop](https://discourse.julialang.org/t/speeding-up-zygote-autodiff-for-numerical-loop/123515)

<div class="topic-metadata">

**Author:** [@dameka](https://discourse.julialang.org/u/dameka)\
**Replies:** 13\
**Last updated:** [December 16, 2024, 4:27pm UTC](https://discourse.julialang.org/t/speeding-up-zygote-autodiff-for-numerical-loop/123515 "2024-12-16T16:27:43Z")

</div>

I’m using Zygote to auto-differentiate the (small) output of a numerical loop. It is quite slow, probably due to the naive way I’ve implemented it. I’m interested in advice on (a) vectorizing the loop to get better perfo…

---

## [LinearSolve.jl for many values of b?](https://discourse.julialang.org/t/linearsolve-jl-for-many-values-of-b/94980)

<div class="topic-metadata">

**Author:** [@moble](https://discourse.julialang.org/u/moble)\
**Replies:** 2\
**Last updated:** [December 16, 2024, 2:20pm UTC](https://discourse.julialang.org/t/linearsolve-jl-for-many-values-of-b/94980 "2024-12-16T14:20:47Z")

</div>

I’m writing a package and I really like the idea of LinearSolve.jl, because I want my code to perform well and be flexible: work on CPU or GPU, be differentiable, not allocate, etc. But one of my most important use case…

---

## [A fast sum. Any downsides?](https://discourse.julialang.org/t/a-fast-sum-any-downsides/123723)

<div class="topic-metadata">

**Author:** [@nicolas](https://discourse.julialang.org/u/nicolas)\
**Replies:** 18\
**Last updated:** [December 16, 2024, 3:04pm UTC](https://discourse.julialang.org/t/a-fast-sum-any-downsides/123723 "2024-12-16T15:04:12Z")

</div>

I wrote a simple function to perform sums using indices. function sumi(f, s, range) @simd for i in range s += f(i) end return s end I was curious to measure the performance hit of using sumi for arrays instead of s…

---

## [How to Efficiently Work with Floats Across a Wide Range of Precision?](https://discourse.julialang.org/t/how-to-efficiently-work-with-floats-across-a-wide-range-of-precision/123833)

<div class="topic-metadata">

**Author:** [@Hugin-Hilbert](https://discourse.julialang.org/u/Hugin-Hilbert)\
**Replies:** 4\
**Last updated:** [December 16, 2024, 10:11am UTC](https://discourse.julialang.org/t/how-to-efficiently-work-with-floats-across-a-wide-range-of-precision/123833 "2024-12-16T10:11:20Z")

</div>

I’m currently developing a divide and conquer algorithm in Julia that requires multiple precision arithmetic at different levels of the computation: Leaf Nodes: Operations are performed with approximately 256-bit preci…

---

## [Julia vs. Python Performance on package catch22: Why is Julia slower in this case and how can I improve it?](https://discourse.julialang.org/t/julia-vs-python-performance-on-package-catch22-why-is-julia-slower-in-this-case-and-how-can-i-improve-it/117936)

<div class="topic-metadata">

**Author:** [@arturdaraujo](https://discourse.julialang.org/u/arturdaraujo)\
**Replies:** 11\
**Last updated:** [December 16, 2024, 4:29am UTC](https://discourse.julialang.org/t/julia-vs-python-performance-on-package-catch22-why-is-julia-slower-in-this-case-and-how-can-i-improve-it/117936 "2024-12-16T04:29:24Z")

</div>

Hello, I’m comparing the performance of Julia and Python for a specific task involving time series data and feature extraction. I’ve implemented a parallel computation in both languages and noticed that Python is signif…

---

## [Does BitArraysX.jl or similar exist?](https://discourse.julialang.org/t/does-bitarraysx-jl-or-similar-exist/123869)

<div class="topic-metadata">

**Author:** [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)\
**Replies:** 2\
**Last updated:** [December 15, 2024, 8:07pm UTC](https://discourse.julialang.org/t/does-bitarraysx-jl-or-similar-exist/123869 "2024-12-15T20:07:46Z")

</div>

There have been a few posts over the years discussing constructing a BitArray from bits in an existing Vector{\<:Unsigned}. Does a package that does some version of this exist? I’ve cobbled something together for my own…

---

## [How to convert the python code to Julia](https://discourse.julialang.org/t/how-to-convert-the-python-code-to-julia/123689)

<div class="topic-metadata">

**Author:** [@govindanupam](https://discourse.julialang.org/u/govindanupam)\
**Replies:** 4\
**Last updated:** [December 15, 2024, 4:55am UTC](https://discourse.julialang.org/t/how-to-convert-the-python-code-to-julia/123689 "2024-12-15T04:55:32Z")

</div>

Dear team, How to convert below mentioned code to Julia only without using Pycall module or any Python modules. Please help import os import vtk import numpy as np def process\_jaw\_stl(input\_file, output\_file, jaw\_type…

---

## [Uninvoked logging with interpolated string screws performance](https://discourse.julialang.org/t/uninvoked-logging-with-interpolated-string-screws-performance/123806)

<div class="topic-metadata">

**Author:** [@dpinol](https://discourse.julialang.org/u/dpinol)\
**Replies:** 2\
**Last updated:** [December 13, 2024, 11:51am UTC](https://discourse.julialang.org/t/uninvoked-logging-with-interpolated-string-screws-performance/123806 "2024-12-13T11:51:23Z")

</div>

I have a a hot loop function which merges 2 SparseVector of 1k items each. With @benchmark I can see that adding conditionWhichIsFalse && @warn lazy"msg $myIntVariable" after the loop, makes the function 3 times slow…

---

## [Julia position in the Debian Benchmark Game can be improved, and categorization of some Julia there is unfair](https://discourse.julialang.org/t/julia-position-in-the-debian-benchmark-game-can-be-improved-and-categorization-of-some-julia-there-is-unfair/122280)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 29\
**Last updated:** [December 12, 2024, 9:55pm UTC](https://discourse.julialang.org/t/julia-position-in-the-debian-benchmark-game-can-be-improved-and-categorization-of-some-julia-there-is-unfair/122280 "2024-12-12T21:55:46Z")

</div>

EDIT: I was looking at graph here thinking Julia might be missing: Measured : Which programming language is fastest? (Benchmarks Game) it’s actually still in other graph, and I still argue the categorization (for “naked …

---

## [Memory Arena](https://discourse.julialang.org/t/memory-arena/123764)

<div class="topic-metadata">

**Author:** [@NimaPoshtiban](https://discourse.julialang.org/u/NimaPoshtiban)\
**Replies:** 1\
**Last updated:** [December 12, 2024, 4:57pm UTC](https://discourse.julialang.org/t/memory-arena/123764 "2024-12-12T16:57:30Z")

</div>

Hello, dear members of the Julia Community. I want to manage heap space for external objects (e.g. C objects) by using an Arena How is it done in Julia? The simple definition of an Arena is “An arena is just a large,…

---

## [Fastest Julia implementation for a cyclic convolution of real vectors](https://discourse.julialang.org/t/fastest-julia-implementation-for-a-cyclic-convolution-of-real-vectors/123665)

<div class="topic-metadata">

**Author:** [@lukemin](https://discourse.julialang.org/u/lukemin)\
**Replies:** 17\
**Last updated:** [December 12, 2024, 4:44pm UTC](https://discourse.julialang.org/t/fastest-julia-implementation-for-a-cyclic-convolution-of-real-vectors/123665 "2024-12-12T16:44:03Z")

</div>

Hi, I am looking for the fastest way to implement the cyclic convolution of two real vectors. In other words, given some positive integer n \> 0 which is not necessarily power-of-two, I want to multiply two degree-(n-1) …

---

## [Not using PreallocationTools.jl correctly](https://discourse.julialang.org/t/not-using-preallocationtools-jl-correctly/123609)

<div class="topic-metadata">

**Author:** [@Nikos\_Gianniotis](https://discourse.julialang.org/u/Nikos_Gianniotis)\
**Replies:** 11\
**Last updated:** [December 12, 2024, 2:26pm UTC](https://discourse.julialang.org/t/not-using-preallocationtools-jl-correctly/123609 "2024-12-12T14:26:42Z")

</div>

I have run into the same problem that others have run into before me. Unfortunately, I can’t solve the problem despite the fact that the question has been asked in (slightly) different guises (e.g. link1, link2). The pr…

---

## [Speeding up elementwise Vector-SparseMatrixCSC multiplication broadcasting](https://discourse.julialang.org/t/speeding-up-elementwise-vector-sparsematrixcsc-multiplication-broadcasting/79437)

<div class="topic-metadata">

**Author:** [@bcsj](https://discourse.julialang.org/u/bcsj)\
**Replies:** 11\
**Last updated:** [December 12, 2024, 9:45am UTC](https://discourse.julialang.org/t/speeding-up-elementwise-vector-sparsematrixcsc-multiplication-broadcasting/79437 "2024-12-12T09:45:23Z")

</div>

I noticed today a bottleneck in my code which was causing significant performance loss. Given a vector b and a sparse matrix A, let b \\odot A be the elementwise multiplication of b on each column of A. An example in Ju…

---

## [MKLSparse with AMD cpu](https://discourse.julialang.org/t/mklsparse-with-amd-cpu/50559)

<div class="topic-metadata">

**Author:** [@Bruno\_Amorim](https://discourse.julialang.org/u/Bruno_Amorim)\
**Replies:** 5\
**Last updated:** [December 11, 2024, 8:25pm UTC](https://discourse.julialang.org/t/mklsparse-with-amd-cpu/50559 "2024-12-11T20:25:18Z")

</div>

As discussed in other threads Acceleration of Intel MKL on AMD Ryzen CPU’s Hack: AMD Ryzen/TR/Epyc + Intel Math Kernel Library (MKL) Intel MKL descriminates against AMD cpu’s (although this might be changing). Does t…

---

## [Understanding multi-dimensional array indexing performance](https://discourse.julialang.org/t/understanding-multi-dimensional-array-indexing-performance/123683)

<div class="topic-metadata">

**Author:** [@miguelborrero](https://discourse.julialang.org/u/miguelborrero)\
**Replies:** 7\
**Last updated:** [December 11, 2024, 2:11pm UTC](https://discourse.julialang.org/t/understanding-multi-dimensional-array-indexing-performance/123683 "2024-12-11T14:11:47Z")

</div>

Hi there, My understanding is that Julia chooses column-major ordering for storing a multi-dimensional array in linear memory. I was testing the performance differences of own-implemented functions that sum over the ele…

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

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