# Performance

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

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

**Page:** 22

---

## [Fast Exponential of a large matrix](https://discourse.julialang.org/t/fast-exponential-of-a-large-matrix/116998)

<div class="topic-metadata">

**Author:** [@devanshu](https://discourse.julialang.org/u/devanshu)\
**Replies:** 14\
**Last updated:** [July 15, 2024, 7:21am UTC](https://discourse.julialang.org/t/fast-exponential-of-a-large-matrix/116998 "2024-07-15T07:21:47Z")

</div>

I have to perform the exponential of a matrix. I have compared the built-in exp function to the exponential! function from the ExponentialUtilites package. The latter is supposed to be much faster than the built-in funct…

---

## [Compare array (of String) with no regard to the order](https://discourse.julialang.org/t/compare-array-of-string-with-no-regard-to-the-order/62322)

<div class="topic-metadata">

**Author:** [@Laco\_Kovac](https://discourse.julialang.org/u/Laco_Kovac)\
**Replies:** 8\
**Last updated:** [July 15, 2024, 4:17am UTC](https://discourse.julialang.org/t/compare-array-of-string-with-no-regard-to-the-order/62322 "2024-07-15T04:17:04Z")

</div>

Le’t have 2 arrays (of String, but it doesn’t really matter). I need to compare them, but the order is irrelevant, just that they contain the same Strings/items (and are of the same length, obviously). i.e. comparison o…

---

## [Increased allocations when using threads](https://discourse.julialang.org/t/increased-allocations-when-using-threads/116902)

<div class="topic-metadata">

**Author:** [@throwaway](https://discourse.julialang.org/u/throwaway)\
**Replies:** 20\
**Last updated:** [July 11, 2024, 4:59pm UTC](https://discourse.julialang.org/t/increased-allocations-when-using-threads/116902 "2024-07-11T16:59:50Z")

</div>

Hello everyone, While playing with Base multithreading I noticed the following odd behaviour (MRE follows): # Single-threaded code always results in exactly one allocation julia\> a = 0.0; @allocations a+=π 1 # Reproduc…

---

## [Help reducing compilation and inference time](https://discourse.julialang.org/t/help-reducing-compilation-and-inference-time/116630)

<div class="topic-metadata">

**Author:** [@osimonn](https://discourse.julialang.org/u/osimonn)\
**Replies:** 71\
**Last updated:** [July 11, 2024, 1:53pm UTC](https://discourse.julialang.org/t/help-reducing-compilation-and-inference-time/116630 "2024-07-11T13:53:27Z")

</div>

We have a simulator in our company that’s fully written in Julia. The codebase is quite large. We have been suffering from very high latency for some time now. I took the initiative of trying to solve the latency issue b…

---

## [Problem with creating view of vectors in vector of vectors (it keeps allocating)](https://discourse.julialang.org/t/problem-with-creating-view-of-vectors-in-vector-of-vectors-it-keeps-allocating/116825)

<div class="topic-metadata">

**Author:** [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Replies:** 2\
**Last updated:** [July 9, 2024, 3:20pm UTC](https://discourse.julialang.org/t/problem-with-creating-view-of-vectors-in-vector-of-vectors-it-keeps-allocating/116825 "2024-07-09T15:20:58Z")

</div>

I have a problem where Julai keeps allocating, causing something I think should be fast to be slow. Simple example: vec\_vec = \[1:100 for i in 1:100\] @time vals = \[vec for vec in vec\_vec\] # Fast, few allocations @time va…

---

## [Using a Custom Length Vector type to define function Parameters](https://discourse.julialang.org/t/using-a-custom-length-vector-type-to-define-function-parameters/116809)

<div class="topic-metadata">

**Author:** [@Maddy](https://discourse.julialang.org/u/Maddy)\
**Replies:** 20\
**Last updated:** [July 9, 2024, 1:57pm UTC](https://discourse.julialang.org/t/using-a-custom-length-vector-type-to-define-function-parameters/116809 "2024-07-09T13:57:55Z")

</div>

I want to dispatch 2 different functions for f(vect::VectorLength2) and f(vect::VectorLength3) Basically, is there any way to have a type that has this behaviour: typeof(\[1,2\]) \<: VectorLength2 \> true typeof(\[1,2,3\]…

---

## [Memory Allocation when using mul! with sparse arrays and views](https://discourse.julialang.org/t/memory-allocation-when-using-mul-with-sparse-arrays-and-views/111276)

<div class="topic-metadata">

**Author:** [@leespen1](https://discourse.julialang.org/u/leespen1)\
**Replies:** 4\
**Last updated:** [July 8, 2024, 6:30pm UTC](https://discourse.julialang.org/t/memory-allocation-when-using-mul-with-sparse-arrays-and-views/111276 "2024-07-08T18:30:07Z")

</div>

I am writing code which performs a five argument mul! operation (from LinearAlgebra) inside a for loop where performance is critical. When using a sparse array instead of a matrix, the operation allocates memory: julia\>…

---

## [Type instabilities when using broadcasting with splat operator](https://discourse.julialang.org/t/type-instabilities-when-using-broadcasting-with-splat-operator/116698)

<div class="topic-metadata">

**Author:** [@danielelamberto](https://discourse.julialang.org/u/danielelamberto)\
**Replies:** 2\
**Last updated:** [July 6, 2024, 4:03pm UTC](https://discourse.julialang.org/t/type-instabilities-when-using-broadcasting-with-splat-operator/116698 "2024-07-06T16:03:39Z")

</div>

Hi, I’m trying to optimize my code and I noticed a type instability when using broadcasting together with the splat operator, as in the following code: function f(x, p1, p2) return x \* p1 + p2 end x = rand(1000) p…

---

## [JET: are union incurred runtime dispatches really happening?](https://discourse.julialang.org/t/jet-are-union-incurred-runtime-dispatches-really-happening/116635)

<div class="topic-metadata">

**Author:** [@filchristou](https://discourse.julialang.org/u/filchristou)\
**Replies:** 10\
**Last updated:** [July 5, 2024, 11:01am UTC](https://discourse.julialang.org/t/jet-are-union-incurred-runtime-dispatches-really-happening/116635 "2024-07-05T11:01:46Z")

</div>

I tend to think that the compiler is pretty smart and staff like union-splitting are handled gracefully under the hood. However, I was currently using JET.@code\_opt and I saw some dynamic dispatch where I thought there …

---

## [How can I improve the computational performance of my code (ODEProblem solving)?](https://discourse.julialang.org/t/how-can-i-improve-the-computational-performance-of-my-code-odeproblem-solving/114425)

<div class="topic-metadata">

**Author:** [@chooron](https://discourse.julialang.org/u/chooron)\
**Replies:** 8\
**Last updated:** [July 4, 2024, 9:33am UTC](https://discourse.julialang.org/t/how-can-i-improve-the-computational-performance-of-my-code-odeproblem-solving/114425 "2024-07-04T09:33:20Z")

</div>

I am currently building a library that can flexibly solve and optimize a variety of hydrological models (including some equations), which typically belongs to the ODEProblem. However, to ensure the flexibility of the lib…

---

## [Readers–writer lock using DataFrame](https://discourse.julialang.org/t/readers-writer-lock-using-dataframe/116550)

<div class="topic-metadata">

**Author:** [@JesperMartinsson](https://discourse.julialang.org/u/JesperMartinsson)\
**Replies:** 6\
**Last updated:** [July 4, 2024, 4:49am UTC](https://discourse.julialang.org/t/readers-writer-lock-using-dataframe/116550 "2024-07-04T04:49:51Z")

</div>

Hi, I have an application where one async task updates a DataFrame with new data every minute, while multiple tasks read the DataFrame at random times. I need to make this thread-safe, possibly by using a lock, to preve…

---

## [Bad performance from parametric struct dispatch](https://discourse.julialang.org/t/bad-performance-from-parametric-struct-dispatch/116594)

<div class="topic-metadata">

**Author:** [@quantumtwist](https://discourse.julialang.org/u/quantumtwist)\
**Replies:** 9\
**Last updated:** [July 3, 2024, 4:03pm UTC](https://discourse.julialang.org/t/bad-performance-from-parametric-struct-dispatch/116594 "2024-07-03T16:03:30Z")

</div>

While trying to optimize the hot loop of my code, I ran into a very strange performance footgun that is reducing the speed of a simple function by at least ~100ns, which is a 10x performance hit for my use case. Questio…

---

## [Time Calculation for Recurring Function Calls](https://discourse.julialang.org/t/time-calculation-for-recurring-function-calls/116578)

<div class="topic-metadata">

**Author:** [@usaer](https://discourse.julialang.org/u/usaer)\
**Replies:** 6\
**Last updated:** [July 3, 2024, 1:04pm UTC](https://discourse.julialang.org/t/time-calculation-for-recurring-function-calls/116578 "2024-07-03T13:04:26Z")

</div>

Hi all, I have a function xyz which I call at different positions inside my main function. Is there any way that I could get the cummulative sum of computational time for all the function xyz calls?

---

## [Slow code to compute b=A\*x](https://discourse.julialang.org/t/slow-code-to-compute-b-a-x/116562)

<div class="topic-metadata">

**Author:** [@ww1g11](https://discourse.julialang.org/u/ww1g11)\
**Replies:** 7\
**Last updated:** [July 3, 2024, 7:55am UTC](https://discourse.julialang.org/t/slow-code-to-compute-b-a-x/116562 "2024-07-03T07:55:35Z")

</div>

Hi all, I wrote a very simple code to compute b=A\*x and found that it is slow, please see the following codes to compare sum1, sum2 and sum3: using TimerOutputs const timer = TimerOutput() function test(N=20000) A…

---

## [How to add axis labels, color bar, and marker shape to TernaryDiagrams?](https://discourse.julialang.org/t/how-to-add-axis-labels-color-bar-and-marker-shape-to-ternarydiagrams/116513)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 0\
**Last updated:** [July 2, 2024, 10:26am UTC](https://discourse.julialang.org/t/how-to-add-axis-labels-color-bar-and-marker-shape-to-ternarydiagrams/116513 "2024-07-02T10:26:46Z")

</div>

Hello, I have two data sets that I would like to represent as a 3-simplex. My goal is to plot the first 3 dimensions as a ternary diagram with TernaryDiagrams.jl and represent the fourth dimension with a color gradient.…

---

## [Declaring types: Vector{Union{Int64, Matrix{Int64}}} is much slower than Vector{Any}, why is that?](https://discourse.julialang.org/t/declaring-types-vector-union-int64-matrix-int64-is-much-slower-than-vector-any-why-is-that/116480)

<div class="topic-metadata">

**Author:** [@13299118606](https://discourse.julialang.org/u/13299118606)\
**Replies:** 10\
**Last updated:** [July 2, 2024, 7:48am UTC](https://discourse.julialang.org/t/declaring-types-vector-union-int64-matrix-int64-is-much-slower-than-vector-any-why-is-that/116480 "2024-07-02T07:48:48Z")

</div>

Declaring types: Vector{Union{Int64, Matrix{Int64}}} is much slower than Vector{Any}, why is that? The following code is different from my declarations. f0 is not declared, f1 is declared ::Vector{Any}, and f2 is declar…

---

## [Insert value with fixed size/gc time](https://discourse.julialang.org/t/insert-value-with-fixed-size-gc-time/116419)

<div class="topic-metadata">

**Author:** [@Sihyun\_Kim](https://discourse.julialang.org/u/Sihyun_Kim)\
**Replies:** 5\
**Last updated:** [July 1, 2024, 9:03am UTC](https://discourse.julialang.org/t/insert-value-with-fixed-size-gc-time/116419 "2024-07-01T09:03:43Z")

</div>

I am a julia beginner. I am working on a large structural (economic) model. But, the problem is that one iteration of the entire model takes 395 seconds, and its 42.84% consists of gc time. My suspicion is that the follo…

---

## [Using Tensorial.jl to deal with Tensors with high symmetries](https://discourse.julialang.org/t/using-tensorial-jl-to-deal-with-tensors-with-high-symmetries/116360)

<div class="topic-metadata">

**Author:** [@Uranium238](https://discourse.julialang.org/u/Uranium238)\
**Replies:** 1\
**Last updated:** [June 28, 2024, 3:32pm UTC](https://discourse.julialang.org/t/using-tensorial-jl-to-deal-with-tensors-with-high-symmetries/116360 "2024-06-28T15:32:35Z")

</div>

I am writing code that deals with contractions of large tensors which possess high symmetry. As an example, I have a tensor g whose certain entries are read from a data file. The remaining entries are entered using the …

---

## [Slow performance when solving SDE for a large number of functions in a loop](https://discourse.julialang.org/t/slow-performance-when-solving-sde-for-a-large-number-of-functions-in-a-loop/116337)

<div class="topic-metadata">

**Author:** [@DavidBerghaus](https://discourse.julialang.org/u/DavidBerghaus)\
**Replies:** 3\
**Last updated:** [June 28, 2024, 2:56pm UTC](https://discourse.julialang.org/t/slow-performance-when-solving-sde-for-a-large-number-of-functions-in-a-loop/116337 "2024-06-28T14:56:03Z")

</div>

I have the following use case: I have a large dataset of 1 million drift and diffusion functions (stored as strings of the symbolic expressions) for which I want to solve the corresponding SDEs. This is my current appr…

---

## [Getting started with Metal.jl](https://discourse.julialang.org/t/getting-started-with-metal-jl/116309)

<div class="topic-metadata">

**Author:** [@marianoarnaiz](https://discourse.julialang.org/u/marianoarnaiz)\
**Replies:** 1\
**Last updated:** [June 28, 2024, 10:48am UTC](https://discourse.julialang.org/t/getting-started-with-metal-jl/116309 "2024-06-28T10:48:11Z")

</div>

Hi everyone. So, I have never worked with GPU, I have a M1 Mac and I am trying to get some codes of mine to run faster. I have a code that I know very well and I thought it might be a good exercise to translate it to Me…

---

## [Vectorization of multivariate normal PDF](https://discourse.julialang.org/t/vectorization-of-multivariate-normal-pdf/116248)

<div class="topic-metadata">

**Author:** [@xor0110](https://discourse.julialang.org/u/xor0110)\
**Replies:** 1\
**Last updated:** [June 26, 2024, 7:57am UTC](https://discourse.julialang.org/t/vectorization-of-multivariate-normal-pdf/116248 "2024-06-26T07:57:54Z")

</div>

I would like to compute the PDF of a multivariate normal distribution of given parameters for a number of input points. (eg MvNorm for several vectors at once) This is for a particle filter, many such computations going …

---

## [\`ENV\["JULIA\_DEBUG"\] == "MyModule" && expensive\_debug\_method()\` good practice?](https://discourse.julialang.org/t/env-julia-debug-mymodule-expensive-debug-method-good-practice/116197)

<div class="topic-metadata">

**Author:** [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Replies:** 7\
**Last updated:** [June 25, 2024, 9:49pm UTC](https://discourse.julialang.org/t/env-julia-debug-mymodule-expensive-debug-method-good-practice/116197 "2024-06-25T21:49:09Z")

</div>

Will Julia compile away lines like ENV\["JULIA\_DEBUG"\] == "MyModule" && expensive\_debug\_method() when the environment variable is not set, or does the dictionary lookup happen at runtime? If the latter, is there a good …

---

## [Specifying analytical Jacobian in NonlinearProblem à la Optim.only\_fg!](https://discourse.julialang.org/t/specifying-analytical-jacobian-in-nonlinearproblem-a-la-optim-only-fg/115991)

<div class="topic-metadata">

**Author:** [@dieg0](https://discourse.julialang.org/u/dieg0)\
**Replies:** 1\
**Last updated:** [June 25, 2024, 6:55pm UTC](https://discourse.julialang.org/t/specifying-analytical-jacobian-in-nonlinearproblem-a-la-optim-only-fg/115991 "2024-06-25T18:55:15Z")

</div>

When minimizing a costly function f(x) using Optim.jl and providing the gradient \\nabla f(x), one can use Optim.only\_fg! to compute the gradient and the function itself within the same function to avoid repeating computa…

---

## [Optimal way to broadcast over a container of funcs](https://discourse.julialang.org/t/optimal-way-to-broadcast-over-a-container-of-funcs/116156)

<div class="topic-metadata">

**Author:** [@miguelborrero](https://discourse.julialang.org/u/miguelborrero)\
**Replies:** 11\
**Last updated:** [June 25, 2024, 1:01am UTC](https://discourse.julialang.org/t/optimal-way-to-broadcast-over-a-container-of-funcs/116156 "2024-06-25T01:01:26Z")

</div>

Hi there, I have a vector (more generally: a list) of functions the map a vector to a vector and also a matrix where each row is to be populated by each of the functions. See below an example: function test() f\_vec…

---

## [Scaling a sparse matrix row-wise and column-wise too slow](https://discourse.julialang.org/t/scaling-a-sparse-matrix-row-wise-and-column-wise-too-slow/115956)

<div class="topic-metadata">

**Author:** [@pitsianis](https://discourse.julialang.org/u/pitsianis)\
**Replies:** 20\
**Last updated:** [June 23, 2024, 9:17pm UTC](https://discourse.julialang.org/t/scaling-a-sparse-matrix-row-wise-and-column-wise-too-slow/115956 "2024-06-23T21:17:22Z")

</div>

I need to scale a sparse matrix row-wise and column-wise. That is S\[i,j\] = r\[i\] \* A\[i,j\] \* c\[j\] If I write it the way you’d see it in a math book, S = spdiagm(r) \* A \* spdiagm(c) the expression takes 8x times more th…

---

## [Converting Vector to Tuple seems not optimal](https://discourse.julialang.org/t/converting-vector-to-tuple-seems-not-optimal/115989)

<div class="topic-metadata">

**Author:** [@miguelborrero](https://discourse.julialang.org/u/miguelborrero)\
**Replies:** 11\
**Last updated:** [June 22, 2024, 7:01am UTC](https://discourse.julialang.org/t/converting-vector-to-tuple-seems-not-optimal/115989 "2024-06-22T07:01:31Z")

</div>

Hi there, I am working on improving the memory allocation performance of my code and in learning about how to do so I came across the fact that tuples are much cheaper to store that vectors. For this reason I was trying…

---

## [Seamless integration of Bumper.jl](https://discourse.julialang.org/t/seamless-integration-of-bumper-jl/115916)

<div class="topic-metadata">

**Author:** [@Tomas\_Pevny](https://discourse.julialang.org/u/Tomas_Pevny)\
**Replies:** 13\
**Last updated:** [June 21, 2024, 12:01pm UTC](https://discourse.julialang.org/t/seamless-integration-of-bumper-jl/115916 "2024-06-21T12:01:05Z")

</div>

Hi All, I have a rather naive question. I have a function computing heuristic value of a state in planning using graph neural network. This function takes state, converts it to a graph uses network and return a single s…

---

## [Optimizing \`powermod\`](https://discourse.julialang.org/t/optimizing-powermod/115936)

<div class="topic-metadata">

**Author:** [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Replies:** 12\
**Last updated:** [June 20, 2024, 3:50pm UTC](https://discourse.julialang.org/t/optimizing-powermod/115936 "2024-06-20T15:50:23Z")

</div>

Here’s how you can implement powermod from scratch in Julia and achieve better performance than the built-in version. (Maybe I need to add more safety checks?) function my\_powermod(a::Int64, b::Int64, c::Int64) @ass…

---

## [Python big integer vs. Julia big integer arithmetic](https://discourse.julialang.org/t/python-big-integer-vs-julia-big-integer-arithmetic/115777)

<div class="topic-metadata">

**Author:** [@oOosys](https://discourse.julialang.org/u/oOosys)\
**Replies:** 89\
**Last updated:** [June 20, 2024, 1:12pm UTC](https://discourse.julialang.org/t/python-big-integer-vs-julia-big-integer-arithmetic/115777 "2024-06-20T13:12:39Z")

</div>

Here what I am wondering about: ~ $ time python -c "print( 3^100000000000 % 102 )" 91 real 0m0.030s user 0m0.026s sys 0m0.004s ~ $ time julia -e "println( big(3)^100000000000 % 102 )" ERROR: OutOfMemoryError() Stacktra…

---

## [Misunderstanding Allocs for Monte Carlo summation](https://discourse.julialang.org/t/misunderstanding-allocs-for-monte-carlo-summation/115894)

<div class="topic-metadata">

**Author:** [@Spuriosity1](https://discourse.julialang.org/u/Spuriosity1)\
**Replies:** 3\
**Last updated:** [June 20, 2024, 12:55am UTC](https://discourse.julialang.org/t/misunderstanding-allocs-for-monte-carlo-summation/115894 "2024-06-20T00:55:14Z")

</div>

I have a simple test function here: function tester(nreps::Int, n\_x::Int) res = zeros(Float64, n\_x) for \_ = 1:nreps res += rand(Float64, n\_x) end return res end I do not understand the behaviour…

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

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