# Performance

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

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

**Page:** 38

---

## [Gram Schmidit python to julia](https://discourse.julialang.org/t/gram-schmidit-python-to-julia/103472)

<div class="topic-metadata">

**Author:** [@jcbritobr](https://discourse.julialang.org/u/jcbritobr)\
**Replies:** 10\
**Last updated:** [September 3, 2023, 1:46am UTC](https://discourse.julialang.org/t/gram-schmidit-python-to-julia/103472 "2023-09-03T01:46:58Z")

</div>

Hello, good evening, I’m having troubles to port an algorithm(Gram Schmidit for qr decompoosition) from python to julia. My results are going to infinity in Orthogonal Q matrix. May someone help? # create the matrix …

---

## [Allocations when indexing (Abstract)Arrays with large dimension](https://discourse.julialang.org/t/allocations-when-indexing-abstract-arrays-with-large-dimension/103383)

<div class="topic-metadata">

**Author:** [@spionkaese](https://discourse.julialang.org/u/spionkaese)\
**Replies:** 6\
**Last updated:** [August 31, 2023, 9:49pm UTC](https://discourse.julialang.org/t/allocations-when-indexing-abstract-arrays-with-large-dimension/103383 "2023-08-31T21:49:30Z")

</div>

I’ve been working with tensors based on AbstractArrays (see https://gist.github.com/AlexanderNenninger/461f37315e45071a8c91b18d73901431 ) that map Base.getindex(A, i...) to a function call A.f(i). While the individual i…

---

## [Non-allocating leaf iterator over simple tree](https://discourse.julialang.org/t/non-allocating-leaf-iterator-over-simple-tree/103425)

<div class="topic-metadata">

**Author:** [@jules](https://discourse.julialang.org/u/jules)\
**Replies:** 0\
**Last updated:** [August 31, 2023, 8:30pm UTC](https://discourse.julialang.org/t/non-allocating-leaf-iterator-over-simple-tree/103425 "2023-08-31T20:30:59Z")

</div>

I have a tree made from a node type like this struct Node children::Vector{Node} end For the life of me, I cannot figure out how to write a non-allocating iterator over the leaves of that tree. I tried with genera…

---

## [Memory allocation when solving ODE with Vern7 and ContinuousCallback](https://discourse.julialang.org/t/memory-allocation-when-solving-ode-with-vern7-and-continuouscallback/101087)

<div class="topic-metadata">

**Author:** [@albertomercurio](https://discourse.julialang.org/u/albertomercurio)\
**Replies:** 2\
**Last updated:** [August 29, 2023, 5:27am UTC](https://discourse.julialang.org/t/memory-allocation-when-solving-ode-with-vern7-and-continuouscallback/101087 "2023-08-29T05:27:39Z")

</div>

Hello, I went through a memory allocation problem in a ODE system, when using Vern7() algorithm and ContinuousCallback. The minimal working example is the following: using LinearAlgebra using SparseArrays using Ordinar…

---

## [Difference between two dates in Julia](https://discourse.julialang.org/t/difference-between-two-dates-in-julia/103048)

<div class="topic-metadata">

**Author:** [@Sandy45](https://discourse.julialang.org/u/Sandy45)\
**Replies:** 8\
**Last updated:** [August 28, 2023, 11:12pm UTC](https://discourse.julialang.org/t/difference-between-two-dates-in-julia/103048 "2023-08-28T23:12:47Z")

</div>

I am trying to get difference between two dates in number of “days”. I am able to substract the two date fields but results is being produced as “n days”. As we can see below DATE\_DIFF is produced after executing below…

---

## [Passing a struct to a function allocates whereas passing an array does not](https://discourse.julialang.org/t/passing-a-struct-to-a-function-allocates-whereas-passing-an-array-does-not/103303)

<div class="topic-metadata">

**Author:** [@simon79](https://discourse.julialang.org/u/simon79)\
**Replies:** 2\
**Last updated:** [August 28, 2023, 6:08pm UTC](https://discourse.julialang.org/t/passing-a-struct-to-a-function-allocates-whereas-passing-an-array-does-not/103303 "2023-08-28T18:08:01Z")

</div>

Hi, I noticed that the simple code example\_1! below allocates memory (lots of it when this is embedded in a large loop) whereas example\_2! does not. example\_1! takes the 3-dimenional array conn\[iel, :, :\] and, with…

---

## [Why is converting from a type to a symbol so slow?](https://discourse.julialang.org/t/why-is-converting-from-a-type-to-a-symbol-so-slow/103212)

<div class="topic-metadata">

**Author:** [@Tortar](https://discourse.julialang.org/u/Tortar)\
**Replies:** 7\
**Last updated:** [August 26, 2023, 9:18pm UTC](https://discourse.julialang.org/t/why-is-converting-from-a-type-to-a-symbol-so-slow/103212 "2023-08-26T21:18:23Z")

</div>

I was experimenting with the sort function where I gave to the by keyword a type related to each element of the array, but types can’t be compared with each others. So I tried to convert the type to a symbol, but it was …

---

## [Multithreaded LIBSVM and XGBoost crashing](https://discourse.julialang.org/t/multithreaded-libsvm-and-xgboost-crashing/103179)

<div class="topic-metadata">

**Author:** [@dbass](https://discourse.julialang.org/u/dbass)\
**Replies:** 7\
**Last updated:** [August 25, 2023, 5:02pm UTC](https://discourse.julialang.org/t/multithreaded-libsvm-and-xgboost-crashing/103179 "2023-08-25T17:02:34Z")

</div>

Hello, I would like to perform crossvalidation and grid search using SVM (and XGBoost), using a parameter grid defined for each method. In MATLAB, within each split, I can run parfor, and each thread will train some mo…

---

## [Reduce type inference when using nested ForwardDiff](https://discourse.julialang.org/t/reduce-type-inference-when-using-nested-forwarddiff/103181)

<div class="topic-metadata">

**Author:** [@Vik1](https://discourse.julialang.org/u/Vik1)\
**Replies:** 0\
**Last updated:** [August 25, 2023, 9:03am UTC](https://discourse.julialang.org/t/reduce-type-inference-when-using-nested-forwarddiff/103181 "2023-08-25T09:03:51Z")

</div>

Hi Julia wizards, I am calculating derivatives wrt. different arguments of a function. Unfortunately, the compilation time in my actual use case is very high due to type inference. I had a quick fix, that reduced it, bu…

---

## [Trying to make multithreading to work on applying a function number of times](https://discourse.julialang.org/t/trying-to-make-multithreading-to-work-on-applying-a-function-number-of-times/103124)

<div class="topic-metadata">

**Author:** [@ahmed](https://discourse.julialang.org/u/ahmed)\
**Replies:** 11\
**Last updated:** [August 25, 2023, 7:51am UTC](https://discourse.julialang.org/t/trying-to-make-multithreading-to-work-on-applying-a-function-number-of-times/103124 "2023-08-25T07:51:37Z")

</div>

I have a function F that does some computations on its input arrays. First I’m trying to see if I can make this function as fast as possible as this function will be computed 50 times in one of possibly many iterations s…

---

## [Invalidation from extending \`Base.reduce\_first\`](https://discourse.julialang.org/t/invalidation-from-extending-base-reduce-first/103146)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 1\
**Last updated:** [August 24, 2023, 9:09am UTC](https://discourse.julialang.org/t/invalidation-from-extending-base-reduce-first/103146 "2023-08-24T09:09:37Z")

</div>

FillArrays has recently introduced a specialization Base.reduce\_first(::typeof(+), x::Ones) = Fill(Base.reduce\_first(+, getindex\_value(x)), axes(x)) On v1.10.0-beta2, this seems to introduce invalidations (although not…

---

## [Status of BFloat16](https://discourse.julialang.org/t/status-of-bfloat16/103109)

<div class="topic-metadata">

**Author:** [@Tomas\_Pevny](https://discourse.julialang.org/u/Tomas_Pevny)\
**Replies:** 4\
**Last updated:** [August 24, 2023, 6:57am UTC](https://discourse.julialang.org/t/status-of-bfloat16/103109 "2023-08-24T06:57:06Z")

</div>

Hello, I have tried Llama2 large language model in Julia following https://github.com/chengchingwen/Transformers.jl/blob/master/example/Llama2\_example.ipynb. This works really nice and smoothly, but, the example uses Fl…

---

## [Multiple-threading does not increase speed in my 16-threads workstation, I am wondering is there something wrong in my code?](https://discourse.julialang.org/t/multiple-threading-does-not-increase-speed-in-my-16-threads-workstation-i-am-wondering-is-there-something-wrong-in-my-code/103076)

<div class="topic-metadata">

**Author:** [@Kim](https://discourse.julialang.org/u/Kim)\
**Replies:** 3\
**Last updated:** [August 22, 2023, 4:02pm UTC](https://discourse.julialang.org/t/multiple-threading-does-not-increase-speed-in-my-16-threads-workstation-i-am-wondering-is-there-something-wrong-in-my-code/103076 "2023-08-22T16:02:25Z")

</div>

Hi, I am recently trying to leverage multiple threading to speed my code. However, even though I likely realized multiple threading, my code run slower. Could somebody proficient in this have a skim on this? My code is p…

---

## [Atomic much slower than @spawn-ed tasks](https://discourse.julialang.org/t/atomic-much-slower-than-spawn-ed-tasks/103055)

<div class="topic-metadata">

**Author:** [@AdaemmerP](https://discourse.julialang.org/u/AdaemmerP)\
**Replies:** 4\
**Last updated:** [August 22, 2023, 1:09pm UTC](https://discourse.julialang.org/t/atomic-much-slower-than-spawn-ed-tasks/103055 "2023-08-22T13:09:04Z")

</div>

The Julia manual offers two solutions to avoid a race condition when using @threads, namely @spawn-ed tasks and atomic operations. The manual states that the atomic approach “may be more performant depending on the chara…

---

## [Getting started with PrecompileTools (Julia 1.9.2) - how to save precompiled code to disk?](https://discourse.julialang.org/t/getting-started-with-precompiletools-julia-1-9-2-how-to-save-precompiled-code-to-disk/103040)

<div class="topic-metadata">

**Author:** [@pluie](https://discourse.julialang.org/u/pluie)\
**Replies:** 3\
**Last updated:** [August 21, 2023, 9:39pm UTC](https://discourse.julialang.org/t/getting-started-with-precompiletools-julia-1-9-2-how-to-save-precompiled-code-to-disk/103040 "2023-08-21T21:39:38Z")

</div>

The documentation for PrecompileTools states “particularly with Julia 1.9 and higher, the precompiled code can be saved to disk, so that it doesn’t need to be compiled freshly in each Julia session.” It is unclear to me …

---

## [Prevent array re-allocation inside a loop (I am not allowed to allocate before the loop)](https://discourse.julialang.org/t/prevent-array-re-allocation-inside-a-loop-i-am-not-allowed-to-allocate-before-the-loop/103042)

<div class="topic-metadata">

**Author:** [@simon79](https://discourse.julialang.org/u/simon79)\
**Replies:** 10\
**Last updated:** [August 21, 2023, 7:11pm UTC](https://discourse.julialang.org/t/prevent-array-re-allocation-inside-a-loop-i-am-not-allowed-to-allocate-before-the-loop/103042 "2023-08-21T19:11:36Z")

</div>

Hi, I am executing a code similar to the simple one below under the constraint that I cannot allocate anything before the loop due to some constraints of the calling function. for it=1:ntime my\_fun() end where m…

---

## [Help for improving the performance of my algorithm](https://discourse.julialang.org/t/help-for-improving-the-performance-of-my-algorithm/102907)

<div class="topic-metadata">

**Author:** [@mike\_k](https://discourse.julialang.org/u/mike_k)\
**Replies:** 6\
**Last updated:** [August 21, 2023, 12:52pm UTC](https://discourse.julialang.org/t/help-for-improving-the-performance-of-my-algorithm/102907 "2023-08-21T12:52:06Z")

</div>

I aim to develop a package for solving the standard quadratic optimization problem which maximizes (minimizes) a quadratic form over the unit simplex. That is \\max x^T Q x : \\sum\_{i \\in \[1:n\]} x\_i = 1, x\\in \\mathbb{R}\_+^…

---

## [Common allocation mistakes](https://discourse.julialang.org/t/common-allocation-mistakes/66127)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 47\
**Last updated:** [August 21, 2023, 5:42am UTC](https://discourse.julialang.org/t/common-allocation-mistakes/66127 "2023-08-21T05:42:20Z")

</div>

@amrods, splitting here the question you posted. 1. Create a mutable array inside a loop, explicitly: julia\> function f(x) z = 0. for i in 1:10 y = \[ i+1, i+2 \] z += x\[1\]\*y\[1\] + x…

---

## [Solving this without a loop (learning purposes)](https://discourse.julialang.org/t/solving-this-without-a-loop-learning-purposes/103013)

<div class="topic-metadata">

**Author:** [@CodeGodz](https://discourse.julialang.org/u/CodeGodz)\
**Replies:** 14\
**Last updated:** [August 21, 2023, 12:46am UTC](https://discourse.julialang.org/t/solving-this-without-a-loop-learning-purposes/103013 "2023-08-21T00:46:23Z")

</div>

I’m trying to get more familiar with using Transducers.jl or related functions that avoid loops - just to learn. Let’s say I have this simple vector x = Bool\[1,1,0,0,1,1,0,1\] and I want to find the indices of adjacent …

---

## [Does redefinition of const variables always create unpredictable behavior?](https://discourse.julialang.org/t/does-redefinition-of-const-variables-always-create-unpredictable-behavior/103001)

<div class="topic-metadata">

**Author:** [@Soldalma](https://discourse.julialang.org/u/Soldalma)\
**Replies:** 6\
**Last updated:** [August 20, 2023, 4:28pm UTC](https://discourse.julialang.org/t/does-redefinition-of-const-variables-always-create-unpredictable-behavior/103001 "2023-08-20T16:28:42Z")

</div>

I have a program that runs fine. I want it to run faster. So I redefined some of its top-level variables to be const, like this const myvar = 1 Now when I run the program I get the following message: WARNING: redefini…

---

## [How does type annotation affect the performance?](https://discourse.julialang.org/t/how-does-type-annotation-affect-the-performance/102986)

<div class="topic-metadata">

**Author:** [@Reza-Reza](https://discourse.julialang.org/u/Reza-Reza)\
**Replies:** 5\
**Last updated:** [August 19, 2023, 10:21pm UTC](https://discourse.julialang.org/t/how-does-type-annotation-affect-the-performance/102986 "2023-08-19T22:21:54Z")

</div>

I read that in Julia it’s better to allow more generic type annotation and that type annotation be it done or not does not have an impact on the performance. I think I might have misunderstood what I read. So I did a mic…

---

## [Is multithreaded FFTW on multiple arrays causing too much overhead?](https://discourse.julialang.org/t/is-multithreaded-fftw-on-multiple-arrays-causing-too-much-overhead/102832)

<div class="topic-metadata">

**Author:** [@erny123](https://discourse.julialang.org/u/erny123)\
**Replies:** 15\
**Last updated:** [August 19, 2023, 6:04pm UTC](https://discourse.julialang.org/t/is-multithreaded-fftw-on-multiple-arrays-causing-too-much-overhead/102832 "2023-08-19T18:04:19Z")

</div>

I have a couple of matrices that I have FFT to computer a nonlinear function and then IFFT. My question: Is using a multithreaded FFT plan creating too much overhead because of each instance the FFTW is called? Is there…

---

## [Speed up solution of large system of equations](https://discourse.julialang.org/t/speed-up-solution-of-large-system-of-equations/102659)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 18\
**Last updated:** [August 19, 2023, 3:19pm UTC](https://discourse.julialang.org/t/speed-up-solution-of-large-system-of-equations/102659 "2023-08-19T15:19:48Z")

</div>

I have a system of equations: \\begin{aligned} & S^m\_{a\_m, e\_m}-\\mu^{0m}\_{a\_m, e\_m}=\\sum\_{a\_m=1}^{46} {\\Pi}\_{a\_m, e\_m, a\_f, e\_f}\\sqrt{S^m\_{a\_m, e\_m} S^f\_{a\_f, e\_f}} \\prod\_{k=0}^{T(a\_m, a\_f)-1}\\left(\\frac{\\mu^{0m}\_{a\_m+k…

---

## [Releasing process memory from Arrow.jl](https://discourse.julialang.org/t/releasing-process-memory-from-arrow-jl/102882)

<div class="topic-metadata">

**Author:** [@djholiver](https://discourse.julialang.org/u/djholiver)\
**Replies:** 5\
**Last updated:** [August 17, 2023, 7:23pm UTC](https://discourse.julialang.org/t/releasing-process-memory-from-arrow-jl/102882 "2023-08-17T19:23:40Z")

</div>

Hi, I make heavy use of the (incredible) Arrow.jl package provided by @quinnj to do api - exposed analytics running in docker containers. The files are large: c. 65GB, 35M rows, 250 columns and the analytics queries exe…

---

## [Does Julia do common subexpression elimination?](https://discourse.julialang.org/t/does-julia-do-common-subexpression-elimination/102901)

<div class="topic-metadata">

**Author:** [@deaminase](https://discourse.julialang.org/u/deaminase)\
**Replies:** 5\
**Last updated:** [August 17, 2023, 5:27pm UTC](https://discourse.julialang.org/t/does-julia-do-common-subexpression-elimination/102901 "2023-08-17T17:27:21Z")

</div>

This recent GitHub reads like Julia doesn’t do common subexpression elimination at all, is this a correct assumption? Here’s the relevant bits from the issue: using BenchmarkTools f(x) = exp(x)/(1+exp(x)) function g(x…

---

## [Curious about the internals of dynamic dispatch](https://discourse.julialang.org/t/curious-about-the-internals-of-dynamic-dispatch/102888)

<div class="topic-metadata">

**Author:** [@HashBrown](https://discourse.julialang.org/u/HashBrown)\
**Replies:** 12\
**Last updated:** [August 17, 2023, 3:34am UTC](https://discourse.julialang.org/t/curious-about-the-internals-of-dynamic-dispatch/102888 "2023-08-17T03:34:14Z")

</div>

My mental model of how Julia handles dynamic dispatch is by compiling code that looks like: for ele in vector\_of\_abstract\_type do\_something(ele) end to something that looks like this for ele in vector\_of\_abstract\_…

---

## [Is there a way to speed up this code?](https://discourse.julialang.org/t/is-there-a-way-to-speed-up-this-code/102878)

<div class="topic-metadata">

**Author:** [@Luis\_Manuel\_Espinoza](https://discourse.julialang.org/u/Luis_Manuel_Espinoza)\
**Replies:** 4\
**Last updated:** [August 16, 2023, 10:09pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-speed-up-this-code/102878 "2023-08-16T22:09:02Z")

</div>

function open\_xyz\_file(path::AbstractString) file = open(path) num\_atoms = parse(Int, readline(file)) comment = readline(file) symbols = Vector{String}(undef, num\_atoms) coords = zeros(num\_atoms,3) for i in 1:num\_a…

---

## [Saving FFTW plans for future use](https://discourse.julialang.org/t/saving-fftw-plans-for-future-use/102871)

<div class="topic-metadata">

**Author:** [@erny123](https://discourse.julialang.org/u/erny123)\
**Replies:** 2\
**Last updated:** [August 16, 2023, 5:47pm UTC](https://discourse.julialang.org/t/saving-fftw-plans-for-future-use/102871 "2023-08-16T17:47:31Z")

</div>

Is there anyway to save and load FFTW plans? For example: using FFTW sz = 2^13 ar = rand(ComplexF64,(sz,sz)); pthread =FFTW.plan\_fft!(ar,flags=FFTW.MEASURE); inv(pthread); pthreadpatient =FFTW.plan\_fft!(ar,flags=FFTW.…

---

## [Performance / Memory differences between constructors of BigInts](https://discourse.julialang.org/t/performance-memory-differences-between-constructors-of-bigints/102863)

<div class="topic-metadata">

**Author:** [@maxasauruswall](https://discourse.julialang.org/u/maxasauruswall)\
**Replies:** 5\
**Last updated:** [August 16, 2023, 4:07pm UTC](https://discourse.julialang.org/t/performance-memory-differences-between-constructors-of-bigints/102863 "2023-08-16T16:07:11Z")

</div>

Hi all, I’m playing around with arbitrary precision integers in a jupyter notebook (Macbook air, Julia v1.10.0-beta1). I noticed a difference between two constructors of BigInts: @btime BigInt(1234567890) # 45.294 ns…

---

## [How to define a function with argument dependent return](https://discourse.julialang.org/t/how-to-define-a-function-with-argument-dependent-return/102841)

<div class="topic-metadata">

**Author:** [@zxm403089989](https://discourse.julialang.org/u/zxm403089989)\
**Replies:** 7\
**Last updated:** [August 16, 2023, 3:47pm UTC](https://discourse.julialang.org/t/how-to-define-a-function-with-argument-dependent-return/102841 "2023-08-16T15:47:02Z")

</div>

I need to set a function with N dimensional array return. And the parameter N is dependent on the argument. However, Julia cannot recognize this before compile. Here is my approach: function DeltaTensor(total\_dimension:…

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

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