# Performance

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

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

**Page:** 23

---

## [Huge distributed overhead](https://discourse.julialang.org/t/huge-distributed-overhead/115815)

<div class="topic-metadata">

**Author:** [@greivin](https://discourse.julialang.org/u/greivin)\
**Replies:** 2\
**Last updated:** [June 19, 2024, 11:46am UTC](https://discourse.julialang.org/t/huge-distributed-overhead/115815 "2024-06-19T11:46:17Z")

</div>

My code looks something like this. First, I have a file where I define my functions #Functions.jl file #Here we import the relevant packages and define all the functions with @everywere @everywhere Solver(A, N) …

---

## [What's the deal with StaticArrays?](https://discourse.julialang.org/t/whats-the-deal-with-staticarrays/115816)

<div class="topic-metadata">

**Author:** [@sadish-d](https://discourse.julialang.org/u/sadish-d)\
**Replies:** 5\
**Last updated:** [June 19, 2024, 12:23am UTC](https://discourse.julialang.org/t/whats-the-deal-with-staticarrays/115816 "2024-06-19T00:23:09Z")

</div>

First, disclaimer that I have a shallow understanding of heap and stack and allocations. Given that, here is my basic understanding of StaticArrays: They are appropriate when there are lots of small arrays involved becau…

---

## [Aggresive garbage collection behavior with DataFrames in 1.10?](https://discourse.julialang.org/t/aggresive-garbage-collection-behavior-with-dataframes-in-1-10/115785)

<div class="topic-metadata">

**Author:** [@james\_thomas](https://discourse.julialang.org/u/james_thomas)\
**Replies:** 0\
**Last updated:** [June 18, 2024, 2:06am UTC](https://discourse.julialang.org/t/aggresive-garbage-collection-behavior-with-dataframes-in-1-10/115785 "2024-06-18T02:06:53Z")

</div>

I’m seeing some unexpected behavior with garbage collection in 1.10 while working with large DataFrames in the REPL. If I run this (simplified example) code in 1.10.4: using DataFrames …

---

## [Overhead of view / reshape / transpose in linear algebra](https://discourse.julialang.org/t/overhead-of-view-reshape-transpose-in-linear-algebra/110761)

<div class="topic-metadata">

**Author:** [@jsjie](https://discourse.julialang.org/u/jsjie)\
**Replies:** 8\
**Last updated:** [June 17, 2024, 7:27pm UTC](https://discourse.julialang.org/t/overhead-of-view-reshape-transpose-in-linear-algebra/110761 "2024-06-17T19:27:37Z")

</div>

An example: reshape + view + ' for transpose + mul! will have some overhead. using Random using LinearAlgebra using BenchmarkTools buf = zeros(1000) v1 = reshape(view(buf, 1:100), (20, 5)) v2 = view(v1, 1:16, :) m3 = ze…

---

## [How to convert contractions from TensorOperations to ITensor?](https://discourse.julialang.org/t/how-to-convert-contractions-from-tensoroperations-to-itensor/115750)

<div class="topic-metadata">

**Author:** [@Uranium238](https://discourse.julialang.org/u/Uranium238)\
**Replies:** 1\
**Last updated:** [June 17, 2024, 2:16pm UTC](https://discourse.julialang.org/t/how-to-convert-contractions-from-tensoroperations-to-itensor/115750 "2024-06-17T14:16:58Z")

</div>

I am trying to write a code for an iterative solver of a set of non linear equations. Doing this needs computation of a lot of Tensor Contractions which I had been doing using TensorOperations.jl . My code is running fin…

---

## [Unstable ODE within Turing model](https://discourse.julialang.org/t/unstable-ode-within-turing-model/115419)

<div class="topic-metadata">

**Author:** [@caesoma](https://discourse.julialang.org/u/caesoma)\
**Replies:** 8\
**Last updated:** [June 17, 2024, 10:18am UTC](https://discourse.julialang.org/t/unstable-ode-within-turing-model/115419 "2024-06-17T10:18:39Z")

</div>

I have a fairly complicated ODE system I am using within Turing for HMC sampling. Sampling seems to work fine: traces and metrics look good in general. However, when I extract a few random samples from the chain and run …

---

## [How to delete a variable from memory in Julia?](https://discourse.julialang.org/t/how-to-delete-a-variable-from-memory-in-julia/115649)

<div class="topic-metadata">

**Author:** [@Uranium238](https://discourse.julialang.org/u/Uranium238)\
**Replies:** 12\
**Last updated:** [June 17, 2024, 8:26am UTC](https://discourse.julialang.org/t/how-to-delete-a-variable-from-memory-in-julia/115649 "2024-06-17T08:26:58Z")

</div>

Below is a very memory and performance intensive part of my code which aims to a system of non-linear equations via tensor contractions. Performance and memory intensive codefunction calculate\_residual\_memeff(T2) # …

---

## [LocalRegistry on Azure DevOps](https://discourse.julialang.org/t/localregistry-on-azure-devops/111649)

<div class="topic-metadata">

**Author:** [@kealme](https://discourse.julialang.org/u/kealme)\
**Replies:** 2\
**Last updated:** [June 16, 2024, 10:57am UTC](https://discourse.julialang.org/t/localregistry-on-azure-devops/111649 "2024-06-16T10:57:01Z")

</div>

Hi, I’m developing some packages. In Python, my workflow for this is as follows: Developing: Develop package and start release pipeline in Azure DevOps DevOps publishes the Python Package in the Azure Artifact Feed U…

---

## [Multithreading when task vary in length (and need temporary arrays)](https://discourse.julialang.org/t/multithreading-when-task-vary-in-length-and-need-temporary-arrays/115689)

<div class="topic-metadata">

**Author:** [@nicolas](https://discourse.julialang.org/u/nicolas)\
**Replies:** 5\
**Last updated:** [June 16, 2024, 9:10am UTC](https://discourse.julialang.org/t/multithreading-when-task-vary-in-length-and-need-temporary-arrays/115689 "2024-06-16T09:10:45Z")

</div>

I am running simulations on my personal computer. The compute time of each draw/specification can vary significantly (in an unpredictable way). I think Threads.@threads schedules each iteration of a loop between threads …

---

## [How to investigate output of type instability checks?](https://discourse.julialang.org/t/how-to-investigate-output-of-type-instability-checks/115639)

<div class="topic-metadata">

**Author:** [@Uranium238](https://discourse.julialang.org/u/Uranium238)\
**Replies:** 11\
**Last updated:** [June 15, 2024, 4:44pm UTC](https://discourse.julialang.org/t/how-to-investigate-output-of-type-instability-checks/115639 "2024-06-15T16:44:29Z")

</div>

I am trying to eliminate the type instabilities that might cause my code (shown below) of an iterative solver to some non linear system of equations to become slow: using Printf,Plots, TimerOutputs include("ccd-helper.j…

---

## [System of SDE with complex noise](https://discourse.julialang.org/t/system-of-sde-with-complex-noise/111469)

<div class="topic-metadata">

**Author:** [@matt1](https://discourse.julialang.org/u/matt1)\
**Replies:** 1\
**Last updated:** [June 15, 2024, 11:00am UTC](https://discourse.julialang.org/t/system-of-sde-with-complex-noise/111469 "2024-06-15T11:00:46Z")

</div>

Hello! Let’s say I want to solve numerically the following stochastic partial differential equation: \\begin{equation} du(x,y,t)=\\nabla^{2}u(x,y,t) dt+k\\cdot dW^{r}(x,y,t)+i k\\cdot dW^{c}(x,y,t)) \\end{equation}, wher…

---

## [Unexpected Memory Allocation of Broadcasting Copy](https://discourse.julialang.org/t/unexpected-memory-allocation-of-broadcasting-copy/115634)

<div class="topic-metadata">

**Author:** [@0samuraiE](https://discourse.julialang.org/u/0samuraiE)\
**Replies:** 4\
**Last updated:** [June 15, 2024, 2:59am UTC](https://discourse.julialang.org/t/unexpected-memory-allocation-of-broadcasting-copy/115634 "2024-06-15T02:59:47Z")

</div>

Hi all. I encounted the problem as topic saids. julia\> a = zeros(4, 4, 3) julia\> @btime @views $a\[:, :, 2\] .= $a\[:, :, 2\] 38.862 ns (1 allocation: 192 bytes) julia\> @btime @views for i in eachindex($a\[:, :, 2\]) …

---

## [Accessing a vector of vector is slow](https://discourse.julialang.org/t/accessing-a-vector-of-vector-is-slow/115552)

<div class="topic-metadata">

**Author:** [@elbert5770](https://discourse.julialang.org/u/elbert5770)\
**Replies:** 6\
**Last updated:** [June 13, 2024, 3:06pm UTC](https://discourse.julialang.org/t/accessing-a-vector-of-vector-is-slow/115552 "2024-06-13T15:06:35Z")

</div>

This topic: How is memory allocated for a vector of structs? - General Usage / Performance - Julia Programming Language (julialang.org) made me wonder if a vector of vectors would be faster than a vector of struct for t…

---

## [For \`x::Vector{Char}\`, which should I use \`string(x...)\` or \`join(x)\`?](https://discourse.julialang.org/t/for-x-vector-char-which-should-i-use-string-x-or-join-x/115469)

<div class="topic-metadata">

**Author:** [@paalon](https://discourse.julialang.org/u/paalon)\
**Replies:** 6\
**Last updated:** [June 13, 2024, 7:01am UTC](https://discourse.julialang.org/t/for-x-vector-char-which-should-i-use-string-x-or-join-x/115469 "2024-06-13T07:01:25Z")

</div>

I have a black box variable x::Vector{Char} which satisfies length(x) \< 20 (actually, it is not a black box because it is open source, but I do not understand how it behaves yet because I have not read the implementation…

---

## [Using a lock array to prevent multi thread corruption](https://discourse.julialang.org/t/using-a-lock-array-to-prevent-multi-thread-corruption/115485)

<div class="topic-metadata">

**Author:** [@CodeGodz](https://discourse.julialang.org/u/CodeGodz)\
**Replies:** 2\
**Last updated:** [June 11, 2024, 10:38pm UTC](https://discourse.julialang.org/t/using-a-lock-array-to-prevent-multi-thread-corruption/115485 "2024-06-11T22:38:15Z")

</div>

I was reading through @Dan’s answer here to lock a struct using a spinlock. Lets say we are in a situation where we have a struct that in its entirety needs to be updated. Could we use something like: struct Entry v…

---

## [How to avoid memory blow up with FFT without expensive garbage collection?](https://discourse.julialang.org/t/how-to-avoid-memory-blow-up-with-fft-without-expensive-garbage-collection/115400)

<div class="topic-metadata">

**Author:** [@singularity](https://discourse.julialang.org/u/singularity)\
**Replies:** 3\
**Last updated:** [June 10, 2024, 7:55pm UTC](https://discourse.julialang.org/t/how-to-avoid-memory-blow-up-with-fft-without-expensive-garbage-collection/115400 "2024-06-10T19:55:33Z")

</div>

I am trying to write a code that has a for loop inside which an array is broken into chunks, sent to multiple processors, and FFT is performed on those chunks. Without using garbage collection GC.gc() command at the end …

---

## [Why is Julia allocating when accessing these structs?](https://discourse.julialang.org/t/why-is-julia-allocating-when-accessing-these-structs/89905)

<div class="topic-metadata">

**Author:** [@dellagd](https://discourse.julialang.org/u/dellagd)\
**Replies:** 18\
**Last updated:** [June 10, 2024, 2:05pm UTC](https://discourse.julialang.org/t/why-is-julia-allocating-when-accessing-these-structs/89905 "2024-06-10T14:05:05Z")

</div>

Been struggling to figure out why accesses to these struct fields are causing memory allocations. Here is my test code: module AllocationsTest struct SubStruct a::Float64 b::Float64 end struct AllocationsStruc…

---

## [Efficient operations on vectors of static things](https://discourse.julialang.org/t/efficient-operations-on-vectors-of-static-things/115387)

<div class="topic-metadata">

**Author:** [@ddcampayo](https://discourse.julialang.org/u/ddcampayo)\
**Replies:** 12\
**Last updated:** [June 10, 2024, 11:27am UTC](https://discourse.julialang.org/t/efficient-operations-on-vectors-of-static-things/115387 "2024-06-10T11:27:36Z")

</div>

Hello. I am (still) trying to make sense on how to efficiently traverse a vector containing static vectors and matrices and doing operations on them. This is in the context of molecular dynamics, where I have N particle…

---

## [How to initialize a tensor with permutational symmetry?](https://discourse.julialang.org/t/how-to-initialize-a-tensor-with-permutational-symmetry/115390)

<div class="topic-metadata">

**Author:** [@Uranium238](https://discourse.julialang.org/u/Uranium238)\
**Replies:** 1\
**Last updated:** [June 9, 2024, 1:52pm UTC](https://discourse.julialang.org/t/how-to-initialize-a-tensor-with-permutational-symmetry/115390 "2024-06-09T13:52:44Z")

</div>

I am working on a iterative solver for non linear Coupled Cluster equations that would require a computation of lot of tensor elements via tensor contractions. For now, I am using the TensorOperations.jl for this purpose…

---

## [Getting Stack Overflow error when running Derivative(x)^n](https://discourse.julialang.org/t/getting-stack-overflow-error-when-running-derivative-x-n/115300)

<div class="topic-metadata">

**Author:** [@vikram\_backup](https://discourse.julialang.org/u/vikram_backup)\
**Replies:** 5\
**Last updated:** [June 8, 2024, 11:11am UTC](https://discourse.julialang.org/t/getting-stack-overflow-error-when-running-derivative-x-n/115300 "2024-06-08T11:11:58Z")

</div>

I have published my code in the following link. I am pasting my code here as well ## using Symbolics using Plots using Statistics ## a = 0.529\*10^-10 # Radius of hydrogen atom in meters function Legrande(l::Int, cosθ:…

---

## [Type instability when solving ODEProblem](https://discourse.julialang.org/t/type-instability-when-solving-odeproblem/105687)

<div class="topic-metadata">

**Author:** [@albertomercurio](https://discourse.julialang.org/u/albertomercurio)\
**Replies:** 3\
**Last updated:** [June 7, 2024, 3:57pm UTC](https://discourse.julialang.org/t/type-instability-when-solving-odeproblem/105687 "2024-06-07T15:57:26Z")

</div>

Hello, in the following I show a minimal working example of the problem. I want to implement a type stable function that solves an ODE. But I figured out that the solve function returns Any type. This is the minimal code…

---

## [How is memory allocated for a vector of structs?](https://discourse.julialang.org/t/how-is-memory-allocated-for-a-vector-of-structs/115314)

<div class="topic-metadata">

**Author:** [@fmario](https://discourse.julialang.org/u/fmario)\
**Replies:** 9\
**Last updated:** [June 7, 2024, 2:31pm UTC](https://discourse.julialang.org/t/how-is-memory-allocated-for-a-vector-of-structs/115314 "2024-06-07T14:31:54Z")

</div>

Say we have a mutable struct like this: mutable struct Foo a::Int b::Int end I have to allocate many of these structs. In C, I would allocate them all at once in an array, instead of using malloc to allocate e…

---

## [Effect of typing in structures](https://discourse.julialang.org/t/effect-of-typing-in-structures/115331)

<div class="topic-metadata">

**Author:** [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Replies:** 4\
**Last updated:** [June 7, 2024, 2:01pm UTC](https://discourse.julialang.org/t/effect-of-typing-in-structures/115331 "2024-06-07T14:01:13Z")

</div>

I have a package which contains a couple of structures that are essential to the package’s functionality. There has been a question of how to handle unknown/parametric types. Basically, to my knowledge, there are three a…

---

## [Strange performance problem](https://discourse.julialang.org/t/strange-performance-problem/115227)

<div class="topic-metadata">

**Author:** [@0samuraiE](https://discourse.julialang.org/u/0samuraiE)\
**Replies:** 14\
**Last updated:** [June 7, 2024, 9:12am UTC](https://discourse.julialang.org/t/strange-performance-problem/115227 "2024-06-07T09:12:00Z")

</div>

Hi all, I am new to this forum. Nice to meet you. Today I encouted a strange performance problem. I benchmarked below codes with Benchmarktools. NG = 2 N = NX = NY = NZ = 256 U = rand!(zeros(N + 2NG, N + 2NG, N + 2NG)…

---

## [Solving linear system BC = X where B is a symmetric positive semi-definite matrix](https://discourse.julialang.org/t/solving-linear-system-bc-x-where-b-is-a-symmetric-positive-semi-definite-matrix/115280)

<div class="topic-metadata">

**Author:** [@Uranium238](https://discourse.julialang.org/u/Uranium238)\
**Replies:** 7\
**Last updated:** [June 6, 2024, 4:19pm UTC](https://discourse.julialang.org/t/solving-linear-system-bc-x-where-b-is-a-symmetric-positive-semi-definite-matrix/115280 "2024-06-06T16:19:18Z")

</div>

I am trying to solve for X in BC=X where B is a symmetric positive semi-definite matrix and X is simply a vector with 1 in all of it’s entries. As far as I understand, this can be solved using C=B\\X , but I was wondering…

---

## [Intersection of level sets](https://discourse.julialang.org/t/intersection-of-level-sets/114913)

<div class="topic-metadata">

**Author:** [@cmarcotte](https://discourse.julialang.org/u/cmarcotte)\
**Replies:** 12\
**Last updated:** [June 6, 2024, 9:26am UTC](https://discourse.julialang.org/t/intersection-of-level-sets/114913 "2024-06-06T09:26:57Z")

</div>

Hello! I am computing the intersections of two level sets computed from some input arrays. The idea is that, having retrieved the contours from Makie we can compute the intersections of the curves by iterating over sequ…

---

## [Preallocating and returning anonymous function](https://discourse.julialang.org/t/preallocating-and-returning-anonymous-function/115241)

<div class="topic-metadata">

**Author:** [@kockahonza](https://discourse.julialang.org/u/kockahonza)\
**Replies:** 4\
**Last updated:** [June 5, 2024, 4:27pm UTC](https://discourse.julialang.org/t/preallocating-and-returning-anonymous-function/115241 "2024-06-05T16:27:51Z")

</div>

Hi, so I’m working on a project and I want to avoid many allocations called in a loop as is often suggested. That said I also want to avoid having to pass all the preallocated arrays/space/whatever it is at every functio…

---

## [Getting rid of allocations when copying data from one row to another](https://discourse.julialang.org/t/getting-rid-of-allocations-when-copying-data-from-one-row-to-another/115211)

<div class="topic-metadata">

**Author:** [@GreyAerin](https://discourse.julialang.org/u/GreyAerin)\
**Replies:** 3\
**Last updated:** [June 5, 2024, 6:07am UTC](https://discourse.julialang.org/t/getting-rid-of-allocations-when-copying-data-from-one-row-to-another/115211 "2024-06-05T06:07:58Z")

</div>

I’m writing model code that requires me to replace the border values with the opposite domain values (our domain is everything but the border of the matrix) and since we have to run this value swap every iteration, I was…

---

## [How to decrease number of allocations when using NLSolve.jl?](https://discourse.julialang.org/t/how-to-decrease-number-of-allocations-when-using-nlsolve-jl/115164)

<div class="topic-metadata">

**Author:** [@Uranium238](https://discourse.julialang.org/u/Uranium238)\
**Replies:** 8\
**Last updated:** [June 4, 2024, 1:07pm UTC](https://discourse.julialang.org/t/how-to-decrease-number-of-allocations-when-using-nlsolve-jl/115164 "2024-06-04T13:07:10Z")

</div>

With reference to my last post , I am trying to solve a set of non-linear equations known as the Coupled Cluster Equations in Quantum Chemistry using the NLSolve.jl package. As per the reply of @alfaromartino , in the sa…

---

## [How to employ nlsolve() to a function which has parameters which are difficult to calculate](https://discourse.julialang.org/t/how-to-employ-nlsolve-to-a-function-which-has-parameters-which-are-difficult-to-calculate/115126)

<div class="topic-metadata">

**Author:** [@Uranium238](https://discourse.julialang.org/u/Uranium238)\
**Replies:** 3\
**Last updated:** [June 4, 2024, 11:31am UTC](https://discourse.julialang.org/t/how-to-employ-nlsolve-to-a-function-which-has-parameters-which-are-difficult-to-calculate/115126 "2024-06-04T11:31:58Z")

</div>

Basically, I am trying to solve the Coupled Cluster Equations using Julia and the package NLsolve which can be used to solve such nonlinear equations. My initial strategy was to define a function as follows that accepts …

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

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