# Performance

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

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

**Page:** 47

---

## [Spurious memory allocations within function](https://discourse.julialang.org/t/spurious-memory-allocations-within-function/85430)

<div class="topic-metadata">

**Author:** [@dwyron](https://discourse.julialang.org/u/dwyron)\
**Replies:** 9\
**Last updated:** [March 22, 2023, 5:25pm UTC](https://discourse.julialang.org/t/spurious-memory-allocations-within-function/85430 "2023-03-22T17:25:44Z")

</div>

Hi everyone, I am trying to reduce memory allocations in a function through preallocations. However, implementing the Perfomance Tips still leaves a significant amount of probably unnecessary allocations, which I can ci…

---

## [Performance help for first passage time simulation](https://discourse.julialang.org/t/performance-help-for-first-passage-time-simulation/96392)

<div class="topic-metadata">

**Author:** [@Bill\_Holmes](https://discourse.julialang.org/u/Bill_Holmes)\
**Replies:** 24\
**Last updated:** [March 22, 2023, 12:58am UTC](https://discourse.julialang.org/t/performance-help-for-first-passage-time-simulation/96392 "2023-03-22T00:58:40Z")

</div>

I’m relatively new to Julia but it seems fantastic! I am still learning optimization tricks and am hoping someone can help. More details below, but my basic problem is that I have a simd type of problem; run 10k relativ…

---

## [Fast permutation vector: code needed](https://discourse.julialang.org/t/fast-permutation-vector-code-needed/96357)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 38\
**Last updated:** [March 21, 2023, 5:58pm UTC](https://discourse.julialang.org/t/fast-permutation-vector-code-needed/96357 "2023-03-21T17:58:57Z")

</div>

Hello all, I need to sort integer vectors, with entries of arbitrary size relative to the length of the vector. At the moment I use sort!(prm, Base.Sort.DEFAULT\_UNSTABLE, Base.Order.Perm(Base.Order.Forward, rows)) to…

---

## [Profiling memory allocations](https://discourse.julialang.org/t/profiling-memory-allocations/96385)

<div class="topic-metadata">

**Author:** [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Replies:** 1\
**Last updated:** [March 21, 2023, 1:12pm UTC](https://discourse.julialang.org/t/profiling-memory-allocations/96385 "2023-03-21T13:12:10Z")

</div>

I have written some code in functional/immutable style, with the aim of not allocating any memory (on the heap). The code is weird because this is a mock-up of something I then want to create a macro to generate from si…

---

## [Performance scaling of broadcasting compared to looping](https://discourse.julialang.org/t/performance-scaling-of-broadcasting-compared-to-looping/92000)

<div class="topic-metadata">

**Author:** [@f.ij](https://discourse.julialang.org/u/f.ij)\
**Replies:** 19\
**Last updated:** [March 21, 2023, 11:24am UTC](https://discourse.julialang.org/t/performance-scaling-of-broadcasting-compared-to-looping/92000 "2023-03-21T11:24:56Z")

</div>

I’m writing a simulation where speed is very important. The program consists of a main loop where I need to collect some scalar by multiplying some floats based on connections in an adjacency matrix. As a very simplified…

---

## [Orders of magnitude runtime difference in row-wise norm](https://discourse.julialang.org/t/orders-of-magnitude-runtime-difference-in-row-wise-norm/96363)

<div class="topic-metadata">

**Author:** [@Benq](https://discourse.julialang.org/u/Benq)\
**Replies:** 5\
**Last updated:** [March 21, 2023, 12:39am UTC](https://discourse.julialang.org/t/orders-of-magnitude-runtime-difference-in-row-wise-norm/96363 "2023-03-21T00:39:51Z")

</div>

I’m trying to divide every row of a matrix by its norm using the approach suggested by this comment. However, I’m finding that two functionally equivalent implementations are resulting in more than 100x difference in run…

---

## [What next after SnoopCompile?](https://discourse.julialang.org/t/what-next-after-snoopcompile/96320)

<div class="topic-metadata">

**Author:** [@Jack\_Coughlin](https://discourse.julialang.org/u/Jack_Coughlin)\
**Replies:** 7\
**Last updated:** [March 20, 2023, 6:24pm UTC](https://discourse.julialang.org/t/what-next-after-snoopcompile/96320 "2023-03-20T18:24:15Z")

</div>

I’m working on reducing TTFX for my project using SnoopCompile.jl. I have eliminated all relevant invalidations according to precompile\_blockers @snoopi\_deep reports the following for my workload: julia\> tinf Inferenc…

---

## [Threads question](https://discourse.julialang.org/t/threads-question/96326)

<div class="topic-metadata">

**Author:** [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Replies:** 4\
**Last updated:** [March 20, 2023, 9:19am UTC](https://discourse.julialang.org/t/threads-question/96326 "2023-03-20T09:19:23Z")

</div>

Running Julia on 1 thread on a 4 Core Windows 10 PC, the line rand(10\_000,10\_000)^2 Uses 100% of the CPUs. From this, I assume that unless you are very advanced, there’s no benefit to writing multi-threaded code as…

---

## [Need for speed: looping over subdataframes to construct lags](https://discourse.julialang.org/t/need-for-speed-looping-over-subdataframes-to-construct-lags/96258)

<div class="topic-metadata">

**Author:** [@moshi](https://discourse.julialang.org/u/moshi)\
**Replies:** 6\
**Last updated:** [March 18, 2023, 11:25am UTC](https://discourse.julialang.org/t/need-for-speed-looping-over-subdataframes-to-construct-lags/96258 "2023-03-18T11:25:51Z")

</div>

I have a very large DataFrame with columns j, t, b, b\_t. I am creating a new column s by df.s = df.b and then I am making changes to the values in s depending on certain conditions of whether b\_t and t differ, for each…

---

## [Strange memory allocations with structs containing functions](https://discourse.julialang.org/t/strange-memory-allocations-with-structs-containing-functions/96007)

<div class="topic-metadata">

**Author:** [@ocp](https://discourse.julialang.org/u/ocp)\
**Replies:** 6\
**Last updated:** [March 17, 2023, 12:23pm UTC](https://discourse.julialang.org/t/strange-memory-allocations-with-structs-containing-functions/96007 "2023-03-17T12:23:26Z")

</div>

I’m working on a piece of code that takes a struct containing a Function and then calls that function. However, I’m fighting allocation issues. Ideally, I would think that the ability to specify the function signature,…

---

## [How to speed up the numerical integration with interpolation](https://discourse.julialang.org/t/how-to-speed-up-the-numerical-integration-with-interpolation/96223)

<div class="topic-metadata">

**Author:** [@J\_I](https://discourse.julialang.org/u/J_I)\
**Replies:** 7\
**Last updated:** [March 17, 2023, 7:40am UTC](https://discourse.julialang.org/t/how-to-speed-up-the-numerical-integration-with-interpolation/96223 "2023-03-17T07:40:41Z")

</div>

Hi, I have performance problem regarding numerical integration and interpolation. I want to perform numerical integration with interpolation like below. using Dierckx using QuadGK function test() x = 0:0.01:1000 …

---

## [Preallocating Interpolation object](https://discourse.julialang.org/t/preallocating-interpolation-object/96207)

<div class="topic-metadata">

**Author:** [@tradler](https://discourse.julialang.org/u/tradler)\
**Replies:** 3\
**Last updated:** [March 16, 2023, 9:40pm UTC](https://discourse.julialang.org/t/preallocating-interpolation-object/96207 "2023-03-16T21:40:02Z")

</div>

I am solving a dynamic programing value function using backward induction, and would like to be able to update an Interpolations.jl object (or something similar) which holds an approximation of the value function in each…

---

## [Solving for only half the solution in NonlinearSolve.jl](https://discourse.julialang.org/t/solving-for-only-half-the-solution-in-nonlinearsolve-jl/96163)

<div class="topic-metadata">

**Author:** [@KZ-Spectra](https://discourse.julialang.org/u/KZ-Spectra)\
**Replies:** 1\
**Last updated:** [March 16, 2023, 4:50am UTC](https://discourse.julialang.org/t/solving-for-only-half-the-solution-in-nonlinearsolve-jl/96163 "2023-03-16T04:50:19Z")

</div>

using NonlinearSolve, LinearAlgebra, Plots # Parameters: p = \[h, \\omega\] N=15 g(u,p) = p\[1\]\*Tridiagonal(fill(1,N), fill(-2,N+1), fill(1,N))\*u - u.^3 - p\[2\]\*u probg = NonlinearProblem{false}(g, \[0.3; fill(0.3, N-1); 0…

---

## [Allocation when applying in place multiplication to matrix of SVector](https://discourse.julialang.org/t/allocation-when-applying-in-place-multiplication-to-matrix-of-svector/96074)

<div class="topic-metadata">

**Author:** [@yiminlin](https://discourse.julialang.org/u/yiminlin)\
**Replies:** 2\
**Last updated:** [March 15, 2023, 2:51pm UTC](https://discourse.julialang.org/t/allocation-when-applying-in-place-multiplication-to-matrix-of-svector/96074 "2023-03-15T14:51:56Z")

</div>

I am trying to apply in-place matrix multiplication to a matrix of SVector. However, there are 3 allocations if I apply mul! directly. If I apply the multiplication over each column, the allocations disappear. Here is th…

---

## [LLVM code changes if code is wrapped in function](https://discourse.julialang.org/t/llvm-code-changes-if-code-is-wrapped-in-function/96107)

<div class="topic-metadata">

**Author:** [@amansawhney](https://discourse.julialang.org/u/amansawhney)\
**Replies:** 2\
**Last updated:** [March 15, 2023, 1:35pm UTC](https://discourse.julialang.org/t/llvm-code-changes-if-code-is-wrapped-in-function/96107 "2023-03-15T13:35:55Z")

</div>

Hi! I am looking to use SIMD to speed up some operations on strings. I noticed that when I wrap my code in a function it seems that julia doesn’t use the vector instructions. I am using SIMD.jl for my simd functions. He…

---

## [Memory allocation issue of a Euler solver implementation](https://discourse.julialang.org/t/memory-allocation-issue-of-a-euler-solver-implementation/96086)

<div class="topic-metadata">

**Author:** [@stevengogogo](https://discourse.julialang.org/u/stevengogogo)\
**Replies:** 2\
**Last updated:** [March 14, 2023, 8:47pm UTC](https://discourse.julialang.org/t/memory-allocation-issue-of-a-euler-solver-implementation/96086 "2023-03-14T20:47:31Z")

</div>

Hello all, I am implementing ODE solvers for a class assignment. Unfortunately, there is a memory allocation problem with my script, and the performance is not optimal. Problem Description The implementation uses the f…

---

## [Perf help: Random Walks for BoundaryValueProblems](https://discourse.julialang.org/t/perf-help-random-walks-for-boundaryvalueproblems/96082)

<div class="topic-metadata">

**Author:** [@miguelraz](https://discourse.julialang.org/u/miguelraz)\
**Replies:** 2\
**Last updated:** [March 14, 2023, 8:27pm UTC](https://discourse.julialang.org/t/perf-help-random-walks-for-boundaryvalueproblems/96082 "2023-03-14T20:27:47Z")

</div>

Hey all :wave: I started working on some code for a class project and I’m proud to say I took it down from my professor’s 300s to sub 6s :smiley: . I am now trying to do the fastest serial version of it before making it…

---

## [Save data into mysql database in batch mode on transaction basis](https://discourse.julialang.org/t/save-data-into-mysql-database-in-batch-mode-on-transaction-basis/95838)

<div class="topic-metadata">

**Author:** [@Sandy45](https://discourse.julialang.org/u/Sandy45)\
**Replies:** 2\
**Last updated:** [March 13, 2023, 4:43am UTC](https://discourse.julialang.org/t/save-data-into-mysql-database-in-batch-mode-on-transaction-basis/95838 "2023-03-13T04:43:13Z")

</div>

I am trying to load data(from df) into mysql database in batch mode, Loading should be on single transaction and data should be rolled back if load fails at any stage during batch processing. I’ve coded currently by usin…

---

## [Lazy broadcasting speed issues](https://discourse.julialang.org/t/lazy-broadcasting-speed-issues/94218)

<div class="topic-metadata">

**Author:** [@RainerHeintzmann](https://discourse.julialang.org/u/RainerHeintzmann)\
**Replies:** 13\
**Last updated:** [March 12, 2023, 4:52pm UTC](https://discourse.julialang.org/t/lazy-broadcasting-speed-issues/94218 "2023-03-12T16:52:22Z")

</div>

I am working on a new package called SeparableFunctions.jl with the aim to boost the performance for functions which are expensive to calculate on multidimensional grids, but can profit a lot from broadcasting. To this…

---

## [Are "Closures should be avoided whenever possible" still valid in Julia v1.9+?](https://discourse.julialang.org/t/are-closures-should-be-avoided-whenever-possible-still-valid-in-julia-v1-9/95893)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 5\
**Last updated:** [March 12, 2023, 12:32am UTC](https://discourse.julialang.org/t/are-closures-should-be-avoided-whenever-possible-still-valid-in-julia-v1-9/95893 "2023-03-12T00:32:39Z")

</div>

I have posted the same question on Are the examples in "Closures should be avoided whenever possible" still valid in Julia v1.9+? · Issue #34 · SciML/SciMLStyle · GitHub. I just tested the examples in the section “Closu…

---

## [Performance of a transpose compared to c and cache friendliness](https://discourse.julialang.org/t/performance-of-a-transpose-compared-to-c-and-cache-friendliness/95883)

<div class="topic-metadata">

**Author:** [@sneakyturtle](https://discourse.julialang.org/u/sneakyturtle)\
**Replies:** 6\
**Last updated:** [March 11, 2023, 3:33pm UTC](https://discourse.julialang.org/t/performance-of-a-transpose-compared-to-c-and-cache-friendliness/95883 "2023-03-11T15:33:01Z")

</div>

In a quest to learn good HPC principles, I am trying to understand how to implement cache friendly loops in Julia. I found this code loop\_blocking that compares performance of loop blocking techniques between c and Rust…

---

## [FFTW plan gets clobbered when module is compiled](https://discourse.julialang.org/t/fftw-plan-gets-clobbered-when-module-is-compiled/95896)

<div class="topic-metadata">

**Author:** [@Jake](https://discourse.julialang.org/u/Jake)\
**Replies:** 1\
**Last updated:** [March 11, 2023, 1:53am UTC](https://discourse.julialang.org/t/fftw-plan-gets-clobbered-when-module-is-compiled/95896 "2023-03-11T01:53:22Z")

</div>

I have a function that calls fft() repeatedly. For performance I implemented an FFT plan. In some situations the length of data will remain the same, in other cases the the length changes. For this reason the plan is …

---

## [Sieving for Bsmooth values](https://discourse.julialang.org/t/sieving-for-bsmooth-values/95404)

<div class="topic-metadata">

**Author:** [@x13420x](https://discourse.julialang.org/u/x13420x)\
**Replies:** 15\
**Last updated:** [March 9, 2023, 9:26pm UTC](https://discourse.julialang.org/t/sieving-for-bsmooth-values/95404 "2023-03-09T21:26:25Z")

</div>

I am playing around with a quadratic sieve for factorization of large numbers. Most of the work of this algorithm is searching for Bsmooth numbers. If you know the sieve of eratosthenes you can use this process to siev…

---

## [Code compiles each time it triggered](https://discourse.julialang.org/t/code-compiles-each-time-it-triggered/95839)

<div class="topic-metadata">

**Author:** [@Sandy45](https://discourse.julialang.org/u/Sandy45)\
**Replies:** 6\
**Last updated:** [March 10, 2023, 6:08pm UTC](https://discourse.julialang.org/t/code-compiles-each-time-it-triggered/95839 "2023-03-10T18:08:37Z")

</div>

I’ve deployed my Julia code to AWS using Docker containers with enabling multiple threads, The issue we are facing is whenever HTTP end point (Julia) has been triggered process is compiling every time since because of us…

---

## [Improving for loop speed in recursive calculation](https://discourse.julialang.org/t/improving-for-loop-speed-in-recursive-calculation/95848)

<div class="topic-metadata">

**Author:** [@marianoarnaiz](https://discourse.julialang.org/u/marianoarnaiz)\
**Replies:** 1\
**Last updated:** [March 10, 2023, 12:15pm UTC](https://discourse.julialang.org/t/improving-for-loop-speed-in-recursive-calculation/95848 "2023-03-10T12:15:04Z")

</div>

Hi all. I am building a little function that does some recursive computation. it will be working in very large datasets and I want to speed it up. Maybe someone can give a helping hand? :slight\_smile: function rec\_ho…

---

## [Help optimising an expectation function](https://discourse.julialang.org/t/help-optimising-an-expectation-function/91181)

<div class="topic-metadata">

**Author:** [@jacobusmmsmit](https://discourse.julialang.org/u/jacobusmmsmit)\
**Replies:** 10\
**Last updated:** [March 9, 2023, 7:12pm UTC](https://discourse.julialang.org/t/help-optimising-an-expectation-function/91181 "2023-03-09T19:12:46Z")

</div>

Hey everyone, Apologies for the vague title, I think part of my problem is I don’t know the words for what I’m doing so I can’t search for it. Anyway: I have a function of N boolean arguments. I would like to be able t…

---

## [Binary Trees for Equations](https://discourse.julialang.org/t/binary-trees-for-equations/95748)

<div class="topic-metadata">

**Author:** [@Kianoush\_Ramezani\_sh](https://discourse.julialang.org/u/Kianoush_Ramezani_sh)\
**Replies:** 4\
**Last updated:** [March 8, 2023, 10:06pm UTC](https://discourse.julialang.org/t/binary-trees-for-equations/95748 "2023-03-08T22:06:59Z")

</div>

Hi everyone, I want to represent an equation like a binary tree, e,g., I have this equation x\*\*2+x+1 and in Julia I want to represent it as a tree with nodes e.g. + sign is a Node in that tree or x is Node or 1 is an…

---

## [Significant difference in execution speed between similar functions with nested loops](https://discourse.julialang.org/t/significant-difference-in-execution-speed-between-similar-functions-with-nested-loops/95710)

<div class="topic-metadata">

**Author:** [@aomidro](https://discourse.julialang.org/u/aomidro)\
**Replies:** 4\
**Last updated:** [March 8, 2023, 5:26am UTC](https://discourse.julialang.org/t/significant-difference-in-execution-speed-between-similar-functions-with-nested-loops/95710 "2023-03-08T05:26:28Z")

</div>

I compared the execution speed of two similar functions, f1 and f2, with f1 taking almost 1000 times longer than f2. Both functions include nested loops. Can anyone explain why there is such a significant difference in e…

---

## [GC time issues when parallelizing tyalorinteg?](https://discourse.julialang.org/t/gc-time-issues-when-parallelizing-tyalorinteg/80481)

<div class="topic-metadata">

**Author:** [@Alseidon](https://discourse.julialang.org/u/Alseidon)\
**Replies:** 7\
**Last updated:** [March 7, 2023, 5:07pm UTC](https://discourse.julialang.org/t/gc-time-issues-when-parallelizing-tyalorinteg/80481 "2023-03-07T17:07:04Z")

</div>

Hi all, I was messing around with Threads.@thread as I am trying to parallelize a for loop : I want to compute taylorinteg from TaylorIntegration.jl several times, independently, for different initial conditions. To do …

---

## [Convert Vector{SVector} to Matrix](https://discourse.julialang.org/t/convert-vector-svector-to-matrix/27939)

<div class="topic-metadata">

**Author:** [@benzwick](https://discourse.julialang.org/u/benzwick)\
**Replies:** 20\
**Last updated:** [March 6, 2023, 8:05pm UTC](https://discourse.julialang.org/t/convert-vector-svector-to-matrix/27939 "2023-03-06T20:05:58Z")

</div>

I have some code where I need to store coordinates x of a mesh. I’m using a vector of points (static vectors), i.e. using StaticArrays Point{dim} = SVector{dim, Float64} x = rand(Point{3}, 10) but some parts of the cod…

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

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