# Performance

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

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

**Page:** 55

---

## [Understanding Shuffle in CUDA](https://discourse.julialang.org/t/understanding-shuffle-in-cuda/90235)

<div class="topic-metadata">

**Author:** [@nethaji8](https://discourse.julialang.org/u/nethaji8)\
**Replies:** 1\
**Last updated:** [November 14, 2022, 1:43pm UTC](https://discourse.julialang.org/t/understanding-shuffle-in-cuda/90235 "2022-11-14T13:43:43Z")

</div>

Hi everyone, I am trying to use shuffle in a Cuda kernel, can someone explain to me how to use CUDA.shfl\_sync, CUDA.shfl\_up\_sync, CUDA.shfl\_down\_sync, CUDA.shfl\_xor\_sync with a simple example…? It’s not clear in the do…

---

## [A Tree? Multi-dimensional Array? hmm](https://discourse.julialang.org/t/a-tree-multi-dimensional-array-hmm/89969)

<div class="topic-metadata">

**Author:** [@theboiwholived](https://discourse.julialang.org/u/theboiwholived)\
**Replies:** 9\
**Last updated:** [November 13, 2022, 11:02am UTC](https://discourse.julialang.org/t/a-tree-multi-dimensional-array-hmm/89969 "2022-11-13T11:02:25Z")

</div>

Hey all, could really use your expertise in determining if what i need here is a tree… and how i would go about doing that At the moment my code basically determines out the difference of all trades between currencies. …

---

## [Unreasonable slow speed in numerical integration](https://discourse.julialang.org/t/unreasonable-slow-speed-in-numerical-integration/89910)

<div class="topic-metadata">

**Author:** [@swish47](https://discourse.julialang.org/u/swish47)\
**Replies:** 16\
**Last updated:** [November 12, 2022, 7:15pm UTC](https://discourse.julialang.org/t/unreasonable-slow-speed-in-numerical-integration/89910 "2022-11-12T19:15:45Z")

</div>

I hope to compute an intergration of a function with intergration inside, however the efficiency is extremely slow. using HCubature,QuadGK,NumericalIntegration spinonenergy(kx::Float64,ky::Float64)::Float64=2\*(cos(kx)+c…

---

## [Efficient calculation of Mahalanobis distance](https://discourse.julialang.org/t/efficient-calculation-of-mahalanobis-distance/90121)

<div class="topic-metadata">

**Author:** [@mleprovost](https://discourse.julialang.org/u/mleprovost)\
**Replies:** 5\
**Last updated:** [November 11, 2022, 7:18pm UTC](https://discourse.julialang.org/t/efficient-calculation-of-mahalanobis-distance/90121 "2022-11-11T19:18:57Z")

</div>

Hello, I would like to compute the following Mahalanobis distance for M samples \\{ x^i \\} with x^i \\in \\mathbb{R}^n d(x^i) = (x^i - \\mu)^\\top \\Sigma^{-1} (x^i - \\mu) where we don’t know \\Sigma but we only know a “squar…

---

## [How to reduce type-instability performance issues in general problem interfaces?](https://discourse.julialang.org/t/how-to-reduce-type-instability-performance-issues-in-general-problem-interfaces/90045)

<div class="topic-metadata">

**Author:** [@user664303](https://discourse.julialang.org/u/user664303)\
**Replies:** 9\
**Last updated:** [November 10, 2022, 2:02pm UTC](https://discourse.julialang.org/t/how-to-reduce-type-instability-performance-issues-in-general-problem-interfaces/90045 "2022-11-10T14:02:44Z")

</div>

I am trying to write a simple interface to define and solve a specific class of problem. The problems are defined by sets of functions and sets of variables. There can be a mix of function types, and a mix of variable ty…

---

## [Impact of specifying input types on function performance, when referencing arguments from Vector{Any}](https://discourse.julialang.org/t/impact-of-specifying-input-types-on-function-performance-when-referencing-arguments-from-vector-any/89993)

<div class="topic-metadata">

**Author:** [@user664303](https://discourse.julialang.org/u/user664303)\
**Replies:** 16\
**Last updated:** [November 10, 2022, 1:07pm UTC](https://discourse.julialang.org/t/impact-of-specifying-input-types-on-function-performance-when-referencing-arguments-from-vector-any/89993 "2022-11-10T13:07:58Z")

</div>

I have a performance issue I’d like to solve. I need to reference some function arguments from a Vector{Any} array. Most of the time this is incurring an expensive allocation penalty. However, when I call an explicitly t…

---

## [Allocation and slow down when # of types involved increase (slower than C++ virtual methods)](https://discourse.julialang.org/t/allocation-and-slow-down-when-of-types-involved-increase-slower-than-c-virtual-methods/87656)

<div class="topic-metadata">

**Author:** [@jling](https://discourse.julialang.org/u/jling)\
**Replies:** 56\
**Last updated:** [November 9, 2022, 7:38pm UTC](https://discourse.julialang.org/t/allocation-and-slow-down-when-of-types-involved-increase-slower-than-c-virtual-methods/87656 "2022-11-09T19:38:33Z")

</div>

\*Happy to pay someone to spend time investigating this The context is @peremato trying to present a Julia case for detector simulation used at e.g. CERN (the LHC) and other accelerator/medical research places: https://in…

---

## [How a program coded and compiled in Julia compares to interpreted Julia in terms of performance?](https://discourse.julialang.org/t/how-a-program-coded-and-compiled-in-julia-compares-to-interpreted-julia-in-terms-of-performance/89995)

<div class="topic-metadata">

**Author:** [@phantomcraft](https://discourse.julialang.org/u/phantomcraft)\
**Replies:** 1\
**Last updated:** [November 9, 2022, 5:47pm UTC](https://discourse.julialang.org/t/how-a-program-coded-and-compiled-in-julia-compares-to-interpreted-julia-in-terms-of-performance/89995 "2022-11-09T17:47:20Z")

</div>

I know that I can generate an executable file in Julia: Creating a binary from Julia code · PackageCompiler In this page has a timing comparison between the interpreted and compiled app. My question is: How the perfor…

---

## [Adding parameters to function definition avoids allocations](https://discourse.julialang.org/t/adding-parameters-to-function-definition-avoids-allocations/89975)

<div class="topic-metadata">

**Author:** [@user664303](https://discourse.julialang.org/u/user664303)\
**Replies:** 3\
**Last updated:** [November 9, 2022, 3:43pm UTC](https://discourse.julialang.org/t/adding-parameters-to-function-definition-avoids-allocations/89975 "2022-11-09T15:43:32Z")

</div>

I’m trying to get a small piece of code that I’ll run millions of times to run without allocations. There is a small allocation that I cannot understand the cause of (for example, using Profile.Allocs cannot attribute th…

---

## [Measure data movement Distributed](https://discourse.julialang.org/t/measure-data-movement-distributed/89966)

<div class="topic-metadata">

**Author:** [@jarbus](https://discourse.julialang.org/u/jarbus)\
**Replies:** 0\
**Last updated:** [November 9, 2022, 4:30am UTC](https://discourse.julialang.org/t/measure-data-movement-distributed/89966 "2022-11-09T04:30:17Z")

</div>

Is there any way to measure the amount of data getting sent to workers? For the example in the Data Movement section of the Distributed Manual, it would be very helpful to tell if a call is moving data or not, to directl…

---

## [Numerical intergration order problem (probably)](https://discourse.julialang.org/t/numerical-intergration-order-problem-probably/89960)

<div class="topic-metadata">

**Author:** [@swish47](https://discourse.julialang.org/u/swish47)\
**Replies:** 0\
**Last updated:** [November 8, 2022, 11:51pm UTC](https://discourse.julialang.org/t/numerical-intergration-order-problem-probably/89960 "2022-11-08T23:51:34Z")

</div>

This is a long example inspired by quantum physics. I tried to abstract the key points and write a typically similar and simpler example, however I failed. Thanks for read my naive and tedious codes in advance. using HC…

---

## [Computational time of appending an array and mutating an array](https://discourse.julialang.org/t/computational-time-of-appending-an-array-and-mutating-an-array/89118)

<div class="topic-metadata">

**Author:** [@bdas123](https://discourse.julialang.org/u/bdas123)\
**Replies:** 4\
**Last updated:** [November 8, 2022, 1:41pm UTC](https://discourse.julialang.org/t/computational-time-of-appending-an-array-and-mutating-an-array/89118 "2022-11-08T13:41:06Z")

</div>

I want to transition from Zygote.jl to AbstractDifferentiation.jl so that I can mutate arrays instead of appending them. Before I do so, I want to make sure that mutating arrays is faster than appending an array. I’ve r…

---

## [Multiplication of vector of matrices and vector of vectors](https://discourse.julialang.org/t/multiplication-of-vector-of-matrices-and-vector-of-vectors/89874)

<div class="topic-metadata">

**Author:** [@dalbandea](https://discourse.julialang.org/u/dalbandea)\
**Replies:** 3\
**Last updated:** [November 7, 2022, 3:59pm UTC](https://discourse.julialang.org/t/multiplication-of-vector-of-matrices-and-vector-of-vectors/89874 "2022-11-07T15:59:50Z")

</div>

I’m trying to optimize a multiplication of a vector of Matrices A of size (L, L, L) and a vector of vectors x of size (L,L), which will result in a vector of vectors c of size (L, L). That is, each c\[i,:\] is the result …

---

## [Silhouette coefficient calculation](https://discourse.julialang.org/t/silhouette-coefficient-calculation/89861)

<div class="topic-metadata">

**Author:** [@Shayan](https://discourse.julialang.org/u/Shayan)\
**Replies:** 5\
**Last updated:** [November 7, 2022, 1:49pm UTC](https://discourse.julialang.org/t/silhouette-coefficient-calculation/89861 "2022-11-07T13:49:47Z")

</div>

I’ve written a Julia script to calculate the silhouette coefficient of the ClusterAnalysis.jl Kmeans’ result, but it’s highly inefficient and slow. I’ve written the procedure for both common and simplified versions of th…

---

## [Usage of lazy vector instead of function](https://discourse.julialang.org/t/usage-of-lazy-vector-instead-of-function/89766)

<div class="topic-metadata">

**Author:** [@Salmon](https://discourse.julialang.org/u/Salmon)\
**Replies:** 22\
**Last updated:** [November 7, 2022, 10:37am UTC](https://discourse.julialang.org/t/usage-of-lazy-vector-instead-of-function/89766 "2022-11-07T10:37:22Z")

</div>

Hi everyone, recently I stumbled across a nice benchmark between different languages and was having a look at the Julia implementation: Now in general, I understand why there is a use case for lazy arrays, but is this…

---

## [Running Julia with multi-threading with \`qsub\`](https://discourse.julialang.org/t/running-julia-with-multi-threading-with-qsub/89850)

<div class="topic-metadata">

**Author:** [@Rick](https://discourse.julialang.org/u/Rick)\
**Replies:** 2\
**Last updated:** [November 6, 2022, 8:20pm UTC](https://discourse.julialang.org/t/running-julia-with-multi-threading-with-qsub/89850 "2022-11-06T20:20:57Z")

</div>

Hi everyone!! I have a question on what is the correct way to run Julia with multithreads with qsub. I am trying to submit a job to the cluster to run Julia with multiple threads. I did the followings: julia "test.jl" …

---

## [Clear variables in caller workspace](https://discourse.julialang.org/t/clear-variables-in-caller-workspace/89825)

<div class="topic-metadata">

**Author:** [@hclin](https://discourse.julialang.org/u/hclin)\
**Replies:** 2\
**Last updated:** [November 6, 2022, 11:22am UTC](https://discourse.julialang.org/t/clear-variables-in-caller-workspace/89825 "2022-11-06T11:22:15Z")

</div>

Hi all, I want to utilize memory usage in Julia. Before I do some heavy computations, I want to clear some big matrices to optimize the memory usage in my code. For example, I have two big matrices, A and B. In the fun…

---

## [Why is type inference failing here?](https://discourse.julialang.org/t/why-is-type-inference-failing-here/89803)

<div class="topic-metadata">

**Author:** [@robsmith11](https://discourse.julialang.org/u/robsmith11)\
**Replies:** 3\
**Last updated:** [November 5, 2022, 2:09pm UTC](https://discourse.julialang.org/t/why-is-type-inference-failing-here/89803 "2022-11-05T14:09:42Z")

</div>

In the following example, it seems like it should be simple for Julia to infer that the type of prev\_x is Float64. Why is it instead getting assigned a boxed type? julia\> function tf(xs) prev\_x = xs\[1\] …

---

## [Unexpected garbage collection when using append!](https://discourse.julialang.org/t/unexpected-garbage-collection-when-using-append/89732)

<div class="topic-metadata">

**Author:** [@jewh](https://discourse.julialang.org/u/jewh)\
**Replies:** 20\
**Last updated:** [November 4, 2022, 3:22pm UTC](https://discourse.julialang.org/t/unexpected-garbage-collection-when-using-append/89732 "2022-11-04T15:22:59Z")

</div>

Working with lots of vectors of variable length and contents so I’m using the push! and append! methods frequently in my code. Using @benchmark from BenchmarkTools I’ve identified garbage collection associated with these…

---

## [What exactly is "allocation" in Julia?](https://discourse.julialang.org/t/what-exactly-is-allocation-in-julia/89579)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 45\
**Last updated:** [November 4, 2022, 2:19pm UTC](https://discourse.julialang.org/t/what-exactly-is-allocation-in-julia/89579 "2022-11-04T14:19:50Z")

</div>

When dealing with performances, after type instability, the second “culprit” that arises is often memory allocation. But what exactly is memory allocation for Julia? Why it influences performances so strongly ? What are…

---

## [Performance comparison - Flux.jl's Adam vs Jax's Adam](https://discourse.julialang.org/t/performance-comparison-flux-jls-adam-vs-jaxs-adam/89553)

<div class="topic-metadata">

**Author:** [@richinex](https://discourse.julialang.org/u/richinex)\
**Replies:** 33\
**Last updated:** [November 3, 2022, 5:27am UTC](https://discourse.julialang.org/t/performance-comparison-flux-jls-adam-vs-jaxs-adam/89553 "2022-11-03T05:27:34Z")

</div>

Hello guys, I have been wondering about Julia’s performance and would like to know if it is really true that Julia is really faster than python as is always stated because I have not yet seen any performance gain since I…

---

## [Help building MWE for 1.8 latency regression](https://discourse.julialang.org/t/help-building-mwe-for-1-8-latency-regression/84796)

<div class="topic-metadata">

**Author:** [@marius311](https://discourse.julialang.org/u/marius311)\
**Replies:** 11\
**Last updated:** [November 2, 2022, 8:02am UTC](https://discourse.julialang.org/t/help-building-mwe-for-1-8-latency-regression/84796 "2022-11-02T08:02:29Z")

</div>

Motivated by the SnoopPrecompile announcement, I checked out my package’s TTFX on 1.8rc3. Using a sample script like: # test\_startup.jl @time using CMBLensing @time LenseFlow(FlatMap(randn(10,10))/1e6) \* FlatMap(randn(1…

---

## [From toy to production code with sparse matrix and sparse-direct factorizations](https://discourse.julialang.org/t/from-toy-to-production-code-with-sparse-matrix-and-sparse-direct-factorizations/89105)

<div class="topic-metadata">

**Author:** [@Gravlax](https://discourse.julialang.org/u/Gravlax)\
**Replies:** 17\
**Last updated:** [November 1, 2022, 10:01pm UTC](https://discourse.julialang.org/t/from-toy-to-production-code-with-sparse-matrix-and-sparse-direct-factorizations/89105 "2022-11-01T22:01:25Z")

</div>

Dear all, I would like to port a toy code that assembles one sparse matrix and solves one linear system of equation to a production code that assembles many sparse matrices and solves many systems of equation iterativel…

---

## [Best \`separate\` performance?](https://discourse.julialang.org/t/best-separate-performance/25841)

<div class="topic-metadata">

**Author:** [@louisponet](https://discourse.julialang.org/u/louisponet)\
**Replies:** 18\
**Last updated:** [November 1, 2022, 3:13pm UTC](https://discourse.julialang.org/t/best-separate-performance/25841 "2022-11-01T15:13:57Z")

</div>

Hi all, I’ve been trying out some ways of separating a Vector into a true and false part based on predicate f, and the basic code below is what I ended up with. My question/challenge is whether anyone knows a faster way …

---

## [Bootstrapping is fast on M1 Max, slow on HPC Knights Landing / Broadwell](https://discourse.julialang.org/t/bootstrapping-is-fast-on-m1-max-slow-on-hpc-knights-landing-broadwell/89463)

<div class="topic-metadata">

**Author:** [@JAF](https://discourse.julialang.org/u/JAF)\
**Replies:** 12\
**Last updated:** [October 31, 2022, 9:05am UTC](https://discourse.julialang.org/t/bootstrapping-is-fast-on-m1-max-slow-on-hpc-knights-landing-broadwell/89463 "2022-10-31T09:05:26Z")

</div>

Hi, I have successfully converted a statistical bootstrapping experiment originally written in Python. My workflow loads multiple datasets of grid data (Z sets of MxNxT) that represent numerical simulations with varying…

---

## [Why is this type check so slow](https://discourse.julialang.org/t/why-is-this-type-check-so-slow/89546)

<div class="topic-metadata">

**Author:** [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Replies:** 1\
**Last updated:** [October 31, 2022, 8:32am UTC](https://discourse.julialang.org/t/why-is-this-type-check-so-slow/89546 "2022-10-31T08:32:11Z")

</div>

Shouldn’t type checks for statically known types be free at runtime? julia\> const IntUInt = Union{Int, UInt} Union{Int64, UInt64} julia\> struct T{U \<: Integer} x::U end julia\> @btime 1 isa T{\<:IntUIn…

---

## [ProfileView takes a long time for "using"](https://discourse.julialang.org/t/profileview-takes-a-long-time-for-using/89530)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 2\
**Last updated:** [October 31, 2022, 7:35am UTC](https://discourse.julialang.org/t/profileview-takes-a-long-time-for-using/89530 "2022-10-31T07:35:53Z")

</div>

julia\> using Profile julia\> @profile using PythonCall \`\`profiletook a long time (way more than 10 sec.), vs@time using. Is that normal? I thought it, or when using @profilevewdirectly, had hung (maybe it did). It did f…

---

## [How to ensure function is type-stable and allocation-free](https://discourse.julialang.org/t/how-to-ensure-function-is-type-stable-and-allocation-free/89509)

<div class="topic-metadata">

**Author:** [@Max\_A](https://discourse.julialang.org/u/Max_A)\
**Replies:** 2\
**Last updated:** [October 30, 2022, 5:58pm UTC](https://discourse.julialang.org/t/how-to-ensure-function-is-type-stable-and-allocation-free/89509 "2022-10-30T17:58:24Z")

</div>

I am writing a function and I’m trying to ensure that it is type-stable and allocation-free. I am using the @code\_warntype to ensure type-stability and @btime to determine memory allocation. Here is my code: # we assum…

---

## [Julia matrix-multiplication performance](https://discourse.julialang.org/t/julia-matrix-multiplication-performance/55175)

<div class="topic-metadata">

**Author:** [@evanfields](https://discourse.julialang.org/u/evanfields)\
**Replies:** 20\
**Last updated:** [October 30, 2022, 12:02pm UTC](https://discourse.julialang.org/t/julia-matrix-multiplication-performance/55175 "2022-10-30T12:02:57Z")

</div>

Julia’s built in matrix multiplication seems to be much faster than this LoopVectorization snippet? julia\> r1 = rand(1000, 1000); r2 = rand(1000, 1000); c = zeros(1000, 1000); julia\> @belapsed $c .= $r1 \* $r2 0.0257447 …

---

## [Muladd! (useful?)](https://discourse.julialang.org/t/muladd-useful/89517)

<div class="topic-metadata">

**Author:** [@photor](https://discourse.julialang.org/u/photor)\
**Replies:** 1\
**Last updated:** [October 30, 2022, 7:57am UTC](https://discourse.julialang.org/t/muladd-useful/89517 "2022-10-30T07:57:00Z")

</div>

Hi, I know there is the muladd function, but it seems there isn’t an in-place version muladd! of it?

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

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