# Performance

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

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

**Page:** 19

---

## [Optimizing sums of products (dot products)](https://discourse.julialang.org/t/optimizing-sums-of-products-dot-products/119515)

<div class="topic-metadata">

**Author:** [@s-baumann](https://discourse.julialang.org/u/s-baumann)\
**Replies:** 17\
**Last updated:** [September 24, 2024, 7:40pm UTC](https://discourse.julialang.org/t/optimizing-sums-of-products-dot-products/119515 "2024-09-24T19:40:11Z")

</div>

Is there a way to avoid the intermediate allocation for a sumproduct scenario? In the following case I can redo it with a for loop which improves the memory allocation but causes it to take longer to execute (the differ…

---

## [Flux slows down by 10x when moving from local system to high performance cluster](https://discourse.julialang.org/t/flux-slows-down-by-10x-when-moving-from-local-system-to-high-performance-cluster/119753)

<div class="topic-metadata">

**Author:** [@SGHoekstra](https://discourse.julialang.org/u/SGHoekstra)\
**Replies:** 10\
**Last updated:** [September 24, 2024, 12:15pm UTC](https://discourse.julialang.org/t/flux-slows-down-by-10x-when-moving-from-local-system-to-high-performance-cluster/119753 "2024-09-24T12:15:38Z")

</div>

Hi everyone, I am using Flux to solve a nonstandard optimisation problem with custom loss. The solution is part a of a larger simulation which I run many times (100,000+) so speed is key. When I try to run my script o…

---

## [Efficiently creating and updating a struct of SVectors](https://discourse.julialang.org/t/efficiently-creating-and-updating-a-struct-of-svectors/119697)

<div class="topic-metadata">

**Author:** [@Tetrakai](https://discourse.julialang.org/u/Tetrakai)\
**Replies:** 10\
**Last updated:** [September 23, 2024, 7:58pm UTC](https://discourse.julialang.org/t/efficiently-creating-and-updating-a-struct-of-svectors/119697 "2024-09-23T19:58:17Z")

</div>

Part A I’m reading some data in from a file then storing it in a struct looking something like this: # "Big" struct of SVectors @with\_kw struct BigStruct{N} A :: SVector{N, Int16} B :: SVector{N, Int16} C :…

---

## [Quaternion to Euler angles](https://discourse.julialang.org/t/quaternion-to-euler-angles/119740)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 4\
**Last updated:** [September 23, 2024, 11:51am UTC](https://discourse.julialang.org/t/quaternion-to-euler-angles/119740 "2024-09-23T11:51:50Z")

</div>

How can I convert a quaternion into Euler angles? Not working: using Rotations q = Float32\[0.51791805, 0.48140272, -0.4814214, -0.5179244\] RotXYZ(q) This fails with a dimension mismatch error. See: Euler Angles · Rot…

---

## [Pushing elements into a view](https://discourse.julialang.org/t/pushing-elements-into-a-view/119733)

<div class="topic-metadata">

**Author:** [@fmor](https://discourse.julialang.org/u/fmor)\
**Replies:** 4\
**Last updated:** [September 23, 2024, 9:29am UTC](https://discourse.julialang.org/t/pushing-elements-into-a-view/119733 "2024-09-23T09:29:19Z")

</div>

I’m working on a clustering model, and to compute cluster weights I have to compare the cohesions of the current cluster k to the one of cluster k plus unit j (respectively old (o) and new (n) in the code). To do so I t…

---

## [Julian way to write this code](https://discourse.julialang.org/t/julian-way-to-write-this-code/119348)

<div class="topic-metadata">

**Author:** [@gdkrmr](https://discourse.julialang.org/u/gdkrmr)\
**Replies:** 18\
**Last updated:** [September 22, 2024, 6:32pm UTC](https://discourse.julialang.org/t/julian-way-to-write-this-code/119348 "2024-09-22T18:32:22Z")

</div>

Is there a pretty way to write this and have good performance? g1 produces runtime dispatch, g2 produces an allocation and g3 doesn’t look very “Julian” and is also unsafe. function g1(x, y, w) sum(i -\> x\[i\] \* y\[i\] \* …

---

## [Why fft with MEASURE plan 10x slower than calling fft directly with CUDA.CUFFT?](https://discourse.julialang.org/t/why-fft-with-measure-plan-10x-slower-than-calling-fft-directly-with-cuda-cufft/119679)

<div class="topic-metadata">

**Author:** [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Replies:** 7\
**Last updated:** [September 22, 2024, 4:53am UTC](https://discourse.julialang.org/t/why-fft-with-measure-plan-10x-slower-than-calling-fft-directly-with-cuda-cufft/119679 "2024-09-22T04:53:10Z")

</div>

using CUDA using CUDA.CUFFT using BenchmarkTools: @benchmark import FFTW a\_gpu = CUDA.rand(Float32, 128, 128, 128) @benchmark CUDA.@sync fft($a\_gpu) which gives: BenchmarkTools.Trial: 1744 samples with 1 evaluation. …

---

## [Why does the speed of Julia in AOT compilation differ from UX4?](https://discourse.julialang.org/t/why-does-the-speed-of-julia-in-aot-compilation-differ-from-ux4/119657)

<div class="topic-metadata">

**Author:** [@aaoo](https://discourse.julialang.org/u/aaoo)\
**Replies:** 12\
**Last updated:** [September 21, 2024, 3:14am UTC](https://discourse.julialang.org/t/why-does-the-speed-of-julia-in-aot-compilation-differ-from-ux4/119657 "2024-09-21T03:14:26Z")

</div>

As the following picture shows, there are two different Julia versions in the speed comparison. The AOT compiled version reaches speeds as fast as Fortran, etc. However, the other version is slower and closer to Python. …

---

## [Logical "and", &&, and mapreduce](https://discourse.julialang.org/t/logical-and-and-mapreduce/119659)

<div class="topic-metadata">

**Author:** [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)\
**Replies:** 8\
**Last updated:** [September 21, 2024, 8:23am UTC](https://discourse.julialang.org/t/logical-and-and-mapreduce/119659 "2024-09-21T08:23:07Z")

</div>

I wonder if a function like and(x::Bool, y::Bool) = x && y would be useful. You can currently do mapreduce(f, &, x, y), where f takes two arguments and returns Bool. But and always returns Bool (only has this one meth…

---

## [Distributed computing over SLURM array](https://discourse.julialang.org/t/distributed-computing-over-slurm-array/119574)

<div class="topic-metadata">

**Author:** [@tb877](https://discourse.julialang.org/u/tb877)\
**Replies:** 11\
**Last updated:** [September 20, 2024, 3:04pm UTC](https://discourse.julialang.org/t/distributed-computing-over-slurm-array/119574 "2024-09-20T15:04:14Z")

</div>

Hi, New to Julia, and also new to SLURM. I’m thinking about the following workflow for my project and would like to see if it seems a sensible strategy, especially considering the specificities of the Julia language. I…

---

## [Tidiest way to reuse variables inside a function to reduce gc time](https://discourse.julialang.org/t/tidiest-way-to-reuse-variables-inside-a-function-to-reduce-gc-time/119509)

<div class="topic-metadata">

**Author:** [@fmor](https://discourse.julialang.org/u/fmor)\
**Replies:** 8\
**Last updated:** [September 18, 2024, 9:09am UTC](https://discourse.julialang.org/t/tidiest-way-to-reuse-variables-inside-a-function-to-reduce-gc-time/119509 "2024-09-18T09:09:22Z")

</div>

I’m writing a function to fit a spatio-temporal model for clustering. At each iteration it has to compute spatial cohesions on subsets of units, and I saw that this takes a lot of the execution time, which is spent in ga…

---

## [Different times with @elapsed, @time and @benchmark](https://discourse.julialang.org/t/different-times-with-elapsed-time-and-benchmark/119381)

<div class="topic-metadata">

**Author:** [@odddot](https://discourse.julialang.org/u/odddot)\
**Replies:** 3\
**Last updated:** [September 17, 2024, 8:51pm UTC](https://discourse.julialang.org/t/different-times-with-elapsed-time-and-benchmark/119381 "2024-09-17T20:51:01Z")

</div>

Hi, I am a little confused by some results that I obtain comparing @time, @elapsed and @benchmark. I am aware of some differences between this macros, but I suppose that I am not really understanding what is happening h…

---

## [Several questions about time evaluation with @time](https://discourse.julialang.org/t/several-questions-about-time-evaluation-with-time/119455)

<div class="topic-metadata">

**Author:** [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Replies:** 7\
**Last updated:** [September 16, 2024, 3:32pm UTC](https://discourse.julialang.org/t/several-questions-about-time-evaluation-with-time/119455 "2024-09-16T15:32:47Z")

</div>

For example, if we want to evaluate the time cost of the following code snippet: total = 0 for i in 1:100000000 total += i end Standard practice is as follows (right?): First, write it into a function: function m…

---

## [Module parameters and run-time efficiency](https://discourse.julialang.org/t/module-parameters-and-run-time-efficiency/119505)

<div class="topic-metadata">

**Author:** [@jhidding](https://discourse.julialang.org/u/jhidding)\
**Replies:** 3\
**Last updated:** [September 17, 2024, 3:17pm UTC](https://discourse.julialang.org/t/module-parameters-and-run-time-efficiency/119505 "2024-09-17T15:17:57Z")

</div>

Hi, I want to perform dispatch based on functions of the same name within a module. There’s two ways to go about it: having a function f(m::Module,...) or defining a trait type and saying f(::Type{Mod{M}}, ...) where M. …

---

## [Time integration in OrdinaryDiffEq.jl in Julia is slower than calling it from Python](https://discourse.julialang.org/t/time-integration-in-ordinarydiffeq-jl-in-julia-is-slower-than-calling-it-from-python/119123)

<div class="topic-metadata">

**Author:** [@dmitry-kabanov](https://discourse.julialang.org/u/dmitry-kabanov)\
**Replies:** 12\
**Last updated:** [September 16, 2024, 7:17pm UTC](https://discourse.julialang.org/t/time-integration-in-ordinarydiffeq-jl-in-julia-is-slower-than-calling-it-from-python/119123 "2024-09-16T19:17:43Z")

</div>

Hi, I work on the software that allows to call numerical solvers across different languages, which is implemented using libffi (Function Foreign Interface library). I was working recently on the performance study, to s…

---

## [Nested for loops vs Iterators.product performance](https://discourse.julialang.org/t/nested-for-loops-vs-iterators-product-performance/119417)

<div class="topic-metadata">

**Author:** [@Nichola](https://discourse.julialang.org/u/Nichola)\
**Replies:** 16\
**Last updated:** [September 16, 2024, 1:40pm UTC](https://discourse.julialang.org/t/nested-for-loops-vs-iterators-product-performance/119417 "2024-09-16T13:40:42Z")

</div>

Assume I have some vectors a,b,c… and I want to compute \\sum\_{ijk..} a\_i b\_j c\_k ... For 3 lists, I can do it using nested for loops : function sumprod1(a, b, c) s = 0 for i in 1:length(a) for j in 1:l…

---

## [Using Symbolic simplification in DataFramesMeta macros](https://discourse.julialang.org/t/using-symbolic-simplification-in-dataframesmeta-macros/119446)

<div class="topic-metadata">

**Author:** [@s-baumann](https://discourse.julialang.org/u/s-baumann)\
**Replies:** 8\
**Last updated:** [September 15, 2024, 11:28pm UTC](https://discourse.julialang.org/t/using-symbolic-simplification-in-dataframesmeta-macros/119446 "2024-09-15T23:28:30Z")

</div>

In DataFramesMeta it is possible to evaluate algebraic combinations and calculations involving the column names of a DataFrame. Is it possible (in DataFramesMeta or another package that can be placed inside as part of i…

---

## [Performance of loop over multi-dimensional array limited by getindex](https://discourse.julialang.org/t/performance-of-loop-over-multi-dimensional-array-limited-by-getindex/119421)

<div class="topic-metadata">

**Author:** [@jpmoliveira](https://discourse.julialang.org/u/jpmoliveira)\
**Replies:** 6\
**Last updated:** [September 15, 2024, 6:46am UTC](https://discourse.julialang.org/t/performance-of-loop-over-multi-dimensional-array-limited-by-getindex/119421 "2024-09-15T06:46:10Z")

</div>

Hey everyone, I am trying to write a decently fast solver for the electric potential along a mesh given a charge distribution using a Gauss-Seidel method with SOR. Essentially, I have two 3d arrays within a struct and …

---

## [Fill SVector with uniformly sampled Float32 values](https://discourse.julialang.org/t/fill-svector-with-uniformly-sampled-float32-values/119386)

<div class="topic-metadata">

**Author:** [@Tetrakai](https://discourse.julialang.org/u/Tetrakai)\
**Replies:** 5\
**Last updated:** [September 14, 2024, 6:57am UTC](https://discourse.julialang.org/t/fill-svector-with-uniformly-sampled-float32-values/119386 "2024-09-14T06:57:33Z")

</div>

There are quite a few topics on this, eg: Performance of generating uniform Float32 numbers Given the current default behavior hasn’t been fixed, I tried a few things. As a baseline, these all return Float64: Edit: Ba…

---

## [A lot of memory only loading modules!](https://discourse.julialang.org/t/a-lot-of-memory-only-loading-modules/119295)

<div class="topic-metadata">

**Author:** [@Ronneesley](https://discourse.julialang.org/u/Ronneesley)\
**Replies:** 8\
**Last updated:** [September 14, 2024, 4:35am UTC](https://discourse.julialang.org/t/a-lot-of-memory-only-loading-modules/119295 "2024-09-14T04:35:03Z")

</div>

Hi, I’m study why my modules requires a lot of memory \> 500MB. So I decided to study the growth of memory of my modules. I discovered that only one module using LibPQ let Julia use 213,1 MB. If I compare only Julia RE…

---

## [Maximizing Input File Read Performance](https://discourse.julialang.org/t/maximizing-input-file-read-performance/117034)

<div class="topic-metadata">

**Author:** [@freestatelabs](https://discourse.julialang.org/u/freestatelabs)\
**Replies:** 7\
**Last updated:** [September 13, 2024, 1:20pm UTC](https://discourse.julialang.org/t/maximizing-input-file-read-performance/117034 "2024-09-13T13:20:47Z")

</div>

Hi everyone, I’m writing a simple simulation program, and trying to figure out the best way of designing a format for my input files. The simulation calculates the effect of multiple types of sources (each defined in a …

---

## [Allocation-free weighted samples](https://discourse.julialang.org/t/allocation-free-weighted-samples/119265)

<div class="topic-metadata">

**Author:** [@Tetrakai](https://discourse.julialang.org/u/Tetrakai)\
**Replies:** 12\
**Last updated:** [September 12, 2024, 1:50pm UTC](https://discourse.julialang.org/t/allocation-free-weighted-samples/119265 "2024-09-12T13:50:12Z")

</div>

Given an SVector of weights, is there a way to take a single weighted sample without any allocations? Ie, these work great but require an allocation: x = \[1\] wts = @SVector rand(16) @btime wsample(1:16, $wts) @btime wsa…

---

## [Optimising voronoi computation](https://discourse.julialang.org/t/optimising-voronoi-computation/119297)

<div class="topic-metadata">

**Author:** [@Manasa\_S](https://discourse.julialang.org/u/Manasa_S)\
**Replies:** 4\
**Last updated:** [September 12, 2024, 8:20am UTC](https://discourse.julialang.org/t/optimising-voronoi-computation/119297 "2024-09-12T08:20:43Z")

</div>

Hi, I am currently working on a project that needs to compute voronoi of points. The points increase exponentially over time. I am currently using DelaunayTriangulation package. I compute tri for the points and then vor…

---

## [Improving GPU performance for symbolic regression](https://discourse.julialang.org/t/improving-gpu-performance-for-symbolic-regression/108800)

<div class="topic-metadata">

**Author:** [@MilesCranmer](https://discourse.julialang.org/u/MilesCranmer)\
**Replies:** 14\
**Last updated:** [September 12, 2024, 5:58am UTC](https://discourse.julialang.org/t/improving-gpu-performance-for-symbolic-regression/108800 "2024-09-12T05:58:56Z")

</div>

I’m trying to improve the GPU performance for evaluation of an expression represented as a tree in DynamicExpressions.jl. The way it works is that an expression is created at runtime – here’s a movie of how this is used …

---

## [Functional programming is not capable of achieving absolute top performance](https://discourse.julialang.org/t/functional-programming-is-not-capable-of-achieving-absolute-top-performance/119233)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 20\
**Last updated:** [September 12, 2024, 12:57am UTC](https://discourse.julialang.org/t/functional-programming-is-not-capable-of-achieving-absolute-top-performance/119233 "2024-09-12T00:57:33Z")

</div>

I was just playing around with the best way to compute the mean and standard deviation of a vector of values. Obviously, sum(x), std(x) is the cleanest but it isn’t the fastest, as I assume that approach needs to scan t…

---

## [Does Julia support Zen 4 CPUs?](https://discourse.julialang.org/t/does-julia-support-zen-4-cpus/119224)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 9\
**Last updated:** [September 11, 2024, 10:46pm UTC](https://discourse.julialang.org/t/does-julia-support-zen-4-cpus/119224 "2024-09-11T22:46:23Z")

</div>

I have a laptop with an Ryzen 7 7840U CPU, which - according to https://www.amd.com/en/products/processors/laptop/ryzen/7000-series/amd-ryzen-7-7840u.html - has a Zen 4 architecture. In Julia 1.10.5, the output of Sys.…

---

## [Complexity/implementation of disjoint-set (union-find) in \`DataStructures.jl\`](https://discourse.julialang.org/t/complexity-implementation-of-disjoint-set-union-find-in-datastructures-jl/119050)

<div class="topic-metadata">

**Author:** [@jacob-roth](https://discourse.julialang.org/u/jacob-roth)\
**Replies:** 4\
**Last updated:** [September 11, 2024, 4:11pm UTC](https://discourse.julialang.org/t/complexity-implementation-of-disjoint-set-union-find-in-datastructures-jl/119050 "2024-09-11T16:11:10Z")

</div>

I didn’t see it in the docs and am trying to identify what algorithm is used in the implementation of find (and union) in the DisjointSets object in the DataStructures.jl package. find The docs say that “path compressi…

---

## [Where is the excessive memory consumption](https://discourse.julialang.org/t/where-is-the-excessive-memory-consumption/119174)

<div class="topic-metadata">

**Author:** [@Betristor](https://discourse.julialang.org/u/Betristor)\
**Replies:** 13\
**Last updated:** [September 10, 2024, 6:20am UTC](https://discourse.julialang.org/t/where-is-the-excessive-memory-consumption/119174 "2024-09-10T06:20:53Z")

</div>

I have a JuMP model with about 0.2 billion variables. Gurobi reports 50 GB of memory consumption and htop reports consistent 350 GB of memory consumption during solving. I’m most curious about the excessive memory consu…

---

## [Benchmark game challenge and some optimization questions](https://discourse.julialang.org/t/benchmark-game-challenge-and-some-optimization-questions/79653)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 29\
**Last updated:** [January 13, 2024, 7:12pm UTC](https://discourse.julialang.org/t/benchmark-game-challenge-and-some-optimization-questions/79653 "2024-01-13T19:12:59Z")

</div>

First the good news, at the Debian benchmark game, clicking “summary stats”: I see the top graph showing Julia is best for “Geometric Mean - Time plus Source Code size”. \[Then further down a similar graph, at first co…

---

## [When to use Tuples instead of Vectors?](https://discourse.julialang.org/t/when-to-use-tuples-instead-of-vectors/119109)

<div class="topic-metadata">

**Author:** [@albertomercurio](https://discourse.julialang.org/u/albertomercurio)\
**Replies:** 16\
**Last updated:** [September 6, 2024, 3:42pm UTC](https://discourse.julialang.org/t/when-to-use-tuples-instead-of-vectors/119109 "2024-09-06T15:42:49Z")

</div>

Hello, I’m developing QuantumToolbox.jl for simulating quantum systems in Julia. Everything is based on the QuantumObject constructor, which is currently defined as follows struct QuantumObject{MT\<:AbstractArray,ObjTyp…

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

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