# Performance

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

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

**Page:** 83

---

## [Multiple Outputs (Tuple) from IfElse with VectorizationBase](https://discourse.julialang.org/t/multiple-outputs-tuple-from-ifelse-with-vectorizationbase/68255)

<div class="topic-metadata">

**Author:** [@disberd](https://discourse.julialang.org/u/disberd)\
**Replies:** 3\
**Last updated:** [September 16, 2021, 2:36pm UTC](https://discourse.julialang.org/t/multiple-outputs-tuple-from-ifelse-with-vectorizationbase/68255 "2021-09-16T14:36:08Z")

</div>

Hi there, I am trying to experiment a bit with VectorizationBase to create functions that can be used inside the @turbo macro from LoopVectorization. I have a use case where my computation can be significantly sped up …

---

## [Kemp and Kemp (1991) Poisson random variates implementation](https://discourse.julialang.org/t/kemp-and-kemp-1991-poisson-random-variates-implementation/68233)

<div class="topic-metadata">

**Author:** [@pjentsch0](https://discourse.julialang.org/u/pjentsch0)\
**Replies:** 0\
**Last updated:** [September 15, 2021, 10:20pm UTC](https://discourse.julialang.org/t/kemp-and-kemp-1991-poisson-random-variates-implementation/68233 "2021-09-15T22:20:51Z")

</div>

Currently, the sampler in Distributions.jl for poisson random variates is PoissonADSampler, which implements the algorithm from J.H. Ahrens, U. Dieter (1982). I found the paper, “Poisson Random Variate Generation” from …

---

## [Memory usage with mmap file](https://discourse.julialang.org/t/memory-usage-with-mmap-file/59883)

<div class="topic-metadata">

**Author:** [@KKesgin](https://discourse.julialang.org/u/KKesgin)\
**Replies:** 17\
**Last updated:** [September 16, 2021, 3:38am UTC](https://discourse.julialang.org/t/memory-usage-with-mmap-file/59883 "2021-09-16T03:38:55Z")

</div>

Hi All I’m accessing a very large binary file randomly on windows. I don’t dare to put in all the code but I managed to replicate the behavior with a small loop. Could someone please explain to me why this is causing in…

---

## [Adding packages + pre-compilation vs. (docker pull) pre-built sysimage](https://discourse.julialang.org/t/adding-packages-pre-compilation-vs-docker-pull-pre-built-sysimage/55445)

<div class="topic-metadata">

**Author:** [@StatisticalMouse](https://discourse.julialang.org/u/StatisticalMouse)\
**Replies:** 1\
**Last updated:** [September 15, 2021, 8:15pm UTC](https://discourse.julialang.org/t/adding-packages-pre-compilation-vs-docker-pull-pre-built-sysimage/55445 "2021-09-15T20:15:00Z")

</div>

I made an observation, which might be useful. I have a base julia docker image with jupyterlab installed. I then added another layer that does RUN julia -e "using Pkg; Pkg.add(\["Plots","StatsPlots","DataFrames"\]); Pkg.p…

---

## [Broadcast comparison of array of enum objects gives an error](https://discourse.julialang.org/t/broadcast-comparison-of-array-of-enum-objects-gives-an-error/68146)

<div class="topic-metadata">

**Author:** [@pjgorski](https://discourse.julialang.org/u/pjgorski)\
**Replies:** 11\
**Last updated:** [September 15, 2021, 1:56pm UTC](https://discourse.julialang.org/t/broadcast-comparison-of-array-of-enum-objects-gives-an-error/68146 "2021-09-15T13:56:24Z")

</div>

I have an array of @Enum objects. I want to count the array elements having a certain value. @enum E x = 0 y = 1 Es = \[E(0) for i in 1:100\] sum(Es .== E(0)) Above code and just Es .== E(0) gives the following error: E…

---

## [How to write a custom distribution using pdf from a Kernel Density Estimator?](https://discourse.julialang.org/t/how-to-write-a-custom-distribution-using-pdf-from-a-kernel-density-estimator/68175)

<div class="topic-metadata">

**Author:** [@vkv](https://discourse.julialang.org/u/vkv)\
**Replies:** 4\
**Last updated:** [September 14, 2021, 9:50pm UTC](https://discourse.julialang.org/t/how-to-write-a-custom-distribution-using-pdf-from-a-kernel-density-estimator/68175 "2021-09-14T21:50:12Z")

</div>

Let x = rand(100); #some data PDF of x can be estimated using KDE: using KernelDensity KDE\_x = kde(x) ik = InterpKDE(KDE\_x) KDE\_pdf(x) = pdf(ik, x) How can the KDE\_pdf function be used in to construct a custom distri…

---

## [How to prevent this warning](https://discourse.julialang.org/t/how-to-prevent-this-warning/68159)

<div class="topic-metadata">

**Author:** [@lewis](https://discourse.julialang.org/u/lewis)\
**Replies:** 2\
**Last updated:** [September 14, 2021, 8:49pm UTC](https://discourse.julialang.org/t/how-to-prevent-this-warning/68159 "2021-09-14T20:49:17Z")

</div>

objc\[5352\]: Class RunLoopModeTracker is implemented in both /opt/miniconda3/lib/libQt5Core.5.9.7.dylib (0x168cffa80) and /Users/lewis/.julia/artifacts/d594d9e68b9d104aaf1a41d933728d2dad54c869/lib/QtCore.framework/Version…

---

## [Multithreaded synchronization using events allocates a lot](https://discourse.julialang.org/t/multithreaded-synchronization-using-events-allocates-a-lot/68158)

<div class="topic-metadata">

**Author:** [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Replies:** 0\
**Last updated:** [September 14, 2021, 5:44pm UTC](https://discourse.julialang.org/t/multithreaded-synchronization-using-events-allocates-a-lot/68158 "2021-09-14T17:44:22Z")

</div>

Context I’d like to use threads to parallelise a physics simulation code. The amount of work each thread has to do in a single loop might be quite small, so I want to keep all the threads running all the time as a lightw…

---

## [Surprising runtime behaviour when wrapping functions](https://discourse.julialang.org/t/surprising-runtime-behaviour-when-wrapping-functions/68140)

<div class="topic-metadata">

**Author:** [@goerch](https://discourse.julialang.org/u/goerch)\
**Replies:** 4\
**Last updated:** [September 14, 2021, 11:21am UTC](https://discourse.julialang.org/t/surprising-runtime-behaviour-when-wrapping-functions/68140 "2021-09-14T11:21:14Z")

</div>

Running the following test program using BenchmarkTools f(x) = x struct Wrapper f::Function end function evaluate(f, x) return f(x) end function evaluate(wrapper::Wrapper, x) return wrapper.f(x) end func…

---

## [Fastest way to swap bytes order in-place (ntoh)](https://discourse.julialang.org/t/fastest-way-to-swap-bytes-order-in-place-ntoh/68053)

<div class="topic-metadata">

**Author:** [@jling](https://discourse.julialang.org/u/jling)\
**Replies:** 1\
**Last updated:** [September 13, 2021, 12:56am UTC](https://discourse.julialang.org/t/fastest-way-to-swap-bytes-order-in-place-ntoh/68053 "2021-09-13T00:56:47Z")

</div>

Originally we had real\_data = ntoh.(reinterpret(T, rawdata)) where T is some element type such as Float64, rawdata is always a UIn8 vector. After some help from Slack, we’ve moved to: real\_data = GC.@preserve rawdata…

---

## [Fastest way to permute Array, given some permutation](https://discourse.julialang.org/t/fastest-way-to-permute-array-given-some-permutation/49687)

<div class="topic-metadata">

**Author:** [@DavidBerghaus](https://discourse.julialang.org/u/DavidBerghaus)\
**Replies:** 13\
**Last updated:** [September 12, 2021, 1:06pm UTC](https://discourse.julialang.org/t/fastest-way-to-permute-array-given-some-permutation/49687 "2021-09-12T13:06:19Z")

</div>

I wonder what the fastest way is to apply a permutation to an array. Three approaches that I checked are: julia\> A = rand(10000); julia\> permutation = sortperm(A); julia\> @btime $A\[$permutation\]; 11.700 μs (3 alloca…

---

## [Writing Data to JSON Files on HPC Cluster](https://discourse.julialang.org/t/writing-data-to-json-files-on-hpc-cluster/67943)

<div class="topic-metadata">

**Author:** [@Noah\_Guzman](https://discourse.julialang.org/u/Noah_Guzman)\
**Replies:** 4\
**Last updated:** [September 11, 2021, 4:53pm UTC](https://discourse.julialang.org/t/writing-data-to-json-files-on-hpc-cluster/67943 "2021-09-11T16:53:54Z")

</div>

Having some issues saving the output of Julia simulations (stochastic differential equations) in a SLURM cluster to JSON files. The cluster manager and I have not been able to figure this out. My original program runs ma…

---

## [Two nearly identical loops — why is one faster?](https://discourse.julialang.org/t/two-nearly-identical-loops-why-is-one-faster/67998)

<div class="topic-metadata">

**Author:** [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Replies:** 2\
**Last updated:** [September 10, 2021, 7:03pm UTC](https://discourse.julialang.org/t/two-nearly-identical-loops-why-is-one-faster/67998 "2021-09-10T19:03:49Z")

</div>

The following two functions both evaluate Chebyshev polynomials, using slightly different recurrences that nevertheless require nearly the same number of operations, both are type-stable with 0 allocations, and yet one o…

---

## [How to parallelize something which allocates a lot?](https://discourse.julialang.org/t/how-to-parallelize-something-which-allocates-a-lot/67853)

<div class="topic-metadata">

**Author:** [@SteffenPL](https://discourse.julialang.org/u/SteffenPL)\
**Replies:** 10\
**Last updated:** [September 10, 2021, 3:42pm UTC](https://discourse.julialang.org/t/how-to-parallelize-something-which-allocates-a-lot/67853 "2021-09-10T15:42:33Z")

</div>

I have a simulation, which needs around 50MB of RAM and 1 second to finish (lets call it simulate(p)). My problem is that I have to run these simulations around 500 times, which suddenly leads to a slowdown (maybe) due …

---

## [Avoiding memory allocation for solves with multiple right-hand sides](https://discourse.julialang.org/t/avoiding-memory-allocation-for-solves-with-multiple-right-hand-sides/67879)

<div class="topic-metadata">

**Author:** [@Gravlax](https://discourse.julialang.org/u/Gravlax)\
**Replies:** 7\
**Last updated:** [September 10, 2021, 8:57am UTC](https://discourse.julialang.org/t/avoiding-memory-allocation-for-solves-with-multiple-right-hand-sides/67879 "2021-09-10T08:57:39Z")

</div>

Hi everyone, I am new to Julia and I try to understand why a solve using the backslash operator allocates memory although the RHS vector is allocated, the solution vector is allocated and the factorisation is precompute…

---

## [Performance of garbage collection](https://discourse.julialang.org/t/performance-of-garbage-collection/37698)

<div class="topic-metadata">

**Author:** [@karelh](https://discourse.julialang.org/u/karelh)\
**Replies:** 5\
**Last updated:** [September 9, 2021, 6:41pm UTC](https://discourse.julialang.org/t/performance-of-garbage-collection/37698 "2021-09-09T18:41:34Z")

</div>

I am trying to optimize the performance of training a neural network model (using Flux.jl and Mill.jl packages). I figured out that significant time is being spent on garbage collection (when @timing individual parts of …

---

## [Memory allocation in dot product](https://discourse.julialang.org/t/memory-allocation-in-dot-product/67901)

<div class="topic-metadata">

**Author:** [@Frisus95](https://discourse.julialang.org/u/Frisus95)\
**Replies:** 11\
**Last updated:** [September 9, 2021, 1:54pm UTC](https://discourse.julialang.org/t/memory-allocation-in-dot-product/67901 "2021-09-09T13:54:12Z")

</div>

Hello everyone. Is it possible to perform a dot product between multidimensional arrays without allocating memory? For example: function funza(A) return dot(A,A) end A = rand(5,5,5,5,5); @btime funza(A) …

---

## [Pmap and svdvals from documentation speed](https://discourse.julialang.org/t/pmap-and-svdvals-from-documentation-speed/67898)

<div class="topic-metadata">

**Author:** [@Pulpo](https://discourse.julialang.org/u/Pulpo)\
**Replies:** 6\
**Last updated:** [September 8, 2021, 11:09pm UTC](https://discourse.julialang.org/t/pmap-and-svdvals-from-documentation-speed/67898 "2021-09-08T23:09:46Z")

</div>

I am wondering why the following example of pmap isn’t getting any speedup: using Distributed using BenchmarkTools @everywhere using LinearAlgebra addprocs(length(Sys.cpu\_info())); M = Matrix{Float64}\[rand(1000,100…

---

## [Correct way of using MKL.jl on Julia Version 1.7.0](https://discourse.julialang.org/t/correct-way-of-using-mkl-jl-on-julia-version-1-7-0/67780)

<div class="topic-metadata">

**Author:** [@j\_u](https://discourse.julialang.org/u/j_u)\
**Replies:** 4\
**Last updated:** [September 8, 2021, 10:26pm UTC](https://discourse.julialang.org/t/correct-way-of-using-mkl-jl-on-julia-version-1-7-0/67780 "2021-09-08T22:26:53Z")

</div>

What is the correct way of using MKL.jl on Julia Version 1.7.0-beta3.0 (2021-07-07) wrt the number of distributed processes and multithreading? I do reinforcement learning (AlphaZero.jl) training on Intel(R) Xeon(R) Gol…

---

## [Can I expect ForwardDiff to give the same performance in this case?](https://discourse.julialang.org/t/can-i-expect-forwarddiff-to-give-the-same-performance-in-this-case/67894)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 5\
**Last updated:** [September 8, 2021, 8:33pm UTC](https://discourse.julialang.org/t/can-i-expect-forwarddiff-to-give-the-same-performance-in-this-case/67894 "2021-09-08T20:33:10Z")

</div>

Hello! I just learned about Automatic Differentiation and of course need to give it a go using Julia :slight\_smile: I have a function defined as: Wendland(q) = aD\*(1-q/2)^4 \* (2\*q+1) Where aD in my case is 696. And …

---

## [Memcpy in julia](https://discourse.julialang.org/t/memcpy-in-julia/67791)

<div class="topic-metadata">

**Author:** [@Beh123](https://discourse.julialang.org/u/Beh123)\
**Replies:** 5\
**Last updated:** [September 7, 2021, 8:45am UTC](https://discourse.julialang.org/t/memcpy-in-julia/67791 "2021-09-07T08:45:57Z")

</div>

Hi everyone I have a vector which contains 5 uint8 elements. How do I copy them to two int32 variables ? we can do it with memcpy in c. Is there similar command in julia? x=\[0x3 0x00 0x11 0x00 0x80\] m= convert(Int32…

---

## [How to run a file/script in the Linux terminal (Ubuntu) assigning multi-threading?](https://discourse.julialang.org/t/how-to-run-a-file-script-in-the-linux-terminal-ubuntu-assigning-multi-threading/67784)

<div class="topic-metadata">

**Author:** [@bojusemo](https://discourse.julialang.org/u/bojusemo)\
**Replies:** 3\
**Last updated:** [September 7, 2021, 6:05am UTC](https://discourse.julialang.org/t/how-to-run-a-file-script-in-the-linux-terminal-ubuntu-assigning-multi-threading/67784 "2021-09-07T06:05:11Z")

</div>

Hi Folks, Could anybody guide me, please? How to run a file/script in the Linux terminal (Ubuntu) assigning multi-threading? If in the first line of the script I use #!/path/of/bin/julia it works without multi-threadin…

---

## [Efficient Way of Installing Packages](https://discourse.julialang.org/t/efficient-way-of-installing-packages/67770)

<div class="topic-metadata">

**Author:** [@mo\_re](https://discourse.julialang.org/u/mo_re)\
**Replies:** 4\
**Last updated:** [September 6, 2021, 7:10pm UTC](https://discourse.julialang.org/t/efficient-way-of-installing-packages/67770 "2021-09-06T19:10:24Z")

</div>

Hey everyone, while learning R I came across a forum post that was very helpful for checking and installing what packages were missing for a user. The R code went like this: packages \<- c("package names"...) # Install…

---

## [Anonymous function in count()](https://discourse.julialang.org/t/anonymous-function-in-count/67761)

<div class="topic-metadata">

**Author:** [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)\
**Replies:** 9\
**Last updated:** [September 6, 2021, 7:02pm UTC](https://discourse.julialang.org/t/anonymous-function-in-count/67761 "2021-09-06T19:02:51Z")

</div>

The slowdown of using something like count(z-\>(edges\[1\]\<z\<=edges\[2\]),x) is substantial, and can be avoided by a wrapping another function (see below). Is this the same as 10x slowdown when passing function as argument? …

---

## [Assign values to a subarray and it take a long time and large allocation](https://discourse.julialang.org/t/assign-values-to-a-subarray-and-it-take-a-long-time-and-large-allocation/67711)

<div class="topic-metadata">

**Author:** [@disadone](https://discourse.julialang.org/u/disadone)\
**Replies:** 4\
**Last updated:** [September 6, 2021, 1:11pm UTC](https://discourse.julialang.org/t/assign-values-to-a-subarray-and-it-take-a-long-time-and-large-allocation/67711 "2021-09-06T13:11:42Z")

</div>

I have functions such as function max\_(v::Matrix{Float64}) m,idx=findmax(v,dims=2) Dt=vec(getindex.(idx,2)) return m,Dt end function max\_!(Vs::AbstractVector{Float64},Ds::AbstractVector{Float64},v::Matrix{F…

---

## [RFC: Just In Time Compilation PoC promising 10x dynamic dispatch performance](https://discourse.julialang.org/t/rfc-just-in-time-compilation-poc-promising-10x-dynamic-dispatch-performance/47341)

<div class="topic-metadata">

**Author:** [@tisztamo](https://discourse.julialang.org/u/tisztamo)\
**Replies:** 0\
**Last updated:** [September 26, 2020, 10:33pm UTC](https://discourse.julialang.org/t/rfc-just-in-time-compilation-poc-promising-10x-dynamic-dispatch-performance/47341 "2020-09-26T22:33:08Z")

</div>

edit: There is the fresh new ManualDispatch.jl, a simple manual implementation of the same idea by @jlapeyre This started as a simple benchmark to better understand the performance characteristics of dynamic dispatch, b…

---

## [RAM+Swap exhausted while building sys image for Flux activity with PackageCompiler on RaspberryPi3 (Raspbian)](https://discourse.julialang.org/t/ram-swap-exhausted-while-building-sys-image-for-flux-activity-with-packagecompiler-on-raspberrypi3-raspbian/67636)

<div class="topic-metadata">

**Author:** [@Vyacheslav\_Vorobyov](https://discourse.julialang.org/u/Vyacheslav_Vorobyov)\
**Replies:** 4\
**Last updated:** [September 4, 2021, 1:16am UTC](https://discourse.julialang.org/t/ram-swap-exhausted-while-building-sys-image-for-flux-activity-with-packagecompiler-on-raspberrypi3-raspbian/67636 "2021-09-04T01:16:31Z")

</div>

To minimize start time of a Julia(1.6.2) program on RaspberryPI3, I tried to use PackageCompiler to build sys image for some activity done against Flux(only inference, not learn). After an hour of work of PackageCompiler…

---

## [Get types of members of a Tuple{} type](https://discourse.julialang.org/t/get-types-of-members-of-a-tuple-type/67645)

<div class="topic-metadata">

**Author:** [@Mark\_Nahabedian](https://discourse.julialang.org/u/Mark_Nahabedian)\
**Replies:** 7\
**Last updated:** [September 3, 2021, 2:35pm UTC](https://discourse.julialang.org/t/get-types-of-members-of-a-tuple-type/67645 "2021-09-03T14:35:50Z")

</div>

Given a Tuple type Tuple{typeof(DXFutils.parseraction), Parser, DXFGroup, EntityType\_SECTION} how do I extract the types of the 2nd and 3rd elements, to get something like (DXFGroup, EntityType\_SECTION})\` Fieldnames …

---

## [Slowdown when computing eigenvalues for list of matrices with pmap](https://discourse.julialang.org/t/slowdown-when-computing-eigenvalues-for-list-of-matrices-with-pmap/67622)

<div class="topic-metadata">

**Author:** [@christian-hh](https://discourse.julialang.org/u/christian-hh)\
**Replies:** 2\
**Last updated:** [September 3, 2021, 7:09am UTC](https://discourse.julialang.org/t/slowdown-when-computing-eigenvalues-for-list-of-matrices-with-pmap/67622 "2021-09-03T07:09:57Z")

</div>

I am attempting to compute, in parallel, the eigenvalues for a list of symmetric matrices. In the code below this is achieved with pmap (using 10 workers) and sequentially (for comparison). I’ve set the number of threads…

---

## [Vector comprehensions hamper type inference?](https://discourse.julialang.org/t/vector-comprehensions-hamper-type-inference/67603)

<div class="topic-metadata">

**Author:** [@droodman](https://discourse.julialang.org/u/droodman)\
**Replies:** 1\
**Last updated:** [September 2, 2021, 10:14pm UTC](https://discourse.julialang.org/t/vector-comprehensions-hamper-type-inference/67603 "2021-09-02T22:14:12Z")

</div>

I’m new to Julia, so I post now with uncertainty. I’m finding that vector comprehensions hamper the compiler’s type inference–both about 1) the type of the result of the comprehension and 2) about the type of arguments p…

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

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