# Performance

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

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

**Page:** 67

---

## [Minimising top-level project latency](https://discourse.julialang.org/t/minimising-top-level-project-latency/80546)

<div class="topic-metadata">

**Author:** [@danielsoutar](https://discourse.julialang.org/u/danielsoutar)\
**Replies:** 3\
**Last updated:** [May 5, 2022, 5:25pm UTC](https://discourse.julialang.org/t/minimising-top-level-project-latency/80546 "2022-05-05T17:25:03Z")

</div>

If I want to use a third-party package with minimal latency overhead, I can do so by having it precompiled. However, I am in the top-level project in a codebase that implements a complex pipeline and get this error when i…

---

## [Apples to apples comparison of A\\b with Float64 and Float16 on A64FX](https://discourse.julialang.org/t/apples-to-apples-comparison-of-a-b-with-float64-and-float16-on-a64fx/76096)

<div class="topic-metadata">

**Author:** [@bburnett](https://discourse.julialang.org/u/bburnett)\
**Replies:** 12\
**Last updated:** [May 2, 2022, 11:37pm UTC](https://discourse.julialang.org/t/apples-to-apples-comparison-of-a-b-with-float64-and-float16-on-a64fx/76096 "2022-05-02T23:37:16Z")

</div>

Hi all, sorry if this is a weird newbie question but I’ll go ahead and ask in hopes to learn something. I recently followed the advice in this github issues page to build Julia to not escalate Float16 to Float32 for arit…

---

## [Feedback for efficiency of Sparse Matrix operations](https://discourse.julialang.org/t/feedback-for-efficiency-of-sparse-matrix-operations/80362)

<div class="topic-metadata">

**Author:** [@danielw2904](https://discourse.julialang.org/u/danielw2904)\
**Replies:** 7\
**Last updated:** [May 2, 2022, 4:24pm UTC](https://discourse.julialang.org/t/feedback-for-efficiency-of-sparse-matrix-operations/80362 "2022-05-02T16:24:57Z")

</div>

This is my first time working with SparseArrays in Julia. I needed a few operations and was wondering if I am as efficient as I can be. I do want to preserve the original matrices (explicitly not doing anything in-place)…

---

## [Why is closure slower than handmade callable struct?](https://discourse.julialang.org/t/why-is-closure-slower-than-handmade-callable-struct/80361)

<div class="topic-metadata">

**Author:** [@FedericoStra](https://discourse.julialang.org/u/FedericoStra)\
**Replies:** 4\
**Last updated:** [May 2, 2022, 1:49pm UTC](https://discourse.julialang.org/t/why-is-closure-slower-than-handmade-callable-struct/80361 "2022-05-02T13:49:38Z")

</div>

I’m having a hard time trying to understand why in the following code a closure is slower than an equivalent hand-made callable struct. using BenchmarkTools using Interpolations using LinearAlgebra: norm using StaticArr…

---

## [Converting default Float type to Float32](https://discourse.julialang.org/t/converting-default-float-type-to-float32/80326)

<div class="topic-metadata">

**Author:** [@Phuntsho](https://discourse.julialang.org/u/Phuntsho)\
**Replies:** 7\
**Last updated:** [May 2, 2022, 7:25am UTC](https://discourse.julialang.org/t/converting-default-float-type-to-float32/80326 "2022-05-02T07:25:52Z")

</div>

I have noticed on my system that whenever I define CuArrays, I get Float64 as default. Is there a way to change the default to Float32, i.e. without specifying the type every time I define CuArrays? I want to get Float32…

---

## [Performance of writing binary files](https://discourse.julialang.org/t/performance-of-writing-binary-files/80278)

<div class="topic-metadata">

**Author:** [@mkoculak](https://discourse.julialang.org/u/mkoculak)\
**Replies:** 2\
**Last updated:** [April 30, 2022, 9:53pm UTC](https://discourse.julialang.org/t/performance-of-writing-binary-files/80278 "2022-04-30T21:53:07Z")

</div>

I am creating a function to write binary data (a data array) to a file. First, I have just reversed the reading function (which reads data almost one byte at a time) and performed a sequential write, but noticed it took…

---

## [Pair{Symbol, Function} slower than equivalent non-parametric type](https://discourse.julialang.org/t/pair-symbol-function-slower-than-equivalent-non-parametric-type/80295)

<div class="topic-metadata">

**Author:** [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Replies:** 4\
**Last updated:** [April 30, 2022, 9:21pm UTC](https://discourse.julialang.org/t/pair-symbol-function-slower-than-equivalent-non-parametric-type/80295 "2022-04-30T21:21:39Z")

</div>

Consider a list of symbol and functions: julia\> macro big\_closure\_list(T, n) esc(:($T\[$(\[:($T(:x, ()-\>$(Symbol(:v, i)))) for i in 1:n\]...)\])) end; julia\> @macroexpand @big\_closure\_list(Pair,…

---

## [Perform a multi-column, multi-dimensional search quickly](https://discourse.julialang.org/t/perform-a-multi-column-multi-dimensional-search-quickly/75113)

<div class="topic-metadata">

**Author:** [@Hikaru\_Matsuoka](https://discourse.julialang.org/u/Hikaru_Matsuoka)\
**Replies:** 9\
**Last updated:** [April 30, 2022, 8:22pm UTC](https://discourse.julialang.org/t/perform-a-multi-column-multi-dimensional-search-quickly/75113 "2022-04-30T20:22:04Z")

</div>

I would like to perform a multi-column search from a multi-dimensional matrix like the one below, is there a fast way to do this? (In the example below, I want to get the rows next to -5.0 3.0 2.0) Test\_matrix = \[-5.0…

---

## [What's the largest factors in latency?](https://discourse.julialang.org/t/whats-the-largest-factors-in-latency/80302)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 0\
**Last updated:** [April 30, 2022, 5:57pm UTC](https://discourse.julialang.org/t/whats-the-largest-factors-in-latency/80302 "2022-04-30T17:57:28Z")

</div>

A) For startup of Julia itself B) For running scripts I know some workaround for B) such as -O0 or --compile=min which often goes too far (I’m looking for a middle-ground with as fast startup as Python), is there any r…

---

## [Why is this MLP slower in Flux than in TensorFlow?](https://discourse.julialang.org/t/why-is-this-mlp-slower-in-flux-than-in-tensorflow/80272)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 5\
**Last updated:** [April 30, 2022, 3:39pm UTC](https://discourse.julialang.org/t/why-is-this-mlp-slower-in-flux-than-in-tensorflow/80272 "2022-04-30T15:39:57Z")

</div>

I am working with some MLPs and noticed that TensorFlow is much faster than Flux. In the examples below, Flux requires about 20 minutes and TensorFlow requires just over a minute. Am I doing something incorrectly? Thank…

---

## [Performance of resize! vs pre-allocating with zeros(...)](https://discourse.julialang.org/t/performance-of-resize-vs-pre-allocating-with-zeros/80258)

<div class="topic-metadata">

**Author:** [@fcdimitr](https://discourse.julialang.org/u/fcdimitr)\
**Replies:** 9\
**Last updated:** [April 29, 2022, 8:28pm UTC](https://discourse.julialang.org/t/performance-of-resize-vs-pre-allocating-with-zeros/80258 "2022-04-29T20:28:18Z")

</div>

I observe a factor of 5x time difference in writing over a vector with two different preallocation strategies. Using x = zeros(Int64, n) Using x = Int64\[\]; resize!(x,n) The benchmark code is bellow using BenchmarkT…

---

## [The best way to pass intermediate value to auxiliary functions](https://discourse.julialang.org/t/the-best-way-to-pass-intermediate-value-to-auxiliary-functions/80254)

<div class="topic-metadata">

**Author:** [@wujinq](https://discourse.julialang.org/u/wujinq)\
**Replies:** 2\
**Last updated:** [April 29, 2022, 2:19pm UTC](https://discourse.julialang.org/t/the-best-way-to-pass-intermediate-value-to-auxiliary-functions/80254 "2022-04-29T14:19:15Z")

</div>

I’m writing a Monte Carlo program and I need a lot of auxiliary function dependent on one or two fields of the parameter model of the main function sweep!(model) in the following way: function sweep!(model, n\_sweep) …

---

## [How to understand the ProfileView output](https://discourse.julialang.org/t/how-to-understand-the-profileview-output/79968)

<div class="topic-metadata">

**Author:** [@Himbeersternchen](https://discourse.julialang.org/u/Himbeersternchen)\
**Replies:** 3\
**Last updated:** [April 29, 2022, 9:52am UTC](https://discourse.julialang.org/t/how-to-understand-the-profileview-output/79968 "2022-04-29T09:52:54Z")

</div>

Hello Everyone, Similar as this topic, i want to understand the profileview output. The test code is as Following: init() = begin n = 250 a1 = Vector{Vector{Float64}}(undef, n) for i in 1:n a1\[i\] …

---

## [Improve performance of CRRA utility function](https://discourse.julialang.org/t/improve-performance-of-crra-utility-function/80229)

<div class="topic-metadata">

**Author:** [@fredrikpaues](https://discourse.julialang.org/u/fredrikpaues)\
**Replies:** 6\
**Last updated:** [April 29, 2022, 8:28am UTC](https://discourse.julialang.org/t/improve-performance-of-crra-utility-function/80229 "2022-04-29T08:28:26Z")

</div>

I want to improve the performance of u in the code below. I have tried rewriting the formula and inlining the broadcasting, which helped some. But when tried using @turbo from LoopVectorization.jl something goes wrong an…

---

## [Data Storage Quo Vadis under Julia: HDF5 - JLD2 - MAT -](https://discourse.julialang.org/t/data-storage-quo-vadis-under-julia-hdf5-jld2-mat/80159)

<div class="topic-metadata">

**Author:** [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Replies:** 0\
**Last updated:** [April 27, 2022, 5:35pm UTC](https://discourse.julialang.org/t/data-storage-quo-vadis-under-julia-hdf5-jld2-mat/80159 "2022-04-27T17:35:45Z")

</div>

The good news: Julia can beat the phyton data-compression package “hdf5storage”. But it is useful to have a closer look into the matter. And, if you store data, it should be better or at least as good as hdf5storage. …

---

## [Performance of for loop vs. broadcast](https://discourse.julialang.org/t/performance-of-for-loop-vs-broadcast/80211)

<div class="topic-metadata">

**Author:** [@Jake](https://discourse.julialang.org/u/Jake)\
**Replies:** 8\
**Last updated:** [April 28, 2022, 8:59pm UTC](https://discourse.julialang.org/t/performance-of-for-loop-vs-broadcast/80211 "2022-04-28T20:59:15Z")

</div>

In scaling a vector I tried a number of implementations to determine the best performance. Initially I implemented it with global variables and a for loop. Then reading the performance tips (and discourse) I realized t…

---

## [Alllocations in a reduction over a Tuple](https://discourse.julialang.org/t/alllocations-in-a-reduction-over-a-tuple/80083)

<div class="topic-metadata">

**Author:** [@ademonts](https://discourse.julialang.org/u/ademonts)\
**Replies:** 2\
**Last updated:** [April 28, 2022, 1:29pm UTC](https://discourse.julialang.org/t/alllocations-in-a-reduction-over-a-tuple/80083 "2022-04-28T13:29:06Z")

</div>

I’m trying to make a recursive reduction over a Tuple that calculates the inverse of the reduction of a nested Tuple everytime it encounters one. I.e. for x=(1,(2,3)), foo(x) should compute f(1)+\\frac{1}{f(2)+f(3)}. The …

---

## [How to best use DistributedArray.jl](https://discourse.julialang.org/t/how-to-best-use-distributedarray-jl/79848)

<div class="topic-metadata">

**Author:** [@ultrapoci](https://discourse.julialang.org/u/ultrapoci)\
**Replies:** 1\
**Last updated:** [April 28, 2022, 1:16pm UTC](https://discourse.julialang.org/t/how-to-best-use-distributedarray-jl/79848 "2022-04-28T13:16:38Z")

</div>

I have a couple of questions about Distributed arrays. I have to simulate a lattice, and for every point of this lattice I have to save a collection of matrices. This is because I’m interested in the links connecting e…

---

## [ReinterpretedArray Performance (even worse on 1.8)](https://discourse.julialang.org/t/reinterpretedarray-performance-even-worse-on-1-8/80102)

<div class="topic-metadata">

**Author:** [@cortner](https://discourse.julialang.org/u/cortner)\
**Replies:** 26\
**Last updated:** [April 28, 2022, 6:16am UTC](https://discourse.julialang.org/t/reinterpretedarray-performance-even-worse-on-1-8/80102 "2022-04-28T06:16:45Z")

</div>

I’d like to use reinterpreted arrays to write into and read from an array. Here is a little script that is a bit oversimplified but not too far from my real use-case. using BenchmarkTools function cheb!(A, x) A\[1\] =…

---

## [Slow multiplication of transpose of sparse matrix](https://discourse.julialang.org/t/slow-multiplication-of-transpose-of-sparse-matrix/80153)

<div class="topic-metadata">

**Author:** [@andresdrenik](https://discourse.julialang.org/u/andresdrenik)\
**Replies:** 5\
**Last updated:** [April 27, 2022, 7:05pm UTC](https://discourse.julialang.org/t/slow-multiplication-of-transpose-of-sparse-matrix/80153 "2022-04-27T19:05:49Z")

</div>

I’m having speed issues multiplying the transpose of a sparse matrix with a column vector. In my code the matrix A is 501×501 SparseMatrixCSC{Float64, Integer} with 1501 stored entries: ⠻⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸ ⠀⠈⠻⣦⡀⠀⠀⠀⠀…

---

## [Why are ref's in structs type unstable?](https://discourse.julialang.org/t/why-are-refs-in-structs-type-unstable/80041)

<div class="topic-metadata">

**Author:** [@tr00](https://discourse.julialang.org/u/tr00)\
**Replies:** 4\
**Last updated:** [April 26, 2022, 2:39pm UTC](https://discourse.julialang.org/t/why-are-refs-in-structs-type-unstable/80041 "2022-04-26T14:39:15Z")

</div>

Hello Julia Community, I’ve just came across a small code example which isn’t type stable according to @code\_warntype but clearly should be, at least according to my understanding of refs. Here is the example: julia\> …

---

## [Handling multiple files at the same time](https://discourse.julialang.org/t/handling-multiple-files-at-the-same-time/80037)

<div class="topic-metadata">

**Author:** [@Drachta](https://discourse.julialang.org/u/Drachta)\
**Replies:** 6\
**Last updated:** [April 26, 2022, 10:49am UTC](https://discourse.julialang.org/t/handling-multiple-files-at-the-same-time/80037 "2022-04-26T10:49:13Z")

</div>

Hello, I wish to replace some occurrence in a file and save it under a new file. The following does what I need, but it reads the entire file before making the substitution. Is there a better way to do this ? some\_var…

---

## [Dependencies "4 skipped during auto due to previous errors"](https://discourse.julialang.org/t/dependencies-4-skipped-during-auto-due-to-previous-errors/79862)

<div class="topic-metadata">

**Author:** [@munozdjp](https://discourse.julialang.org/u/munozdjp)\
**Replies:** 9\
**Last updated:** [April 26, 2022, 7:48am UTC](https://discourse.julialang.org/t/dependencies-4-skipped-during-auto-due-to-previous-errors/79862 "2022-04-26T07:48:00Z")

</div>

When I follow the tutorial on : When I instantiate in julia: (image attached): I obtain the following errors: Do someone knows how to fix the problem of these dependencies?

---

## [Why are my higher order functions a million times slower than they should be?](https://discourse.julialang.org/t/why-are-my-higher-order-functions-a-million-times-slower-than-they-should-be/80021)

<div class="topic-metadata">

**Author:** [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Replies:** 7\
**Last updated:** [April 26, 2022, 12:41am UTC](https://discourse.julialang.org/t/why-are-my-higher-order-functions-a-million-times-slower-than-they-should-be/80021 "2022-04-26T00:41:25Z")

</div>

While this example looks highly constructed, I ran into this performance issue in real code and got this as a MWE. I expect a slight penalty for calling a function dynamically (i.e. \_slow instead of the constant slow) bu…

---

## [Will Julia ever fix its "using ..." latency problems?](https://discourse.julialang.org/t/will-julia-ever-fix-its-using-latency-problems/50659)

<div class="topic-metadata">

**Author:** [@Volker\_Weissmann](https://discourse.julialang.org/u/Volker_Weissmann)\
**Replies:** 68\
**Last updated:** [April 25, 2022, 2:40pm UTC](https://discourse.julialang.org/t/will-julia-ever-fix-its-using-latency-problems/50659 "2022-04-25T14:40:11Z")

</div>

The “using …” command is extremely slow: julia\> @time using Plots 12.731850 seconds (17.25 M allocations: 976.326 MiB, 3.64% gc time) julia\> @time using DifferentialEquations 34.780873 seconds (41.90 M allocations: …

---

## [Updating a function in a type, where the function is a parameter](https://discourse.julialang.org/t/updating-a-function-in-a-type-where-the-function-is-a-parameter/79933)

<div class="topic-metadata">

**Author:** [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Replies:** 26\
**Last updated:** [April 25, 2022, 8:30am UTC](https://discourse.julialang.org/t/updating-a-function-in-a-type-where-the-function-is-a-parameter/79933 "2022-04-25T08:30:03Z")

</div>

I just ran into a problem with my idea to have performant code and updating a struct. Assume we have a struct (already mutable to change it) mutable struct MyStruct{F} f::F end where f is a function (in my applica…

---

## [JIT compilation does not avoid useless computations](https://discourse.julialang.org/t/jit-compilation-does-not-avoid-useless-computations/79939)

<div class="topic-metadata">

**Author:** [@alequa](https://discourse.julialang.org/u/alequa)\
**Replies:** 6\
**Last updated:** [April 24, 2022, 5:54pm UTC](https://discourse.julialang.org/t/jit-compilation-does-not-avoid-useless-computations/79939 "2022-04-24T17:54:36Z")

</div>

Hello, I had a naïve idea bout the JIT compiler. This is that when I define a function with independent return cases it will know with computations to perform, that is: function test(z::Bool=true,array::Vector=rand(10…

---

## [Fast Parallel ROC AUC Calculation](https://discourse.julialang.org/t/fast-parallel-roc-auc-calculation/79918)

<div class="topic-metadata">

**Author:** [@brianhempel](https://discourse.julialang.org/u/brianhempel)\
**Replies:** 1\
**Last updated:** [April 24, 2022, 12:15am UTC](https://discourse.julialang.org/t/fast-parallel-roc-auc-calculation/79918 "2022-04-24T00:15:19Z")

</div>

I’m trying to calculate the receiver operator characteristic area under curve for large amounts of data. I’ve parallelized the sorting, but I’ve got too much SARS-CoV2 in me at the moment to figure out the math to parall…

---

## [Non-allocating matrix inversion](https://discourse.julialang.org/t/non-allocating-matrix-inversion/62264)

<div class="topic-metadata">

**Author:** [@nandoconde](https://discourse.julialang.org/u/nandoconde)\
**Replies:** 13\
**Last updated:** [April 23, 2022, 9:56pm UTC](https://discourse.julialang.org/t/non-allocating-matrix-inversion/62264 "2022-04-23T21:56:43Z")

</div>

Is there any way to perform matrix inversion? Say I have a Vector of Matrix where I want to perform the inverse, and then save them in the same spot where they came from in the array. I had thought of this: function bu…

---

## [Precompiling non-inferrable calls](https://discourse.julialang.org/t/precompiling-non-inferrable-calls/79771)

<div class="topic-metadata">

**Author:** [@rikh](https://discourse.julialang.org/u/rikh)\
**Replies:** 2\
**Last updated:** [April 23, 2022, 4:54pm UTC](https://discourse.julialang.org/t/precompiling-non-inferrable-calls/79771 "2022-04-23T16:54:21Z")

</div>

Let me start of by saying that precompile is great. It can move a lot of compilation time from the package loading to the precompilation stage. For people unfamiliar with precompile, when calling it on a function, it pr…

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

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