# Performance

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

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

**Page:** 51

---

## [Median calculation performing better than expected](https://discourse.julialang.org/t/median-calculation-performing-better-than-expected/93174)

<div class="topic-metadata">

**Author:** [@Nino\_Rode](https://discourse.julialang.org/u/Nino_Rode)\
**Replies:** 3\
**Last updated:** [January 18, 2023, 6:19pm UTC](https://discourse.julialang.org/t/median-calculation-performing-better-than-expected/93174 "2023-01-18T18:19:43Z")

</div>

I have an “it works … why?” question. I hope this is the right place. I’m trying to learn to write julia code to have as good performance as possible (yes, I’m new with julia). Most of the time, I’m trying to reproduce …

---

## [Improving performance of item response model in Turing.jl](https://discourse.julialang.org/t/improving-performance-of-item-response-model-in-turing-jl/86249)

<div class="topic-metadata">

**Author:** [@p-gw](https://discourse.julialang.org/u/p-gw)\
**Replies:** 23\
**Last updated:** [January 18, 2023, 3:06pm UTC](https://discourse.julialang.org/t/improving-performance-of-item-response-model-in-turing-jl/86249 "2023-01-18T15:06:52Z")

</div>

Hi everyone, I am trying to fit an item response model in Turing.jl and have some questions regarding performance. This question is related to Making Turing Fast with large numbers of parameters? and in fact is referenc…

---

## [Help me understand vector initialization](https://discourse.julialang.org/t/help-me-understand-vector-initialization/93129)

<div class="topic-metadata">

**Author:** [@udax](https://discourse.julialang.org/u/udax)\
**Replies:** 7\
**Last updated:** [January 18, 2023, 11:01am UTC](https://discourse.julialang.org/t/help-me-understand-vector-initialization/93129 "2023-01-18T11:01:50Z")

</div>

Here is a MWE of a problem that I am facing. In method 1, the array “arr” gets initialized correctly, but it seems very inelegant. In the second method, the array “brr” often does not get initialized correctly. for k = …

---

## [Not easy to add utility packages to env](https://discourse.julialang.org/t/not-easy-to-add-utility-packages-to-env/93068)

<div class="topic-metadata">

**Author:** [@tictaccat](https://discourse.julialang.org/u/tictaccat)\
**Replies:** 22\
**Last updated:** [January 18, 2023, 6:32am UTC](https://discourse.julialang.org/t/not-easy-to-add-utility-packages-to-env/93068 "2023-01-18T06:32:10Z")

</div>

Let’s say I’m trying to edit someone’s package. While debugging my code using the environment provided by the package’s Project.toml, I realize it would be useful to plot something. So I’d like to add Plots.jl. However, …

---

## [Double precompilation](https://discourse.julialang.org/t/double-precompilation/93100)

<div class="topic-metadata">

**Author:** [@bernardofpc](https://discourse.julialang.org/u/bernardofpc)\
**Replies:** 1\
**Last updated:** [January 17, 2023, 3:13pm UTC](https://discourse.julialang.org/t/double-precompilation/93100 "2023-01-17T15:13:23Z")

</div>

I just downloaded a Project.toml for a project I’m working on another computer. I went through Pkg.instantiate(), Pkg.precompile() and then started using some packages. To my surprise, JuMP was precompiled again. Is t…

---

## [How can I limit the number of CPU cores Julia has access to?](https://discourse.julialang.org/t/how-can-i-limit-the-number-of-cpu-cores-julia-has-access-to/93082)

<div class="topic-metadata">

**Author:** [@Ashley](https://discourse.julialang.org/u/Ashley)\
**Replies:** 1\
**Last updated:** [January 17, 2023, 10:57am UTC](https://discourse.julialang.org/t/how-can-i-limit-the-number-of-cpu-cores-julia-has-access-to/93082 "2023-01-17T10:57:01Z")

</div>

I am using a PBS cluster system where I request a number of CPU cores for a job. However, my Julia program seems to use more than what I allocate, causing the job to be killed by the manager! I have tried setting JULIA\_…

---

## [Random memory access performance - how to hint compiler/runtime to preload/cache/plan](https://discourse.julialang.org/t/random-memory-access-performance-how-to-hint-compiler-runtime-to-preload-cache-plan/93046)

<div class="topic-metadata">

**Author:** [@FireCrumb](https://discourse.julialang.org/u/FireCrumb)\
**Replies:** 0\
**Last updated:** [January 16, 2023, 8:04pm UTC](https://discourse.julialang.org/t/random-memory-access-performance-how-to-hint-compiler-runtime-to-preload-cache-plan/93046 "2023-01-16T20:04:42Z")

</div>

Hi, I have some constant size matrices (so I use StaticArrays package, verified it’s faster than Array/Vector) which I access many times randomly in a loop. After random reads/writes, I need to copy a part of one array…

---

## [Precompilation failure caused by package dependency version](https://discourse.julialang.org/t/precompilation-failure-caused-by-package-dependency-version/92995)

<div class="topic-metadata">

**Author:** [@Rex\_Wang](https://discourse.julialang.org/u/Rex_Wang)\
**Replies:** 1\
**Last updated:** [January 15, 2023, 5:10pm UTC](https://discourse.julialang.org/t/precompilation-failure-caused-by-package-dependency-version/92995 "2023-01-15T17:10:08Z")

</div>

I am trying to install two packages ClimeTools and MultivariateStats. The former requires version 0.32.2 of the package StatsBase while the latter requires 0.33.21. This results in a conflict and prevents me from success…

---

## [Unexpected comma in array expression Stacktrace:](https://discourse.julialang.org/t/unexpected-comma-in-array-expression-stacktrace/92993)

<div class="topic-metadata">

**Author:** [@priyanshujiiii](https://discourse.julialang.org/u/priyanshujiiii)\
**Replies:** 1\
**Last updated:** [January 15, 2023, 2:02pm UTC](https://discourse.julialang.org/t/unexpected-comma-in-array-expression-stacktrace/92993 "2023-01-15T14:02:47Z")

</div>

---

## [How to efficiently split StaticArrays into columns?](https://discourse.julialang.org/t/how-to-efficiently-split-staticarrays-into-columns/92990)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 6\
**Last updated:** [January 15, 2023, 1:35pm UTC](https://discourse.julialang.org/t/how-to-efficiently-split-staticarrays-into-columns/92990 "2023-01-15T13:35:47Z")

</div>

Hi! Suppose I have: using StaticArrays Values = rand(SVector{3,Float64},10^6) I know that I can split this into components as such: ValuesX = getindex.(Values,1) @benchmark getindex.($Values,1) BenchmarkTools.Tria…

---

## [Why does this type instability lead to allocations?](https://discourse.julialang.org/t/why-does-this-type-instability-lead-to-allocations/92821)

<div class="topic-metadata">

**Author:** [@user664303](https://discourse.julialang.org/u/user664303)\
**Replies:** 3\
**Last updated:** [January 13, 2023, 6:48pm UTC](https://discourse.julialang.org/t/why-does-this-type-instability-lead-to-allocations/92821 "2023-01-13T18:48:15Z")

</div>

I previously posted a question about dynamic dispatch leading to allocations. The answer I got was that the type instability that leads to dynamic dispatch also leads to the allocations - at least that’s what I understoo…

---

## [Need help implementing non-allocating normal distribution with StaticArrays](https://discourse.julialang.org/t/need-help-implementing-non-allocating-normal-distribution-with-staticarrays/92919)

<div class="topic-metadata">

**Author:** [@vpetukhov](https://discourse.julialang.org/u/vpetukhov)\
**Replies:** 2\
**Last updated:** [January 13, 2023, 2:12pm UTC](https://discourse.julialang.org/t/need-help-implementing-non-allocating-normal-distribution-with-staticarrays/92919 "2023-01-13T14:12:37Z")

</div>

I’m trying to implement a zero-allocating version of a normal distribution pdf, but get some unexpected allocations. Below is my code for a script ./test\_allocations.jl, which could be ran to test allocations quickly. u…

---

## [How to achieve perfect scaling with Threads (Julia 1.7.1)](https://discourse.julialang.org/t/how-to-achieve-perfect-scaling-with-threads-julia-1-7-1/92603)

<div class="topic-metadata">

**Author:** [@Salmon](https://discourse.julialang.org/u/Salmon)\
**Replies:** 33\
**Last updated:** [January 13, 2023, 11:07am UTC](https://discourse.julialang.org/t/how-to-achieve-perfect-scaling-with-threads-julia-1-7-1/92603 "2023-01-13T11:07:20Z")

</div>

Hi everyone, I am currently investigating a scaling bottleneck in one of my codes which seems a bit elusive to me. In my investigation to get a MWE, I have tried to produce a somewhat representative example, which shou…

---

## [Why isn't SnoopPrecompile being able to fully compile the calls in this case?](https://discourse.julialang.org/t/why-isnt-snoopprecompile-being-able-to-fully-compile-the-calls-in-this-case/92849)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 10\
**Last updated:** [January 13, 2023, 7:36am UTC](https://discourse.julialang.org/t/why-isnt-snoopprecompile-being-able-to-fully-compile-the-calls-in-this-case/92849 "2023-01-13T07:36:49Z")

</div>

I have a PR to BandedMatrices with the following SnoopPrecompile instructions: @precompile\_setup begin vs = (\[1.0\], Float32\[1.0\], ComplexF32\[1.0\], ComplexF64\[1.0\]) Bs = Any\[BandedMatrix(0 =\> v) for v in vs\] @precompi…

---

## [Performance measurement of floating number division vs multiplication](https://discourse.julialang.org/t/performance-measurement-of-floating-number-division-vs-multiplication/92874)

<div class="topic-metadata">

**Author:** [@linwaytin](https://discourse.julialang.org/u/linwaytin)\
**Replies:** 3\
**Last updated:** [January 12, 2023, 3:30pm UTC](https://discourse.julialang.org/t/performance-measurement-of-floating-number-division-vs-multiplication/92874 "2023-01-12T15:30:55Z")

</div>

I want to know how expensive the floating number division is, compared to the multiplication. Using BenchmarkTools, I found they are the same. julia\> @benchmark $(Ref(a))\[\] \* $(Ref(b))\[\] BenchmarkTools.Trial: 10000 samp…

---

## [Very long time to compile system image with v1.9beta2](https://discourse.julialang.org/t/very-long-time-to-compile-system-image-with-v1-9beta2/92870)

<div class="topic-metadata">

**Author:** [@mcreel](https://discourse.julialang.org/u/mcreel)\
**Replies:** 5\
**Last updated:** [January 12, 2023, 3:12pm UTC](https://discourse.julialang.org/t/very-long-time-to-compile-system-image-with-v1-9beta2/92870 "2023-01-12T15:12:15Z")

</div>

Using julia v1.9beta2, I have tried to compile a system image for a project with many dependencies. This takes around 10-12 minutes with v1.8.x. With 1.9b2, I interrupted it at the 2 hour point. Perhaps I should clear ou…

---

## [ForwardDiff.derivative pointwise](https://discourse.julialang.org/t/forwarddiff-derivative-pointwise/92867)

<div class="topic-metadata">

**Author:** [@c\_sell](https://discourse.julialang.org/u/c_sell)\
**Replies:** 2\
**Last updated:** [January 12, 2023, 1:15pm UTC](https://discourse.julialang.org/t/forwarddiff-derivative-pointwise/92867 "2023-01-12T13:15:48Z")

</div>

Hello, is it possible to use ForwardDiff in the following way. I have a function (a forward diff through a neural network). I want to take the second derivative of the output with respect to the input. If I use n input…

---

## [Surprising type widening when constructing Tuple{...}](https://discourse.julialang.org/t/surprising-type-widening-when-constructing-tuple/92840)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 2\
**Last updated:** [January 12, 2023, 3:18am UTC](https://discourse.julialang.org/t/surprising-type-widening-when-constructing-tuple/92840 "2023-01-12T03:18:58Z")

</div>

Dear Julia type inference masters, I am facing some inference/performance problems which look like they could be circumvented, but I don’t know enough about what is going on here. struct ValType{T, V} end ValTypeof(v::…

---

## [Much worse import time for \`Statistics\` and \`SparseArrays\` on julia 1.9.0 nightly?](https://discourse.julialang.org/t/much-worse-import-time-for-statistics-and-sparsearrays-on-julia-1-9-0-nightly/83679)

<div class="topic-metadata">

**Author:** [@Krastanov](https://discourse.julialang.org/u/Krastanov)\
**Replies:** 3\
**Last updated:** [January 12, 2023, 12:43am UTC](https://discourse.julialang.org/t/much-worse-import-time-for-statistics-and-sparsearrays-on-julia-1-9-0-nightly/83679 "2023-01-12T00:43:30Z")

</div>

I am confused by this. Why would Statistics (or its dependency SparseArrays), a package in the standard library, have such a bad time to import? Anything I can do about this in my package that depends on Statistics? I ha…

---

## [Benign data races?](https://discourse.julialang.org/t/benign-data-races/92424)

<div class="topic-metadata">

**Author:** [@pitsianis](https://discourse.julialang.org/u/pitsianis)\
**Replies:** 2\
**Last updated:** [January 10, 2023, 5:52pm UTC](https://discourse.julialang.org/t/benign-data-races/92424 "2023-01-10T17:52:59Z")

</div>

Somebody, please elaborate on the dangers alluded to by the manual in section “Data-race freedom” Julia is not memory safe in the presence of a data race. Be very careful about reading any data if another thread might …

---

## [MATLAB outperforms Julia (20 times faster) running this nested loop](https://discourse.julialang.org/t/matlab-outperforms-julia-20-times-faster-running-this-nested-loop/92691)

<div class="topic-metadata">

**Author:** [@SantiagoOrtiz](https://discourse.julialang.org/u/SantiagoOrtiz)\
**Replies:** 20\
**Last updated:** [January 10, 2023, 2:03am UTC](https://discourse.julialang.org/t/matlab-outperforms-julia-20-times-faster-running-this-nested-loop/92691 "2023-01-10T02:03:30Z")

</div>

Hello Fellas, I am relatively new to Julia Programming. So far, Julia’s high performance has caught my attention. However, it was disappointing to see that MATLAB performs 20 times faster in executing the following prog…

---

## [Help implementing parallelism with readbytes!](https://discourse.julialang.org/t/help-implementing-parallelism-with-readbytes/92672)

<div class="topic-metadata">

**Author:** [@CodeGodz](https://discourse.julialang.org/u/CodeGodz)\
**Replies:** 9\
**Last updated:** [January 9, 2023, 9:44pm UTC](https://discourse.julialang.org/t/help-implementing-parallelism-with-readbytes/92672 "2023-01-09T21:44:08Z")

</div>

I have to read some TBs of data and I want to read a 10-50GB chunk using readbytes! and process it. Since processing the chunk takes longer than reading it it would be a waste to every time wait for the readbytes!. So I…

---

## [Using do with file handle somehow causes allocations?](https://discourse.julialang.org/t/using-do-with-file-handle-somehow-causes-allocations/92704)

<div class="topic-metadata">

**Author:** [@CodeGodz](https://discourse.julialang.org/u/CodeGodz)\
**Replies:** 4\
**Last updated:** [January 9, 2023, 11:24am UTC](https://discourse.julialang.org/t/using-do-with-file-handle-somehow-causes-allocations/92704 "2023-01-09T11:24:28Z")

</div>

I was implementing some code regarding my prev question and came across some behavior that I can’t wrap my head around when reading chunks from a file. I put the reduced code below. Actually readbytes! doesn’t make the d…

---

## [Any packages/tools to automatically turn natural codes for matrix operations into pre-allocated forms?](https://discourse.julialang.org/t/any-packages-tools-to-automatically-turn-natural-codes-for-matrix-operations-into-pre-allocated-forms/92657)

<div class="topic-metadata">

**Author:** [@photor](https://discourse.julialang.org/u/photor)\
**Replies:** 0\
**Last updated:** [January 8, 2023, 6:00am UTC](https://discourse.julialang.org/t/any-packages-tools-to-automatically-turn-natural-codes-for-matrix-operations-into-pre-allocated-forms/92657 "2023-01-08T06:00:15Z")

</div>

For example, turn F=D\*(A+B\*C)+E into G=copy(A) mul!(G, B, C, true, true) F=copy(E) mul!(F, D, G, true, true) Thanks.

---

## [Would a search directly calling memchr have disadvantages?](https://discourse.julialang.org/t/would-a-search-directly-calling-memchr-have-disadvantages/92592)

<div class="topic-metadata">

**Author:** [@CodeGodz](https://discourse.julialang.org/u/CodeGodz)\
**Replies:** 5\
**Last updated:** [January 6, 2023, 12:07pm UTC](https://discourse.julialang.org/t/would-a-search-directly-calling-memchr-have-disadvantages/92592 "2023-01-06T12:07:38Z")

</div>

Just looking at the ScanByte package by @jakobnissen (thanks for giving me ideas! :slight\_smile: ). It’s written to find the first occurrence of a given byte in a byte array. Just as a test I thought I can also call memc…

---

## [Only 1 BLAS thread in 1.9-beta2](https://discourse.julialang.org/t/only-1-blas-thread-in-1-9-beta2/92578)

<div class="topic-metadata">

**Author:** [@PeterSimon](https://discourse.julialang.org/u/PeterSimon)\
**Replies:** 2\
**Last updated:** [January 6, 2023, 12:18am UTC](https://discourse.julialang.org/t/only-1-blas-thread-in-1-9-beta2/92578 "2023-01-06T00:18:14Z")

</div>

When I start up Julia 1.9-beta2 on my 8-core Windows machine, BLAS.get\_num\_threads() returns 1 (whether or not I start with the -t8 option. Is this intended behavior or a bug? PS D:\\peter\\Documents\> julia …

---

## [Julia v1.9.0-beta2 is fast](https://discourse.julialang.org/t/julia-v1-9-0-beta2-is-fast/92290)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 43\
**Last updated:** [January 5, 2023, 10:20pm UTC](https://discourse.julialang.org/t/julia-v1-9-0-beta2-is-fast/92290 "2023-01-05T22:20:59Z")

</div>

First test on Ubuntu 20.04: Code, save it in bench.jl: using CSV const input=""" time,ping 1,25.7 2,31.8 """ function read\_csv(in) io = IOBuffer(in) file = CSV.File(io) close(io) file end file = read…

---

## [When should you use views?](https://discourse.julialang.org/t/when-should-you-use-views/25092)

<div class="topic-metadata">

**Author:** [@HenriDeh](https://discourse.julialang.org/u/HenriDeh)\
**Replies:** 9\
**Last updated:** [June 10, 2019, 3:51pm UTC](https://discourse.julialang.org/t/when-should-you-use-views/25092 "2019-06-10T15:51:32Z")

</div>

I was wondering in which cases you should use views to avoid copy of data. The example I had in mind is m = maximum(arr\[4:end\]) m = maximum(@view arr\[4:end\]) are those equivalent ?

---

## [How can I fix the following type unstability? (Example of a Type unstable function)](https://discourse.julialang.org/t/how-can-i-fix-the-following-type-unstability-example-of-a-type-unstable-function/92510)

<div class="topic-metadata">

**Author:** [@Shayan](https://discourse.julialang.org/u/Shayan)\
**Replies:** 4\
**Last updated:** [January 4, 2023, 3:27pm UTC](https://discourse.julialang.org/t/how-can-i-fix-the-following-type-unstability-example-of-a-type-unstable-function/92510 "2023-01-04T15:27:07Z")

</div>

I’ve defined the following function: using DataFrames function Silouhette( input\_data, model::KmeansResult )::Float64 if Tables.istable(input\_data) RunSilouhette(Tables.matrix(input\_data), model) else …

---

## [Are computations with Dual numbers twice as slow as non Duals?](https://discourse.julialang.org/t/are-computations-with-dual-numbers-twice-as-slow-as-non-duals/92502)

<div class="topic-metadata">

**Author:** [@nrontsis](https://discourse.julialang.org/u/nrontsis)\
**Replies:** 2\
**Last updated:** [January 4, 2023, 2:39pm UTC](https://discourse.julialang.org/t/are-computations-with-dual-numbers-twice-as-slow-as-non-duals/92502 "2023-01-04T14:39:08Z")

</div>

After reading this I got the impression that computations with dual numbers are typically expected to be twice as slow as non-duals. The reasoning was that both the normal and dual computations have to calculated at each…

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

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