# Performance

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

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

**Page:** 36

---

## [A brief for Julia in Jupyter Notebook (in Turkish)](https://discourse.julialang.org/t/a-brief-for-julia-in-jupyter-notebook-in-turkish/104710)

<div class="topic-metadata">

**Author:** [@qneoxk](https://discourse.julialang.org/u/qneoxk)\
**Replies:** 0\
**Last updated:** [October 7, 2023, 7:47pm UTC](https://discourse.julialang.org/t/a-brief-for-julia-in-jupyter-notebook-in-turkish/104710 "2023-10-07T19:47:08Z")

</div>

Some basic applications for Julia with Jupyter Notebook https://github.com/qneoxk/Julia

---

## [How to create a single shared parameter for multiple gates within a circuit directly using Yao.jl?](https://discourse.julialang.org/t/how-to-create-a-single-shared-parameter-for-multiple-gates-within-a-circuit-directly-using-yao-jl/104648)

<div class="topic-metadata">

**Author:** [@nethaji8](https://discourse.julialang.org/u/nethaji8)\
**Replies:** 3\
**Last updated:** [October 7, 2023, 5:10am UTC](https://discourse.julialang.org/t/how-to-create-a-single-shared-parameter-for-multiple-gates-within-a-circuit-directly-using-yao-jl/104648 "2023-10-07T05:10:32Z")

</div>

I am trying to parameterize a circuit using a single variable θ in the code below but the output is: Number of parameters in the circuit: 4 . Can someone please help me create a single shared parameter for multiple g…

---

## [Avoid allocations for string concatenation](https://discourse.julialang.org/t/avoid-allocations-for-string-concatenation/104666)

<div class="topic-metadata">

**Author:** [@pjuergens](https://discourse.julialang.org/u/pjuergens)\
**Replies:** 5\
**Last updated:** [October 7, 2023, 3:35am UTC](https://discourse.julialang.org/t/avoid-allocations-for-string-concatenation/104666 "2023-10-07T03:35:14Z")

</div>

Hei together, I realised with the allocation profiler that our model allocates a lot when concatenating strings like "a" \* "b". Is there a way to avoid allocation in such cases? I tried with InternedStrings and intern("…

---

## [Fastest way possible to find index of value equals 1 across a matrix column](https://discourse.julialang.org/t/fastest-way-possible-to-find-index-of-value-equals-1-across-a-matrix-column/104485)

<div class="topic-metadata">

**Author:** [@eduardosalaz](https://discourse.julialang.org/u/eduardosalaz)\
**Replies:** 7\
**Last updated:** [October 6, 2023, 4:32pm UTC](https://discourse.julialang.org/t/fastest-way-possible-to-find-index-of-value-equals-1-across-a-matrix-column/104485 "2023-10-06T16:32:06Z")

</div>

Hi there everyone. I am currently working on my thesis which involves an optimization problem in which I have an X decision matrix filled with 0s, each column must have a 1 value as it represents an allocation. In my lo…

---

## [Strange allocation in loop when calling function](https://discourse.julialang.org/t/strange-allocation-in-loop-when-calling-function/104620)

<div class="topic-metadata">

**Author:** [@GrantHecht](https://discourse.julialang.org/u/GrantHecht)\
**Replies:** 2\
**Last updated:** [October 5, 2023, 5:35pm UTC](https://discourse.julialang.org/t/strange-allocation-in-loop-when-calling-function/104620 "2023-10-05T17:35:52Z")

</div>

Hello! I’ve been working on writing some very simple ODE solvers as an exercise to improve my understanding of Julia and how it can be used to write fast code. In doing so, I’ve arrived at some code that exhibits some s…

---

## [Struggling with creating a faster threaded version of a concurrent problem](https://discourse.julialang.org/t/struggling-with-creating-a-faster-threaded-version-of-a-concurrent-problem/104549)

<div class="topic-metadata">

**Author:** [@tamasgal](https://discourse.julialang.org/u/tamasgal)\
**Replies:** 16\
**Last updated:** [October 5, 2023, 12:22pm UTC](https://discourse.julialang.org/t/struggling-with-creating-a-faster-threaded-version-of-a-concurrent-problem/104549 "2023-10-05T12:22:56Z")

</div>

Alright, I am so desperate that I call for some help from people experienced in concurrent/threaded programming in Julia since I am hitting a wall here. I can’t even provide a MWE but I am getting more and more desperate…

---

## [Julia on VSCode Notebook does not clean RAM and hangs if notebook restarted](https://discourse.julialang.org/t/julia-on-vscode-notebook-does-not-clean-ram-and-hangs-if-notebook-restarted/104535)

<div class="topic-metadata">

**Author:** [@Simone\_Gabbriellini](https://discourse.julialang.org/u/Simone_Gabbriellini)\
**Replies:** 1\
**Last updated:** [October 4, 2023, 8:37am UTC](https://discourse.julialang.org/t/julia-on-vscode-notebook-does-not-clean-ram-and-hangs-if-notebook-restarted/104535 "2023-10-04T08:37:12Z")

</div>

I have a notebook I use in VSCode, with a kernel Julia 1.9.3, that uses the package Agents. I launch a distributed simulation on 10 cores on my Ubuntu 18.04. The model loads a CSV file (50MB), then I launch, say, 30 simu…

---

## [Zygote performances for simple function](https://discourse.julialang.org/t/zygote-performances-for-simple-function/104465)

<div class="topic-metadata">

**Author:** [@rcalxrc08](https://discourse.julialang.org/u/rcalxrc08)\
**Replies:** 14\
**Last updated:** [October 3, 2023, 9:19am UTC](https://discourse.julialang.org/t/zygote-performances-for-simple-function/104465 "2023-10-03T09:19:12Z")

</div>

Hi all, I have a the following example in Zygote for computing a single gradient, and I don’t understand why I get this performance regression over the following examples: using SpecialFunctions,BenchmarkTools,Zygote,I…

---

## [A bug in using varinfo() when there is 3d data in the struct structure!](https://discourse.julialang.org/t/a-bug-in-using-varinfo-when-there-is-3d-data-in-the-struct-structure/104449)

<div class="topic-metadata">

**Author:** [@13299118606](https://discourse.julialang.org/u/13299118606)\
**Replies:** 4\
**Last updated:** [October 3, 2023, 7:40am UTC](https://discourse.julialang.org/t/a-bug-in-using-varinfo-when-there-is-3d-data-in-the-struct-structure/104449 "2023-10-03T07:40:36Z")

</div>

There is a bug in using varinfo when there is three-dimensional data in the struct structure. When there is 3d data inside the structure, it will greatly slow down the corresponding response speed when using varinfo. The…

---

## [Inconsistent results using LoopVectorization @turbo with linear indexing](https://discourse.julialang.org/t/inconsistent-results-using-loopvectorization-turbo-with-linear-indexing/104481)

<div class="topic-metadata">

**Author:** [@james3](https://discourse.julialang.org/u/james3)\
**Replies:** 1\
**Last updated:** [October 2, 2023, 3:08am UTC](https://discourse.julialang.org/t/inconsistent-results-using-loopvectorization-turbo-with-linear-indexing/104481 "2023-10-02T03:08:39Z")

</div>

I am obtaining incorrect results when I combine @turbo with linear indexing of my array. I have a simple example of the issue below. Results are the same except when I combine @turbo with linear indexing. using LoopVect…

---

## [Binary reading and matrix allocations: most performant way?](https://discourse.julialang.org/t/binary-reading-and-matrix-allocations-most-performant-way/103929)

<div class="topic-metadata">

**Author:** [@myersm0](https://discourse.julialang.org/u/myersm0)\
**Replies:** 3\
**Last updated:** [October 1, 2023, 8:54pm UTC](https://discourse.julialang.org/t/binary-reading-and-matrix-allocations-most-performant-way/103929 "2023-10-01T20:54:04Z")

</div>

Would anyone be able to offer some insight towards getting faster performance for the below sort of use case? Say I have a struct that holds a Matrix and my primary goal is to fill it with values, possibly transposed, a…

---

## [Is it possible to parallelize matrix division](https://discourse.julialang.org/t/is-it-possible-to-parallelize-matrix-division/104398)

<div class="topic-metadata">

**Author:** [@Shashank](https://discourse.julialang.org/u/Shashank)\
**Replies:** 10\
**Last updated:** [October 1, 2023, 2:18pm UTC](https://discourse.julialang.org/t/is-it-possible-to-parallelize-matrix-division/104398 "2023-10-01T14:18:15Z")

</div>

I have a big (~10000x10000) but sparse matrix A and a vector B. I want to solve the system using backslash C = A\\B , and it works, but it is taking too long. Is there a way to parallelize this and utilize multiple core…

---

## [Faster sum loop when looping through vector multiple times than once](https://discourse.julialang.org/t/faster-sum-loop-when-looping-through-vector-multiple-times-than-once/104388)

<div class="topic-metadata">

**Author:** [@Jad\_Zeitouni](https://discourse.julialang.org/u/Jad_Zeitouni)\
**Replies:** 5\
**Last updated:** [September 29, 2023, 1:47pm UTC](https://discourse.julialang.org/t/faster-sum-loop-when-looping-through-vector-multiple-times-than-once/104388 "2023-09-29T13:47:39Z")

</div>

I was benchmarking different ways of summing a matrix by its second dimension and I got some surprising results (for me) when doing it through a for loop. I had thought that in general the loop would be faster if the in…

---

## [MKLPardiso and Julia GC seg faults](https://discourse.julialang.org/t/mklpardiso-and-julia-gc-seg-faults/104368)

<div class="topic-metadata">

**Author:** [@jdlara-berkeley](https://discourse.julialang.org/u/jdlara-berkeley)\
**Replies:** 0\
**Last updated:** [September 28, 2023, 9:26pm UTC](https://discourse.julialang.org/t/mklpardiso-and-julia-gc-seg-faults/104368 "2023-09-28T21:26:45Z")

</div>

I have been using Pardiso.jl 0.5.4 to solve large linear systems of equations with many RHS (80k x 80k). From time to time depending on the size of the system and wether Julia calls GarbageCollect then it will create a s…

---

## [Multithreading increases memory allocations](https://discourse.julialang.org/t/multithreading-increases-memory-allocations/104355)

<div class="topic-metadata">

**Author:** [@Alberto\_Roman](https://discourse.julialang.org/u/Alberto_Roman)\
**Replies:** 3\
**Last updated:** [September 28, 2023, 5:56pm UTC](https://discourse.julialang.org/t/multithreading-increases-memory-allocations/104355 "2023-09-28T17:56:59Z")

</div>

Hi there, I am trying to understand why the number of memory allocations increases with multi threading. I have the following code computing the difference of a vector (it is basically the diff function) ‘’’ function…

---

## [Why is sum slower than multiplying by vector of ones?](https://discourse.julialang.org/t/why-is-sum-slower-than-multiplying-by-vector-of-ones/104347)

<div class="topic-metadata">

**Author:** [@Jad\_Zeitouni](https://discourse.julialang.org/u/Jad_Zeitouni)\
**Replies:** 4\
**Last updated:** [September 28, 2023, 2:05pm UTC](https://discourse.julialang.org/t/why-is-sum-slower-than-multiplying-by-vector-of-ones/104347 "2023-09-28T14:05:04Z")

</div>

So when I try to sum a 10000 x 100 matrix x on its second dimension, using sum(x, dims=2), it takes about 200 microseconds. If I instead do x \* ones(100), this takes only 40 microseconds. What gives? Here’s the full cod…

---

## [Performance comparison, Julia is a slower than Mojo, am I doing something wrong?](https://discourse.julialang.org/t/performance-comparison-julia-is-a-slower-than-mojo-am-i-doing-something-wrong/103870)

<div class="topic-metadata">

**Author:** [@Brian1](https://discourse.julialang.org/u/Brian1)\
**Replies:** 44\
**Last updated:** [September 28, 2023, 1:10pm UTC](https://discourse.julialang.org/t/performance-comparison-julia-is-a-slower-than-mojo-am-i-doing-something-wrong/103870 "2023-09-28T13:10:00Z")

</div>

I am using fibonacci function to the compare the performance between Julia and Mojo. First Julia code: function fib(n::Int64)::Int64 n \<= 2 && return 1 n == 3 && return 2 fib(n - 1) + fib(n - 2) end @time …

---

## [Size-hinted array declarations](https://discourse.julialang.org/t/size-hinted-array-declarations/100935)

<div class="topic-metadata">

**Author:** [@jonniedie](https://discourse.julialang.org/u/jonniedie)\
**Replies:** 6\
**Last updated:** [September 28, 2023, 10:20am UTC](https://discourse.julialang.org/t/size-hinted-array-declarations/100935 "2023-09-28T10:20:49Z")

</div>

The common way of declaring size-hinted arrays for more efficient append!/push!/etc. seems to be x = SomeElementType\[\] sizehint!(x, expected\_size) But the sizehint! induces an extra allocation. Is there a way to avoid …

---

## [Why do hitting Ctrl+Enter or cutting and pasting code in the REPL yield different results?](https://discourse.julialang.org/t/why-do-hitting-ctrl-enter-or-cutting-and-pasting-code-in-the-repl-yield-different-results/104272)

<div class="topic-metadata">

**Author:** [@Soldalma](https://discourse.julialang.org/u/Soldalma)\
**Replies:** 3\
**Last updated:** [September 26, 2023, 9:00pm UTC](https://discourse.julialang.org/t/why-do-hitting-ctrl-enter-or-cutting-and-pasting-code-in-the-repl-yield-different-results/104272 "2023-09-26T21:00:19Z")

</div>

I have some code that I am working on in VSCode, where at some point I try to include a file with this line: include("./src/ModelData.jl") Then I get an error message: ERROR: SystemError: opening file "c:\\\\Users\\\\fsal…

---

## [Need help understanding the allocations](https://discourse.julialang.org/t/need-help-understanding-the-allocations/104225)

<div class="topic-metadata">

**Author:** [@navdeeprana](https://discourse.julialang.org/u/navdeeprana)\
**Replies:** 8\
**Last updated:** [September 26, 2023, 9:15am UTC](https://discourse.julialang.org/t/need-help-understanding-the-allocations/104225 "2023-09-26T09:15:25Z")

</div>

Consider the following code using BenchmarkTools using Random using QuadGK f(p, xm, x) = -x^2 / ((p\[1\] - xm\[1\]\*x)^2 + (p\[2\] - xm\[2\]\*x)^2) g(p, xm, x) = -x^2 / ((p\[1\] - xm\[1\])^2 + (p\[2\] - xm\[2\])^2) integralf(p, xm) = qu…

---

## [GenieBuilder unable to install package](https://discourse.julialang.org/t/geniebuilder-unable-to-install-package/104123)

<div class="topic-metadata">

**Author:** [@vtomar](https://discourse.julialang.org/u/vtomar)\
**Replies:** 4\
**Last updated:** [September 26, 2023, 7:38am UTC](https://discourse.julialang.org/t/geniebuilder-unable-to-install-package/104123 "2023-09-26T07:38:08Z")

</div>

I get the following error: Pkg.add(url = “GitHub - GenieFramework/GenieBuilder.jl”) Cloning git-repo https://github.com/GenieFramework/GenieBuilder.jl.git Updating git-repo https://github.com/GenieFramework/GenieBuil…

---

## [How to improve REPL startup time OR clear the workspace](https://discourse.julialang.org/t/how-to-improve-repl-startup-time-or-clear-the-workspace/104171)

<div class="topic-metadata">

**Author:** [@mcmuffin6o](https://discourse.julialang.org/u/mcmuffin6o)\
**Replies:** 9\
**Last updated:** [September 24, 2023, 4:53am UTC](https://discourse.julialang.org/t/how-to-improve-repl-startup-time-or-clear-the-workspace/104171 "2023-09-24T04:53:41Z")

</div>

I love Julia – it’s amazing with the VS Code extension, which solves the problem of not being able to perform the simple task of plotting more than one thing at once. There’s just one thing keeping me from recommending i…

---

## [Speeding up a nested for loop](https://discourse.julialang.org/t/speeding-up-a-nested-for-loop/104130)

<div class="topic-metadata">

**Author:** [@MarcBerliner](https://discourse.julialang.org/u/MarcBerliner)\
**Replies:** 5\
**Last updated:** [September 23, 2023, 10:06pm UTC](https://discourse.julialang.org/t/speeding-up-a-nested-for-loop/104130 "2023-09-23T22:06:18Z")

</div>

I have a nested for-loop where the length of the internal loop is dependent on the outer loop. Any ideas on how to squeeze more performance out of this? N = 500 a = rand(N) b = rand(N) c = rand(N) out = zeros(N) j\_mi…

---

## [How to speed up the calculation of Logit likelihood?](https://discourse.julialang.org/t/how-to-speed-up-the-calculation-of-logit-likelihood/104153)

<div class="topic-metadata">

**Author:** [@Strange\_Xue](https://discourse.julialang.org/u/Strange_Xue)\
**Replies:** 8\
**Last updated:** [September 23, 2023, 11:41am UTC](https://discourse.julialang.org/t/how-to-speed-up-the-calculation-of-logit-likelihood/104153 "2023-09-23T11:41:57Z")

</div>

Hi, I am currently using Julia to solve some econometric structural models which usually involve the calculation and optimization of Log-likelihood function. While the optimization can be done by Optim.jl, the calculatio…

---

## [Best practices to reduce allocations in Julia](https://discourse.julialang.org/t/best-practices-to-reduce-allocations-in-julia/104158)

<div class="topic-metadata">

**Author:** [@Jian\_ZUO](https://discourse.julialang.org/u/Jian_ZUO)\
**Replies:** 6\
**Last updated:** [September 23, 2023, 7:59am UTC](https://discourse.julialang.org/t/best-practices-to-reduce-allocations-in-julia/104158 "2023-09-23T07:59:42Z")

</div>

Hi all, I have a relatively big simulation function (which has 20,000 repeated loops). The @time results show more than 64.5G allocations. Are there some tips to reduce the allocations? Thank you in advance.

---

## [Reduce allocations LinearSolve](https://discourse.julialang.org/t/reduce-allocations-linearsolve/104141)

<div class="topic-metadata">

**Author:** [@Kieran\_Marray](https://discourse.julialang.org/u/Kieran_Marray)\
**Replies:** 4\
**Last updated:** [September 22, 2023, 2:34pm UTC](https://discourse.julialang.org/t/reduce-allocations-linearsolve/104141 "2023-09-22T14:34:52Z")

</div>

Hi - I am trying to solve a linear problem repeatedly using LinearSolve.jl without allocating any new memory by mutating the input and solution arrays. Here is a minimal example using LinearAlgebra, LinearSolve, Iterati…

---

## [Efficiently merge multiple .arrow files (12 files totaling 2.5 TB) into a single DataFrame for effective data analysis while minimizing memory overhead](https://discourse.julialang.org/t/efficiently-merge-multiple-arrow-files-12-files-totaling-2-5-tb-into-a-single-dataframe-for-effective-data-analysis-while-minimizing-memory-overhead/104110)

<div class="topic-metadata">

**Author:** [@ujjwal\_singh](https://discourse.julialang.org/u/ujjwal_singh)\
**Replies:** 14\
**Last updated:** [September 22, 2023, 9:17am UTC](https://discourse.julialang.org/t/efficiently-merge-multiple-arrow-files-12-files-totaling-2-5-tb-into-a-single-dataframe-for-effective-data-analysis-while-minimizing-memory-overhead/104110 "2023-09-22T09:17:48Z")

</div>

Could someone please guide me on how to merge multiple large .arrow files (12 files totaling 2.5 TB) into a single DataFrame with minimal memory overhead for big data analysis? I have a total of 1 TB of RAM; can I manage…

---

## [What is idiomatic way of vectorizing longer operations in Julia?](https://discourse.julialang.org/t/what-is-idiomatic-way-of-vectorizing-longer-operations-in-julia/104117)

<div class="topic-metadata">

**Author:** [@Devetak](https://discourse.julialang.org/u/Devetak)\
**Replies:** 5\
**Last updated:** [September 21, 2023, 6:22pm UTC](https://discourse.julialang.org/t/what-is-idiomatic-way-of-vectorizing-longer-operations-in-julia/104117 "2023-09-21T18:22:06Z")

</div>

Hello. I have recently tried writing some code and need help with vectorization. I like that Julia’s loops are efficient, but sometimes I want to write less verbose code. How to do it in this case? What are the best pra…

---

## [Why the function sum1 is faster than builtin sum](https://discourse.julialang.org/t/why-the-function-sum1-is-faster-than-builtin-sum/104051)

<div class="topic-metadata">

**Author:** [@VinodV](https://discourse.julialang.org/u/VinodV)\
**Replies:** 14\
**Last updated:** [September 21, 2023, 8:17am UTC](https://discourse.julialang.org/t/why-the-function-sum1-is-faster-than-builtin-sum/104051 "2023-09-21T08:17:21Z")

</div>

julia\> using BenchmarkTools julia\> function sum1(num) total = 0 for i in num total += i end return total end sum1 (generic function with 1 method) julia\> a = coll…

---

## [How to construct a struct with common field values efficiently](https://discourse.julialang.org/t/how-to-construct-a-struct-with-common-field-values-efficiently/104047)

<div class="topic-metadata">

**Author:** [@lukemin](https://discourse.julialang.org/u/lukemin)\
**Replies:** 32\
**Last updated:** [September 21, 2023, 3:13am UTC](https://discourse.julialang.org/t/how-to-construct-a-struct-with-common-field-values-efficiently/104047 "2023-09-21T03:13:35Z")

</div>

I am now developing a code which makes use of a huge number of modulo arithmetic. For a better readability, I tried to define custom types Modulus and ModNum. Modulus contains some values which is essential for the mod…

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

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