# Performance

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

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

**Page:** 30

---

## [Why is garbage collection called here?](https://discourse.julialang.org/t/why-is-garbage-collection-called-here/109870)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 11\
**Last updated:** [February 8, 2024, 11:02am UTC](https://discourse.julialang.org/t/why-is-garbage-collection-called-here/109870 "2024-02-08T11:02:48Z")

</div>

Hello! I’ve been hitting my head on the wall for a few days now. I have a function which when using @profview seems to call the garbage collection (red bar), but it does not allocate. It is updatexij! (which is resized …

---

## [What is meant by this tip for StaticArrays?](https://discourse.julialang.org/t/what-is-meant-by-this-tip-for-staticarrays/109757)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 6\
**Last updated:** [February 6, 2024, 8:21am UTC](https://discourse.julialang.org/t/what-is-meant-by-this-tip-for-staticarrays/109757 "2024-02-06T08:21:49Z")

</div>

Hello! In the Github of StaticArrays.jl, the following is stated: Note that in the current implementation, working with large StaticArray s puts a lot of stress on the compiler, and becomes slower than Base.Array as t…

---

## [How can I fix the type instability](https://discourse.julialang.org/t/how-can-i-fix-the-type-instability/109730)

<div class="topic-metadata">

**Author:** [@RayleighLord](https://discourse.julialang.org/u/RayleighLord)\
**Replies:** 3\
**Last updated:** [February 5, 2024, 1:45pm UTC](https://discourse.julialang.org/t/how-can-i-fix-the-type-instability/109730 "2024-02-05T13:45:49Z")

</div>

Hello, I have the following MWE, where I cannot remove the type instability that appears from the call on the last line. abstract type FrictionLaw end struct Cubic{T \<: Real} \<: FrictionLaw γ::T end g(x, law::Cub…

---

## [Allocations in broadcasted assignment (StackOverflow question)](https://discourse.julialang.org/t/allocations-in-broadcasted-assignment-stackoverflow-question/109680)

<div class="topic-metadata">

**Author:** [@bert](https://discourse.julialang.org/u/bert)\
**Replies:** 2\
**Last updated:** [February 4, 2024, 7:21am UTC](https://discourse.julialang.org/t/allocations-in-broadcasted-assignment-stackoverflow-question/109680 "2024-02-04T07:21:49Z")

</div>

I came across this StackOverflow post and am wondering what the solution is. I have played around with the example in this post (copied below) and, like the author, cannot get rid of the allocation in d’s broadcast assig…

---

## [Memory build-up when loading DataFrames in a loop](https://discourse.julialang.org/t/memory-build-up-when-loading-dataframes-in-a-loop/109678)

<div class="topic-metadata">

**Author:** [@isaacjeffersonlee](https://discourse.julialang.org/u/isaacjeffersonlee)\
**Replies:** 2\
**Last updated:** [February 3, 2024, 6:24pm UTC](https://discourse.julialang.org/t/memory-build-up-when-loading-dataframes-in-a-loop/109678 "2024-02-03T18:24:02Z")

</div>

When I sequentially load a very large DataFrame into memory and then sort it in place, the memory usage builds eventually running out of memory? Is there anything I can do to prevent this? Why is the garbage collector n…

---

## [Unreasonably fast FFT on CUDA](https://discourse.julialang.org/t/unreasonably-fast-fft-on-cuda/109398)

<div class="topic-metadata">

**Author:** [@jabru](https://discourse.julialang.org/u/jabru)\
**Replies:** 8\
**Last updated:** [February 3, 2024, 3:56pm UTC](https://discourse.julialang.org/t/unreasonably-fast-fft-on-cuda/109398 "2024-02-03T15:56:01Z")

</div>

Hey there, so I am currently working on an algorithm that will likely strongly depend on the FFT very significantly. Therefore I am considering to do the FFT in FFTW on Cuda to speed up the algorithm. It is a 3d FFT wit…

---

## [Help with this code (deallocation/pointers on sparse matrices)](https://discourse.julialang.org/t/help-with-this-code-deallocation-pointers-on-sparse-matrices/109574)

<div class="topic-metadata">

**Author:** [@Enlil50](https://discourse.julialang.org/u/Enlil50)\
**Replies:** 31\
**Last updated:** [February 3, 2024, 9:32am UTC](https://discourse.julialang.org/t/help-with-this-code-deallocation-pointers-on-sparse-matrices/109574 "2024-02-03T09:32:46Z")

</div>

This is a follow up of a recent thread I made Sparse matrices copy arrays, do not view them I sum up all the shared ideas, with 2 code examples. This is intended as a much clearer version and prosecution of that thread,…

---

## [Why does profiling suggest that integer comparison dominates broadcasted assignment?](https://discourse.julialang.org/t/why-does-profiling-suggest-that-integer-comparison-dominates-broadcasted-assignment/109606)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 4\
**Last updated:** [February 3, 2024, 2:47am UTC](https://discourse.julialang.org/t/why-does-profiling-suggest-that-integer-comparison-dominates-broadcasted-assignment/109606 "2024-02-03T02:47:53Z")

</div>

julia\> a = rand(40000,4000); b = rand(40000,4000); julia\> Profile.clear() julia\> @bprofile $a\[1:end, 1:end\] .= $b BenchmarkTools.Trial: 9 samples with 1 evaluation. Range (min … max): 571.819 ms … 586.555 ms ┊ GC (m…

---

## [Fast allocation of blocks in sparse matrix](https://discourse.julialang.org/t/fast-allocation-of-blocks-in-sparse-matrix/109561)

<div class="topic-metadata">

**Author:** [@johannesnauta](https://discourse.julialang.org/u/johannesnauta)\
**Replies:** 7\
**Last updated:** [February 2, 2024, 6:34pm UTC](https://discourse.julialang.org/t/fast-allocation-of-blocks-in-sparse-matrix/109561 "2024-02-02T18:34:00Z")

</div>

When trying to generate a “super adjacency matrix”, that is an adjacency matrix where each of its entries is the identity matrix, I noticed a bottleneck when generating the sparse block-matrix. More specifically, I am t…

---

## [Double checking there is no multi-threaded dense x sparse matmul implementation](https://discourse.julialang.org/t/double-checking-there-is-no-multi-threaded-dense-x-sparse-matmul-implementation/106619)

<div class="topic-metadata">

**Author:** [@RomeoV](https://discourse.julialang.org/u/RomeoV)\
**Replies:** 7\
**Last updated:** [February 1, 2024, 9:48pm UTC](https://discourse.julialang.org/t/double-checking-there-is-no-multi-threaded-dense-x-sparse-matmul-implementation/106619 "2024-02-01T21:48:15Z")

</div>

I am in need of having very efficient dense x sparse matmul code, but it seems there is no threaded implementation of this available (only sparse x dense). I therefore wrote my own version, which achieves about 3x speedu…

---

## [LinearAlgebra.inv! not exported, in-place inversion](https://discourse.julialang.org/t/linearalgebra-inv-not-exported-in-place-inversion/109563)

<div class="topic-metadata">

**Author:** [@AdaemmerP](https://discourse.julialang.org/u/AdaemmerP)\
**Replies:** 5\
**Last updated:** [February 1, 2024, 12:00pm UTC](https://discourse.julialang.org/t/linearalgebra-inv-not-exported-in-place-inversion/109563 "2024-02-01T12:00:47Z")

</div>

Why is inv!() not exported from LinearAlgebra? What is the fastest and most efficient way to invert a Matrix? I have to invert (I - A) where I is the identity Matrix. In some cases A may be sparse. Imat = I(10) Imatx =…

---

## [Sparse matrices copy arrays, do not view them](https://discourse.julialang.org/t/sparse-matrices-copy-arrays-do-not-view-them/109505)

<div class="topic-metadata">

**Author:** [@Enlil50](https://discourse.julialang.org/u/Enlil50)\
**Replies:** 18\
**Last updated:** [January 31, 2024, 9:06pm UTC](https://discourse.julialang.org/t/sparse-matrices-copy-arrays-do-not-view-them/109505 "2024-01-31T21:06:01Z")

</div>

I wrote this program, which preallocates the csc arrays. I have to do a lot of kronecker products and i wanted to re-use this arrays and to write in them. Each iteration would have a different @view inside them, but if…

---

## [Bounds check outside loop affects loop performance](https://discourse.julialang.org/t/bounds-check-outside-loop-affects-loop-performance/109524)

<div class="topic-metadata">

**Author:** [@wheeheee](https://discourse.julialang.org/u/wheeheee)\
**Replies:** 0\
**Last updated:** [January 31, 2024, 4:10pm UTC](https://discourse.julialang.org/t/bounds-check-outside-loop-affects-loop-performance/109524 "2024-01-31T16:10:50Z")

</div>

While playing around with a function, I noticed that adding a bounds check (si\_check) had a drastic impact on its performance. Although for N \<= 18, there is no noticeable performance impact, and the emitted LLVM IR show…

---

## [Type Instability using StaticArrays that I dont get](https://discourse.julialang.org/t/type-instability-using-staticarrays-that-i-dont-get/109499)

<div class="topic-metadata">

**Author:** [@Christian\_Dengler](https://discourse.julialang.org/u/Christian_Dengler)\
**Replies:** 4\
**Last updated:** [January 31, 2024, 8:03am UTC](https://discourse.julialang.org/t/type-instability-using-staticarrays-that-i-dont-get/109499 "2024-01-31T08:03:30Z")

</div>

Hello, I have a type instability according to @code\_warntype in the following code. To me it seems all types should be inferable though. What would I need to change to make it type stable? using StaticArrays import Lin…

---

## [Functors instead of arrays, matrices etc](https://discourse.julialang.org/t/functors-instead-of-arrays-matrices-etc/109282)

<div class="topic-metadata">

**Author:** [@Enlil50](https://discourse.julialang.org/u/Enlil50)\
**Replies:** 22\
**Last updated:** [January 30, 2024, 4:24pm UTC](https://discourse.julialang.org/t/functors-instead-of-arrays-matrices-etc/109282 "2024-01-30T16:24:12Z")

</div>

So, there is this C++ eigen feature which I really like: CWiseNullaryOp. To sum it up, you can write a functor, which stores some values and returns some algorithms, and use this as a matrix. This permits you to not st…

---

## [Large amount of memory allocation when using autodiff and IPNewton](https://discourse.julialang.org/t/large-amount-of-memory-allocation-when-using-autodiff-and-ipnewton/109451)

<div class="topic-metadata">

**Author:** [@TimOb](https://discourse.julialang.org/u/TimOb)\
**Replies:** 1\
**Last updated:** [January 30, 2024, 4:02pm UTC](https://discourse.julialang.org/t/large-amount-of-memory-allocation-when-using-autodiff-and-ipnewton/109451 "2024-01-30T16:02:37Z")

</div>

Hi all, I’m new to Julia and have been working on a model which essentially is a long loop over optimisation problems: for state = 1:n x0 = ones(5)/2; fun1(x) = -hh\_utility(x, state)\[1\]; …

---

## [Upper boundary for dispatch in Julia](https://discourse.julialang.org/t/upper-boundary-for-dispatch-in-julia/109405)

<div class="topic-metadata">

**Author:** [@BBReactionHooper](https://discourse.julialang.org/u/BBReactionHooper)\
**Replies:** 15\
**Last updated:** [January 30, 2024, 3:30pm UTC](https://discourse.julialang.org/t/upper-boundary-for-dispatch-in-julia/109405 "2024-01-30T15:30:14Z")

</div>

Hi fellows, I have a function, which can return five different types according to some conditions. Julia seems to have a problem with type-inference. I created a small example with a similar problem. We create a random …

---

## [Unexpected allocation](https://discourse.julialang.org/t/unexpected-allocation/109393)

<div class="topic-metadata">

**Author:** [@abraunst](https://discourse.julialang.org/u/abraunst)\
**Replies:** 7\
**Last updated:** [January 30, 2024, 8:45am UTC](https://discourse.julialang.org/t/unexpected-allocation/109393 "2024-01-30T08:45:33Z")

</div>

I’m trying to write an iteration for my type. The iteration needs to keep a Vector and an Int in its state. I cannot get rid of an allocation. I condensed the problem into the following MWE: function iter((i,v)) v\[…

---

## [Parallelizing over an iterable](https://discourse.julialang.org/t/parallelizing-over-an-iterable/108936)

<div class="topic-metadata">

**Author:** [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Replies:** 18\
**Last updated:** [January 29, 2024, 5:07pm UTC](https://discourse.julialang.org/t/parallelizing-over-an-iterable/108936 "2024-01-29T17:07:44Z")

</div>

Suppose we are working with an iterable with known finite length. I have a function that does something like function makeresult(n::Int) it = makeiterator(n) res = 0.0 for x in it res += f(x) en…

---

## [Cthulhu.jl showing unstable return type](https://discourse.julialang.org/t/cthulhu-jl-showing-unstable-return-type/109385)

<div class="topic-metadata">

**Author:** [@Gokhan\_Kof](https://discourse.julialang.org/u/Gokhan_Kof)\
**Replies:** 5\
**Last updated:** [January 29, 2024, 2:59pm UTC](https://discourse.julialang.org/t/cthulhu-jl-showing-unstable-return-type/109385 "2024-01-29T14:59:00Z")

</div>

Hi, I am trying to eliminate type unstable parts of my code and Cthulhu.jl is showing the return type of a dictionary access as red: x = my\_dict\[first(my\_set)\] x is detected as as Array{Float64} but shown in red. I su…

---

## [Matrix storage](https://discourse.julialang.org/t/matrix-storage/109343)

<div class="topic-metadata">

**Author:** [@Enlil50](https://discourse.julialang.org/u/Enlil50)\
**Replies:** 11\
**Last updated:** [January 27, 2024, 6:59pm UTC](https://discourse.julialang.org/t/matrix-storage/109343 "2024-01-27T18:59:18Z")

</div>

How are matrices stored? Let us make an example: I initialize a 10\*10 int32 matrix. I first fill the 5\*5 left-top block. I then extend the matrix to be a 10\*10, adding the new elements with the correct \[ , \] syntax. …

---

## [Remove bounds checking for the entire program](https://discourse.julialang.org/t/remove-bounds-checking-for-the-entire-program/109339)

<div class="topic-metadata">

**Author:** [@Enlil50](https://discourse.julialang.org/u/Enlil50)\
**Replies:** 8\
**Last updated:** [January 27, 2024, 6:38pm UTC](https://discourse.julialang.org/t/remove-bounds-checking-for-the-entire-program/109339 "2024-01-27T18:38:53Z")

</div>

I don’t need bound checking. Instead of writing @inbounds everywhere, can I test my program without it and then, when it all works, enable a flag which disables all the bound checking and other automatic behaviours typi…

---

## [Removing undesirable allocations in some functions](https://discourse.julialang.org/t/removing-undesirable-allocations-in-some-functions/109337)

<div class="topic-metadata">

**Author:** [@aris](https://discourse.julialang.org/u/aris)\
**Replies:** 15\
**Last updated:** [January 27, 2024, 6:15pm UTC](https://discourse.julialang.org/t/removing-undesirable-allocations-in-some-functions/109337 "2024-01-27T18:15:41Z")

</div>

Greetings everyone, Here I would like to use a specific example from a code of mine, to help me (and hopefully others) better understand how allocations work. I’ve got a code which imports data (xyz coordinates of hydr…

---

## [Compiler doesn't know the type of real.(vec) in compile time](https://discourse.julialang.org/t/compiler-doesnt-know-the-type-of-real-vec-in-compile-time/109336)

<div class="topic-metadata">

**Author:** [@Shayan](https://discourse.julialang.org/u/Shayan)\
**Replies:** 6\
**Last updated:** [January 27, 2024, 2:03pm UTC](https://discourse.julialang.org/t/compiler-doesnt-know-the-type-of-real-vec-in-compile-time/109336 "2024-01-27T14:03:04Z")

</div>

How to make the cc function type stable? function cc( model::Type{\<:CepstralCoeffModel}, tseries::AbstractVector, p::Integer, n::Integer; normalize::Bool=false ) series = tseries normalize && begin ser…

---

## [Parallelization seems to increase the necessary amount of allocations for single threads](https://discourse.julialang.org/t/parallelization-seems-to-increase-the-necessary-amount-of-allocations-for-single-threads/109259)

<div class="topic-metadata">

**Author:** [@jabru](https://discourse.julialang.org/u/jabru)\
**Replies:** 8\
**Last updated:** [January 26, 2024, 3:10pm UTC](https://discourse.julialang.org/t/parallelization-seems-to-increase-the-necessary-amount-of-allocations-for-single-threads/109259 "2024-01-26T15:10:00Z")

</div>

Hi there, so I am currently working on a small piece of code that is meant to demonstrate the usefulness of parallelization. Therefore I wrote a small Euler like differential equation solver that solves the Euler equatio…

---

## [Independent threads much slower by parallelizable](https://discourse.julialang.org/t/independent-threads-much-slower-by-parallelizable/109227)

<div class="topic-metadata">

**Author:** [@jabru](https://discourse.julialang.org/u/jabru)\
**Replies:** 2\
**Last updated:** [January 25, 2024, 10:26am UTC](https://discourse.julialang.org/t/independent-threads-much-slower-by-parallelizable/109227 "2024-01-25T10:26:42Z")

</div>

Hi there. So soon I will give a talk on the Julia programming language in my research group. In that presentation, I wanted to show how well parallelization works in Julia. So I decided to take the following as an exam…

---

## [Individual threads superfast, while sync really slow with virtually no communication](https://discourse.julialang.org/t/individual-threads-superfast-while-sync-really-slow-with-virtually-no-communication/109203)

<div class="topic-metadata">

**Author:** [@jabru](https://discourse.julialang.org/u/jabru)\
**Replies:** 4\
**Last updated:** [January 24, 2024, 5:56pm UTC](https://discourse.julialang.org/t/individual-threads-superfast-while-sync-really-slow-with-virtually-no-communication/109203 "2024-01-24T17:56:24Z")

</div>

Hey there! So I am currently trying to understand how parallelization works in Julia, as a practice I tried writing this nice pi estimator: function estimate\_pi(number) m=0. for i=1:number x=rand() …

---

## [@inbounds does nothing when converting Cartesian to linear Index](https://discourse.julialang.org/t/inbounds-does-nothing-when-converting-cartesian-to-linear-index/109201)

<div class="topic-metadata">

**Author:** [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Replies:** 4\
**Last updated:** [January 24, 2024, 4:01pm UTC](https://discourse.julialang.org/t/inbounds-does-nothing-when-converting-cartesian-to-linear-index/109201 "2024-01-24T16:01:29Z")

</div>

Hi, I do not understand the profiling of the following MWE. using BenchmarkTools using Random function weirdsum(a,lis,ci) li = @inbounds lis\[ci\] ac = @inbounds a\[ci\] al = @inbounds a\[li\] return ac+al e…

---

## [Reducing allocations in quadgk within loop](https://discourse.julialang.org/t/reducing-allocations-in-quadgk-within-loop/109127)

<div class="topic-metadata">

**Author:** [@physh](https://discourse.julialang.org/u/physh)\
**Replies:** 7\
**Last updated:** [January 24, 2024, 2:10am UTC](https://discourse.julialang.org/t/reducing-allocations-in-quadgk-within-loop/109127 "2024-01-24T02:10:33Z")

</div>

Hi all, I try to optimize some code which calls quadgk many times on a matrix. A MWE is using SpecialFunctions using QuadGK Lsum = 2 v\_arr = zeros(100,Lsum+1); alpha\_arr = rand(100); gamma\_dict = Dict{Float64,Float64}…

---

## [Julia package incompatibility](https://discourse.julialang.org/t/julia-package-incompatibility/108597)

<div class="topic-metadata">

**Author:** [@Mahnoor\_Pop](https://discourse.julialang.org/u/Mahnoor_Pop)\
**Replies:** 7\
**Last updated:** [January 23, 2024, 9:06pm UTC](https://discourse.julialang.org/t/julia-package-incompatibility/108597 "2024-01-23T21:06:03Z")

</div>

Hi all! Ever since working with GLMakie, GraphMakie etc, I’ve been having a LOT of issues with my packages in Julia, it takes really really long for them to precompile at the start \[1\] (which is not how it’s been up unti…

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

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