# Performance

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

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

**Page:** 59

---

## [Slow \`reduce(vcat, itr)\`](https://discourse.julialang.org/t/slow-reduce-vcat-itr/87115)

<div class="topic-metadata">

**Author:** [@DNF](https://discourse.julialang.org/u/DNF)\
**Replies:** 26\
**Last updated:** [September 13, 2022, 11:03pm UTC](https://discourse.julialang.org/t/slow-reduce-vcat-itr/87115 "2022-09-13T23:03:50Z")

</div>

reduce(vcat, itr) and reduce(hcat, itr) have special implementations that are supposed to make them faster than vcat(itr...) and hcat(itr...), at least for long iterators. But I am seeing the opposite: It starts out ok: …

---

## [FLoops for updating a vector by index](https://discourse.julialang.org/t/floops-for-updating-a-vector-by-index/87186)

<div class="topic-metadata">

**Author:** [@DanielVandH](https://discourse.julialang.org/u/DanielVandH)\
**Replies:** 7\
**Last updated:** [September 13, 2022, 6:03am UTC](https://discourse.julialang.org/t/floops-for-updating-a-vector-by-index/87186 "2022-09-13T06:03:40Z")

</div>

I want to make the following function parallel. function build\_vector\_explicit(du, elements) for k ∈ elements du\[k\] += sin(k) end return nothing end This function takes in a vector du (not necessari…

---

## [Constant propagation: Irrationals doing much better than Float64](https://discourse.julialang.org/t/constant-propagation-irrationals-doing-much-better-than-float64/87142)

<div class="topic-metadata">

**Author:** [@cscherrer](https://discourse.julialang.org/u/cscherrer)\
**Replies:** 15\
**Last updated:** [September 13, 2022, 2:10am UTC](https://discourse.julialang.org/t/constant-propagation-irrationals-doing-much-better-than-float64/87142 "2022-09-13T02:10:06Z")

</div>

@oschulz and I have been talking about a deterministic RNG, with the main application being to generate an arbitrary point in the support of a given distribution. Here’s our current implementation: export FixedRNG struc…

---

## [Forcing data points containing one sinusoidal signal to be symetric around zero and multithreading](https://discourse.julialang.org/t/forcing-data-points-containing-one-sinusoidal-signal-to-be-symetric-around-zero-and-multithreading/87139)

<div class="topic-metadata">

**Author:** [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Replies:** 4\
**Last updated:** [September 12, 2022, 3:27pm UTC](https://discourse.julialang.org/t/forcing-data-points-containing-one-sinusoidal-signal-to-be-symetric-around-zero-and-multithreading/87139 "2022-09-12T15:27:49Z")

</div>

Starting point are real world measurements containing one unique sinusoidal signal. For signal processing purposes it might be beneficial to reduce the offset around zero before evaluating the signal either with fft() o…

---

## [Outer-only constructors and concrete types](https://discourse.julialang.org/t/outer-only-constructors-and-concrete-types/87036)

<div class="topic-metadata">

**Author:** [@pgoulart](https://discourse.julialang.org/u/pgoulart)\
**Replies:** 4\
**Last updated:** [September 12, 2022, 1:26pm UTC](https://discourse.julialang.org/t/outer-only-constructors-and-concrete-types/87036 "2022-09-12T13:26:25Z")

</div>

Suppose I have a type like this, taken from the docs on outer-only constructors: struct Foo{T\<:Number,S\<:Number} \<: SuperType{T} data::Vector{T} sum::S function Foo(a::Vector{T}) where T S = widen(T)…

---

## [Copy the return value of a function to the clipboard](https://discourse.julialang.org/t/copy-the-return-value-of-a-function-to-the-clipboard/87112)

<div class="topic-metadata">

**Author:** [@qwerty](https://discourse.julialang.org/u/qwerty)\
**Replies:** 1\
**Last updated:** [September 12, 2022, 7:54am UTC](https://discourse.julialang.org/t/copy-the-return-value-of-a-function-to-the-clipboard/87112 "2022-09-12T07:54:10Z")

</div>

I have a function that returns a string, how can I make it so that when the function terminates the result is automatically copied to the clipboard (ctrl + c)? Thank you.

---

## [Julia in Colab suddenly does not work](https://discourse.julialang.org/t/julia-in-colab-suddenly-does-not-work/87108)

<div class="topic-metadata">

**Author:** [@Shuo\_Z](https://discourse.julialang.org/u/Shuo_Z)\
**Replies:** 0\
**Last updated:** [September 12, 2022, 5:27am UTC](https://discourse.julialang.org/t/julia-in-colab-suddenly-does-not-work/87108 "2022-09-12T05:27:47Z")

</div>

I had been using Julia in Colab for months, it had been working well until 8th Sep. The template I use is: Julia Template Colab The installation (1st cell) suddenly cannot be complete. I tried to change runtime type, …

---

## [Multithreading in many nested loops](https://discourse.julialang.org/t/multithreading-in-many-nested-loops/87017)

<div class="topic-metadata">

**Author:** [@Jonas208](https://discourse.julialang.org/u/Jonas208)\
**Replies:** 1\
**Last updated:** [September 9, 2022, 9:46pm UTC](https://discourse.julialang.org/t/multithreading-in-many-nested-loops/87017 "2022-09-09T21:46:13Z")

</div>

I am trying to optimize a function which performs a convolution-operation known from neuronal networks. I have already tried to optimize the function as much as possible (e.g. code\_warntype etc.), now I would like to gi…

---

## [Why more BLAS threads take more time](https://discourse.julialang.org/t/why-more-blas-threads-take-more-time/86975)

<div class="topic-metadata">

**Author:** [@tiZ](https://discourse.julialang.org/u/tiZ)\
**Replies:** 2\
**Last updated:** [September 9, 2022, 4:14pm UTC](https://discourse.julialang.org/t/why-more-blas-threads-take-more-time/86975 "2022-09-09T16:14:35Z")

</div>

Hi, I wrote a deep learning model using MNIST data and when I ran it on PC and server respectively, I encountered some performance issues. More details are listed below. About the devices I’m using. the PC have 1 phy…

---

## [Fast small integer matrix multiplication](https://discourse.julialang.org/t/fast-small-integer-matrix-multiplication/86981)

<div class="topic-metadata">

**Author:** [@Fabrice\_Rosay](https://discourse.julialang.org/u/Fabrice_Rosay)\
**Replies:** 11\
**Last updated:** [September 9, 2022, 3:03pm UTC](https://discourse.julialang.org/t/fast-small-integer-matrix-multiplication/86981 "2022-09-09T15:03:38Z")

</div>

Hi, I need to multiply a lot of times a vector B of integers of size 64 by a 24x64 integer matrix B. Currently the fastest way I found is simply A\*B, which is very fast if the matrix are converted to Float32 (which I’d…

---

## [~7x compliation time regression in the following data reading code](https://discourse.julialang.org/t/7x-compliation-time-regression-in-the-following-data-reading-code/86951)

<div class="topic-metadata">

**Author:** [@artemsolod](https://discourse.julialang.org/u/artemsolod)\
**Replies:** 6\
**Last updated:** [September 9, 2022, 12:11pm UTC](https://discourse.julialang.org/t/7x-compliation-time-regression-in-the-following-data-reading-code/86951 "2022-09-09T12:11:46Z")

</div>

I noticed a big regression in my data reading code (read csv.zip files from a folder). Stripping it down I get significant time difference between 1.7.3 and 1.8.0. This setup is quite fragile, for example, DataFrames is…

---

## [Utilizing @turbo / @tturbo in Performance Critical Code](https://discourse.julialang.org/t/utilizing-turbo-tturbo-in-performance-critical-code/86940)

<div class="topic-metadata">

**Author:** [@nosewitz](https://discourse.julialang.org/u/nosewitz)\
**Replies:** 4\
**Last updated:** [September 8, 2022, 7:22pm UTC](https://discourse.julialang.org/t/utilizing-turbo-tturbo-in-performance-critical-code/86940 "2022-09-08T19:22:36Z")

</div>

I am writing a KNN prediction algorithm from scratch and I wanted to see if I can squeeze even more performance out of with LoopVectorization’s @turbo macros. However when trying to compile the method, it seems that init…

---

## [How to passing vargs... to a function without allocation?](https://discourse.julialang.org/t/how-to-passing-vargs-to-a-function-without-allocation/86824)

<div class="topic-metadata">

**Author:** [@MrBug](https://discourse.julialang.org/u/MrBug)\
**Replies:** 4\
**Last updated:** [September 6, 2022, 9:54am UTC](https://discourse.julialang.org/t/how-to-passing-vargs-to-a-function-without-allocation/86824 "2022-09-06T09:54:05Z")

</div>

I would like to unpack a tuple parameter of a function, then pass it to another function. The naive implementation in the following causes allocations which becomes a bottleneck for my application. Is there any way to r…

---

## [Advice on speeding up highly parallel and I/O intensive code](https://discourse.julialang.org/t/advice-on-speeding-up-highly-parallel-and-i-o-intensive-code/86795)

<div class="topic-metadata">

**Author:** [@snowgum](https://discourse.julialang.org/u/snowgum)\
**Replies:** 4\
**Last updated:** [September 5, 2022, 7:28pm UTC](https://discourse.julialang.org/t/advice-on-speeding-up-highly-parallel-and-i-o-intensive-code/86795 "2022-09-05T19:28:08Z")

</div>

I am solving a problem that is highly parallel, and wondering how to make it as efficient as possible in Julia. I need to run a function (let’s call it do\_work) on 1D slices of 3D arrays written on disk. For example, if …

---

## [BenchmarkTools for benchmarking thread scalability of functions](https://discourse.julialang.org/t/benchmarktools-for-benchmarking-thread-scalability-of-functions/86711)

<div class="topic-metadata">

**Author:** [@gerhardu](https://discourse.julialang.org/u/gerhardu)\
**Replies:** 6\
**Last updated:** [September 5, 2022, 11:12am UTC](https://discourse.julialang.org/t/benchmarktools-for-benchmarking-thread-scalability-of-functions/86711 "2022-09-05T11:12:39Z")

</div>

I use BenchmarkTools.jl to benchmark functions in my code. That works great! But what I am missing is a good interface to analyze thread scalability. Is there an option in BenchmarkTools.jl or another package? As far a…

---

## [Zygote and StaticArrays](https://discourse.julialang.org/t/zygote-and-staticarrays/86176)

<div class="topic-metadata">

**Author:** [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Replies:** 12\
**Last updated:** [September 5, 2022, 5:09am UTC](https://discourse.julialang.org/t/zygote-and-staticarrays/86176 "2022-09-05T05:09:08Z")

</div>

I am currently evaluating Zygote. My “usecase” is maybe a bit different from what has driven Zygote’s development: I want to take the gradient of scalar-valued functions of 10 to 100 inputes, but I will compute millions…

---

## [Is @evalpoly needed anymore?](https://discourse.julialang.org/t/is-evalpoly-needed-anymore/86732)

<div class="topic-metadata">

**Author:** [@shmiggles](https://discourse.julialang.org/u/shmiggles)\
**Replies:** 1\
**Last updated:** [September 3, 2022, 4:14pm UTC](https://discourse.julialang.org/t/is-evalpoly-needed-anymore/86732 "2022-09-03T16:14:45Z")

</div>

Julia provides two ways of polynomial evaluation: one as a function (evalpoly) and the other as a macro (@evalpoly). My understanding is that the macro can (sometimes) be faster than the function due to inlining. However…

---

## [How to avoid allocations when reading arbitrary keys from a NamedTuple?](https://discourse.julialang.org/t/how-to-avoid-allocations-when-reading-arbitrary-keys-from-a-namedtuple/71806)

<div class="topic-metadata">

**Author:** [@mattwigway](https://discourse.julialang.org/u/mattwigway)\
**Replies:** 8\
**Last updated:** [September 2, 2022, 9:00pm UTC](https://discourse.julialang.org/t/how-to-avoid-allocations-when-reading-arbitrary-keys-from-a-namedtuple/71806 "2022-09-02T21:00:01Z")

</div>

I have a situation where I’m processing rowwise data from a JuliaDB table in a reducer. I’m having trouble with type stability, because my function looks like: function (row, col) value = row\[col\] ...do things wit…

---

## [Any small example of a queue like system, where a function is automatically executed when a new item pops in the queue?](https://discourse.julialang.org/t/any-small-example-of-a-queue-like-system-where-a-function-is-automatically-executed-when-a-new-item-pops-in-the-queue/86616)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 12\
**Last updated:** [September 2, 2022, 8:31pm UTC](https://discourse.julialang.org/t/any-small-example-of-a-queue-like-system-where-a-function-is-automatically-executed-when-a-new-item-pops-in-the-queue/86616 "2022-09-02T20:31:38Z")

</div>

Hello! I have some Julia code which detects when new files are made in a folder. The name of these files are then passed to a vector. Whenever a new item enters the vector, I wish to have a function detect this and run …

---

## [Priority queue choice](https://discourse.julialang.org/t/priority-queue-choice/42783)

<div class="topic-metadata">

**Author:** [@mschauer](https://discourse.julialang.org/u/mschauer)\
**Replies:** 24\
**Last updated:** [September 1, 2022, 6:49pm UTC](https://discourse.julialang.org/t/priority-queue-choice/42783 "2022-09-01T18:49:44Z")

</div>

I need a performant implementation of a PriorityQueue{Int,Float64}. For Int you can think pixels and for Float64 think random times. Is this PriorityQueue from DataStructures.jl the right thing or are there maybe other …

---

## [Fast(er) priority queues?](https://discourse.julialang.org/t/fast-er-priority-queues/81269)

<div class="topic-metadata">

**Author:** [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Replies:** 20\
**Last updated:** [September 1, 2022, 6:47pm UTC](https://discourse.julialang.org/t/fast-er-priority-queues/81269 "2022-09-01T18:47:11Z")

</div>

Hi there! Recently I wanted to accelerate Dijkstra’s algorithm, and I ended up implementing a really dumb priority queue based on two sorted vectors. Surprisingly, in some settings, it significantly speeds up the algori…

---

## [Container of mutable structs without 100x slowdown?](https://discourse.julialang.org/t/container-of-mutable-structs-without-100x-slowdown/86629)

<div class="topic-metadata">

**Author:** [@robsmith11](https://discourse.julialang.org/u/robsmith11)\
**Replies:** 7\
**Last updated:** [September 1, 2022, 12:03pm UTC](https://discourse.julialang.org/t/container-of-mutable-structs-without-100x-slowdown/86629 "2022-09-01T12:03:08Z")

</div>

It seems like when mutable structs are stored in any kind of container, Julia is unable to optimize them onto the stack or even to a packed buffer on the heap. It always allocates new memory on the heap for each individ…

---

## [Directly modify compiled method without recompilation](https://discourse.julialang.org/t/directly-modify-compiled-method-without-recompilation/86564)

<div class="topic-metadata">

**Author:** [@FireCrumb](https://discourse.julialang.org/u/FireCrumb)\
**Replies:** 25\
**Last updated:** [August 31, 2022, 9:05pm UTC](https://discourse.julialang.org/t/directly-modify-compiled-method-without-recompilation/86564 "2022-08-31T21:05:45Z")

</div>

Question – how can I evaluate an expression into a method, compile it, and then directly manipulate the compiled version (lower than AST) to create another slightly modified method faster than re-compilation? I need to …

---

## [Is it possible to precompile a function in Julia?](https://discourse.julialang.org/t/is-it-possible-to-precompile-a-function-in-julia/86578)

<div class="topic-metadata">

**Author:** [@valperez](https://discourse.julialang.org/u/valperez)\
**Replies:** 2\
**Last updated:** [August 31, 2022, 10:02pm UTC](https://discourse.julialang.org/t/is-it-possible-to-precompile-a-function-in-julia/86578 "2022-08-31T22:02:05Z")

</div>

Hi there, I’m trying to make my Julia code as fast as possible and a friend of mine recommended using precompile. I have read about it but I’m not sure how to proceed, do I precompile the package I’m using o the functio…

---

## [XML syntax highlighting when printing to terminal?](https://discourse.julialang.org/t/xml-syntax-highlighting-when-printing-to-terminal/86414)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 1\
**Last updated:** [August 30, 2022, 8:36pm UTC](https://discourse.julialang.org/t/xml-syntax-highlighting-when-printing-to-terminal/86414 "2022-08-30T20:36:05Z")

</div>

I was curious about whether or not there is a way to automatically color format XML statements such as (all grey in terminal): \<simulationdomain\> \<posmin x="default" y="default" z="default"/\> \<posmax x="default" y="…

---

## [Resource usage in versions 1.7.2 and 1.8.0](https://discourse.julialang.org/t/resource-usage-in-versions-1-7-2-and-1-8-0/86111)

<div class="topic-metadata">

**Author:** [@marllos](https://discourse.julialang.org/u/marllos)\
**Replies:** 19\
**Last updated:** [August 30, 2022, 7:58pm UTC](https://discourse.julialang.org/t/resource-usage-in-versions-1-7-2-and-1-8-0/86111 "2022-08-30T19:58:54Z")

</div>

Hello everyone. I updated Julia from version 1.7.2 to 1.8.0 and had a surprise: a code that used 2 GB of RAM, now uses 10 GB, and the number of subprocesses (htop) also increased from 8 to 64! Is this normal? I was a bit…

---

## [Are julia -p x and addprocs(x) equivalent?](https://discourse.julialang.org/t/are-julia-p-x-and-addprocs-x-equivalent/86554)

<div class="topic-metadata">

**Author:** [@structural](https://discourse.julialang.org/u/structural)\
**Replies:** 1\
**Last updated:** [August 30, 2022, 7:08pm UTC](https://discourse.julialang.org/t/are-julia-p-x-and-addprocs-x-equivalent/86554 "2022-08-30T19:08:52Z")

</div>

I want to use multiple threads on multiple workers. Will the two sets of commands produce equivalent results? export JULIA\_NUM\_THREADS=20 julia addprocs(12) export JULIA\_NUM\_THREADS=20 julia -p 12

---

## [Most effective way to check if neighboring values in a matrix are the same](https://discourse.julialang.org/t/most-effective-way-to-check-if-neighboring-values-in-a-matrix-are-the-same/86291)

<div class="topic-metadata">

**Author:** [@phantom](https://discourse.julialang.org/u/phantom)\
**Replies:** 19\
**Last updated:** [August 30, 2022, 12:07am UTC](https://discourse.julialang.org/t/most-effective-way-to-check-if-neighboring-values-in-a-matrix-are-the-same/86291 "2022-08-30T00:07:01Z")

</div>

Suppose A is the following matrix. 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0 1.0 1.0 0.0 0.0 0.0 1.0 1.0 0.0 1.0 0.0 1.0 1.0 1.0 1.0 1.0 I want to check each row of the matrix for the number of times …

---

## [Force type stability (over block of code)](https://discourse.julialang.org/t/force-type-stability-over-block-of-code/86501)

<div class="topic-metadata">

**Author:** [@Marcell\_Havlik](https://discourse.julialang.org/u/Marcell_Havlik)\
**Replies:** 1\
**Last updated:** [August 29, 2022, 2:41pm UTC](https://discourse.julialang.org/t/force-type-stability-over-block-of-code/86501 "2022-08-29T14:41:43Z")

</div>

Hi Julianners, I saw many attempt on type table block. @code\_warntype to trace them. But in the end I don’t find what is the way to force type stability over a specific block. I want the code to stop or do a warn mes…

---

## [Avoiding allocation when accessing fields of a StructArray inside a Struct](https://discourse.julialang.org/t/avoiding-allocation-when-accessing-fields-of-a-structarray-inside-a-struct/86168)

<div class="topic-metadata">

**Author:** [@cuihantao](https://discourse.julialang.org/u/cuihantao)\
**Replies:** 3\
**Last updated:** [August 23, 2022, 7:42pm UTC](https://discourse.julialang.org/t/avoiding-allocation-when-accessing-fields-of-a-structarray-inside-a-struct/86168 "2022-08-23T19:42:17Z")

</div>

Let me start with the MWE using StructArrays using BenchmarkTools # the struct to be converted to StructArray struct Foo1 a::Float64 b::Float64 end a = \[1.0, 2.0\] b = \[3.0, 4.0\] foo1 = StructArray{Foo1}(a=a, …

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

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