# Performance

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

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

**Page:** 64

---

## [Code in unexecuted if statement causes slowdown in other function](https://discourse.julialang.org/t/code-in-unexecuted-if-statement-causes-slowdown-in-other-function/82983)

<div class="topic-metadata">

**Author:** [@f.ij](https://discourse.julialang.org/u/f.ij)\
**Replies:** 1\
**Last updated:** [June 19, 2022, 3:02am UTC](https://discourse.julialang.org/t/code-in-unexecuted-if-statement-causes-slowdown-in-other-function/82983 "2022-06-19T03:02:48Z")

</div>

I’m making a Monte Carlo simulation program. The object my simulation is working on is a graph, which I represent by struct mutable struct IsingGraph state::Vector{Int8} adj::Vector{Vector{Int32}} ... eprops…

---

## [Initialize the julia runtime more than once within C++](https://discourse.julialang.org/t/initialize-the-julia-runtime-more-than-once-within-c/82892)

<div class="topic-metadata">

**Author:** [@MarioSouto](https://discourse.julialang.org/u/MarioSouto)\
**Replies:** 5\
**Last updated:** [June 18, 2022, 7:49pm UTC](https://discourse.julialang.org/t/initialize-the-julia-runtime-more-than-once-within-c/82892 "2022-06-18T19:49:34Z")

</div>

I’m trying to create a micro service in C++ that calls julia at each new request. In the first call it works just fine but it crashes with a signal (11): Segmentation fault at the second call. I’ve tried initializing the…

---

## [Blend pmap with dynamic addprocs() rmprocs() on shared High Performance Computing Cluster](https://discourse.julialang.org/t/blend-pmap-with-dynamic-addprocs-rmprocs-on-shared-high-performance-computing-cluster/82702)

<div class="topic-metadata">

**Author:** [@philip](https://discourse.julialang.org/u/philip)\
**Replies:** 7\
**Last updated:** [June 17, 2022, 12:47am UTC](https://discourse.julialang.org/t/blend-pmap-with-dynamic-addprocs-rmprocs-on-shared-high-performance-computing-cluster/82702 "2022-06-17T00:47:45Z")

</div>

I have a “trivially parallel” computation to run. The function is loosely like this: function process\_one\_iteration(i::Int64, input\_directory::String) x = read\_input\_from\_directory(i, input\_directory::String) …

---

## [Why \`count\` is slower than my code?](https://discourse.julialang.org/t/why-count-is-slower-than-my-code/82856)

<div class="topic-metadata">

**Author:** [@aerdely](https://discourse.julialang.org/u/aerdely)\
**Replies:** 7\
**Last updated:** [June 16, 2022, 1:13pm UTC](https://discourse.julialang.org/t/why-count-is-slower-than-my-code/82856 "2022-06-16T13:13:30Z")

</div>

I was expecting count to be highly optimized, but it seems like it is 10x slower than the following code, why? using BenchmarkTools function contar() c = 0 for i in "?#?##?#?#???####??##" c += i == '#' …

---

## [Yield() not behaving as expected](https://discourse.julialang.org/t/yield-not-behaving-as-expected/82784)

<div class="topic-metadata">

**Author:** [@mjg](https://discourse.julialang.org/u/mjg)\
**Replies:** 2\
**Last updated:** [June 15, 2022, 9:02pm UTC](https://discourse.julialang.org/t/yield-not-behaving-as-expected/82784 "2022-06-15T21:02:11Z")

</div>

I’m trying to make a producer-consumer threaded program, but can’t figure out why yield seems not to be ceding control to worker tasks most of the time. Simplified Example I’ve created a much simpler example that replic…

---

## [Zygote very slow relative to ForwardDiff?](https://discourse.julialang.org/t/zygote-very-slow-relative-to-forwarddiff/82837)

<div class="topic-metadata">

**Author:** [@robsmith11](https://discourse.julialang.org/u/robsmith11)\
**Replies:** 1\
**Last updated:** [June 15, 2022, 8:56pm UTC](https://discourse.julialang.org/t/zygote-very-slow-relative-to-forwarddiff/82837 "2022-06-15T20:56:59Z")

</div>

I’m trying to speed up fitting a model with DynamicHMC.jl, so I was experimenting with different autodiff packages. I’ve seen Zygote mentioned quite a bit as a promising autodiff package, but the performance seems to be…

---

## [\`sort!()\` and \`sort()\` give me runtime dispatches](https://discourse.julialang.org/t/sort-and-sort-give-me-runtime-dispatches/82715)

<div class="topic-metadata">

**Author:** [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Replies:** 1\
**Last updated:** [June 15, 2022, 2:21pm UTC](https://discourse.julialang.org/t/sort-and-sort-give-me-runtime-dispatches/82715 "2022-06-15T14:21:48Z")

</div>

I have been learning how to use JET.jl to check my code for type instabilities, and I notice that it keeps giving me a runtime dispatch after calling Julia’s built-iin sort routines. This happens even when my functions h…

---

## [Accelerate autodiff in Zygote.jl](https://discourse.julialang.org/t/accelerate-autodiff-in-zygote-jl/66454)

<div class="topic-metadata">

**Author:** [@Richard-Li](https://discourse.julialang.org/u/Richard-Li)\
**Replies:** 9\
**Last updated:** [June 15, 2022, 12:26pm UTC](https://discourse.julialang.org/t/accelerate-autodiff-in-zygote-jl/66454 "2022-06-15T12:26:35Z")

</div>

Hi there, I’d like to know if there is any performance tip for using Zygote.jl. I am calculating the Hessian matrix using autodiff, and now the autodiff part runs quite slow, and I’d like to accelerate it. e.g. 4.3…

---

## [How to efficiently sort subarrays of 2 large arrays in parallel?](https://discourse.julialang.org/t/how-to-efficiently-sort-subarrays-of-2-large-arrays-in-parallel/82771)

<div class="topic-metadata">

**Author:** [@Leo\_I](https://discourse.julialang.org/u/Leo_I)\
**Replies:** 0\
**Last updated:** [June 14, 2022, 5:40pm UTC](https://discourse.julialang.org/t/how-to-efficiently-sort-subarrays-of-2-large-arrays-in-parallel/82771 "2022-06-14T17:40:28Z")

</div>

I have large 1D arrays x and y, and pointers I that separate them into subarrays. My x and y barely fit into RAM and are of different dtypes (one contains UInt32’s, the other Rational{Int64}'s), so I don’t want to join t…

---

## [Type of real part (of complex array element)](https://discourse.julialang.org/t/type-of-real-part-of-complex-array-element/82723)

<div class="topic-metadata">

**Author:** [@nicolas](https://discourse.julialang.org/u/nicolas)\
**Replies:** 8\
**Last updated:** [June 14, 2022, 1:00pm UTC](https://discourse.julialang.org/t/type-of-real-part-of-complex-array-element/82723 "2022-06-14T13:00:43Z")

</div>

I’m wondering whether there is a nice way of knowing the concrete type of the real part of a complex number, particularly something like eltype() for array elements. Right now, for an abstract array x, I’m using typeof(r…

---

## ["Optional" in-place output arguments](https://discourse.julialang.org/t/optional-in-place-output-arguments/82492)

<div class="topic-metadata">

**Author:** [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Replies:** 31\
**Last updated:** [June 13, 2022, 1:11pm UTC](https://discourse.julialang.org/t/optional-in-place-output-arguments/82492 "2022-06-13T13:11:22Z")

</div>

I am considering writing a function foo!(i1,i2,o1,o2,o3) where i1 etc. are inputs and o1 etc. are outputs. Importantly: all the outputs are preallocated (mutable) vectors, and the results are to written in place into…

---

## [Unexpected allocation at each loop iteration](https://discourse.julialang.org/t/unexpected-allocation-at-each-loop-iteration/82600)

<div class="topic-metadata">

**Author:** [@simon79](https://discourse.julialang.org/u/simon79)\
**Replies:** 8\
**Last updated:** [June 11, 2022, 5:19pm UTC](https://discourse.julialang.org/t/unexpected-allocation-at-each-loop-iteration/82600 "2022-06-11T17:19:53Z")

</div>

Hi, The following overly-simplified extraction from my code shows a section of the code which is allocating memory at every loop iteration. I think this should not happen and I’d like to have advise and suggestion on h…

---

## [View or copy: looking for an overview](https://discourse.julialang.org/t/view-or-copy-looking-for-an-overview/82495)

<div class="topic-metadata">

**Author:** [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)\
**Replies:** 8\
**Last updated:** [June 9, 2022, 8:29pm UTC](https://discourse.julialang.org/t/view-or-copy-looking-for-an-overview/82495 "2022-06-09T20:29:42Z")

</div>

I am looking for an overview/recommendations on the classical view or copy issue. Any links? Background: even in a simple case like sum(x\[ind\]) versus sum(view(x,ind)), the former seems to be faster in many cases (eg.…

---

## [Is this a good illustration of the principle "Don't store fields you can compute on demand"?](https://discourse.julialang.org/t/is-this-a-good-illustration-of-the-principle-dont-store-fields-you-can-compute-on-demand/82496)

<div class="topic-metadata">

**Author:** [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Replies:** 6\
**Last updated:** [June 9, 2022, 10:26pm UTC](https://discourse.julialang.org/t/is-this-a-good-illustration-of-the-principle-dont-store-fields-you-can-compute-on-demand/82496 "2022-06-09T22:26:17Z")

</div>

Motivation I was reading @jakobnissen 's blog post about optimizing Julia code and came across this interesting tip: Do not store fields that can easily be computed on demand. In my code, I am working on a numerical …

---

## [Test of expand and substitute in Symbolics.jl, SymEngine.jl and Mathematica](https://discourse.julialang.org/t/test-of-expand-and-substitute-in-symbolics-jl-symengine-jl-and-mathematica/77470)

<div class="topic-metadata">

**Author:** [@gangchern](https://discourse.julialang.org/u/gangchern)\
**Replies:** 18\
**Last updated:** [June 9, 2022, 2:38am UTC](https://discourse.julialang.org/t/test-of-expand-and-substitute-in-symbolics-jl-symengine-jl-and-mathematica/77470 "2022-06-09T02:38:24Z")

</div>

My computer is Mac Pro M1, 2020. General Comments: for expand, SymEngine is nearly as good as Mathematica, Symbolics‘s “expand” function still needs to be greatly improved. substitute are similar for the three CAS in pe…

---

## [Reinterpret to non bits type](https://discourse.julialang.org/t/reinterpret-to-non-bits-type/82307)

<div class="topic-metadata">

**Author:** [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Replies:** 41\
**Last updated:** [June 8, 2022, 11:38am UTC](https://discourse.julialang.org/t/reinterpret-to-non-bits-type/82307 "2022-06-08T11:38:58Z")

</div>

I have a Vector{UInt8} and I want to get a Vector{T} for an arbitrary type T without or with minimal runtime penalty and without allocating. The actual contents of the input and output are unspecified. The use case is i…

---

## [Type Sudoku (test if object is a struct)](https://discourse.julialang.org/t/type-sudoku-test-if-object-is-a-struct/66139)

<div class="topic-metadata">

**Author:** [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Replies:** 21\
**Last updated:** [June 8, 2022, 9:43am UTC](https://discourse.julialang.org/t/type-sudoku-test-if-object-is-a-struct/66139 "2022-06-08T09:43:32Z")

</div>

This is NOT to complain about Julia, rather a learning experience, so bear with me… Dispatching to a struct type seems like the match of the last resort - after a lot of not this, not that, not really testable. And cont…

---

## [What is the equivalent of this OpenMP Directive in Julia?](https://discourse.julialang.org/t/what-is-the-equivalent-of-this-openmp-directive-in-julia/82014)

<div class="topic-metadata">

**Author:** [@Amro](https://discourse.julialang.org/u/Amro)\
**Replies:** 14\
**Last updated:** [June 7, 2022, 7:13pm UTC](https://discourse.julialang.org/t/what-is-the-equivalent-of-this-openmp-directive-in-julia/82014 "2022-06-07T19:13:09Z")

</div>

What is the equivalent to the below command in Julia, in which I can run a specific code (or function) on a specific CPU core? !$OMP PARALLEL # Code !$OMP END PARALLEL

---

## [ProgressMeter while using DataFrame commands?](https://discourse.julialang.org/t/progressmeter-while-using-dataframe-commands/65405)

<div class="topic-metadata">

**Author:** [@joonp](https://discourse.julialang.org/u/joonp)\
**Replies:** 2\
**Last updated:** [June 7, 2022, 6:38pm UTC](https://discourse.julialang.org/t/progressmeter-while-using-dataframe-commands/65405 "2022-06-07T18:38:09Z")

</div>

Hi, I have a code chunk that uses DataFrame groupby() and combine() and that requires heavy computation for each group. I would like to see its progress such as out of n groups… how many groups have finished the computa…

---

## [Why is Traceur Warning: is assigned as Union{Nothing, Tuple{Int64, Int64}}?](https://discourse.julialang.org/t/why-is-traceur-warning-is-assigned-as-union-nothing-tuple-int64-int64/82322)

<div class="topic-metadata">

**Author:** [@peter.wolf](https://discourse.julialang.org/u/peter.wolf)\
**Replies:** 2\
**Last updated:** [June 7, 2022, 2:41pm UTC](https://discourse.julialang.org/t/why-is-traceur-warning-is-assigned-as-union-nothing-tuple-int64-int64/82322 "2022-06-07T14:41:17Z")

</div>

Hello, I am optimizing my code. I have made all the types stable according to @code\_warntype, but @trace is still giving me this warning throughout my code Warning: is assigned as Union{Nothing, Tuple{Int64, Int64}} …

---

## [Small changes on large arrays of custom types: mutable or immutable? shallow or deepcopy?](https://discourse.julialang.org/t/small-changes-on-large-arrays-of-custom-types-mutable-or-immutable-shallow-or-deepcopy/82335)

<div class="topic-metadata">

**Author:** [@skraemer](https://discourse.julialang.org/u/skraemer)\
**Replies:** 3\
**Last updated:** [June 7, 2022, 12:56pm UTC](https://discourse.julialang.org/t/small-changes-on-large-arrays-of-custom-types-mutable-or-immutable-shallow-or-deepcopy/82335 "2022-06-07T12:56:51Z")

</div>

(I have previously asked this on the New to Julia category, but I think might rather belong here) There are a few things somehow all related about the following situation concerning mutability to which I can not find a …

---

## [Benchmarking all algorithms in DiffEq/Optimisation code](https://discourse.julialang.org/t/benchmarking-all-algorithms-in-diffeq-optimisation-code/82358)

<div class="topic-metadata">

**Author:** [@DanielVandH](https://discourse.julialang.org/u/DanielVandH)\
**Replies:** 1\
**Last updated:** [June 7, 2022, 11:05am UTC](https://discourse.julialang.org/t/benchmarking-all-algorithms-in-diffeq-optimisation-code/82358 "2022-06-07T11:05:41Z")

</div>

If I have some ODE code, say this code from the https://diffeq.sciml.ai/stable/tutorials/advanced\_ode\_example/: using DifferentialEquations, LinearAlgebra, SparseArrays const N = 32 const xyd\_brusselator = range(0,stop…

---

## [Semaphore with permit id?](https://discourse.julialang.org/t/semaphore-with-permit-id/82142)

<div class="topic-metadata">

**Author:** [@Joris\_Pinkse](https://discourse.julialang.org/u/Joris_Pinkse)\
**Replies:** 1\
**Last updated:** [June 7, 2022, 2:50am UTC](https://discourse.julialang.org/t/semaphore-with-permit-id/82142 "2022-06-07T02:50:44Z")

</div>

I’d like to use a Semaphore like object with say four permits, where a call to acquire would tell me which of the four permits was assigned and a call to release would release that specific permit. I understand that Sem…

---

## [Expressiveness for queries](https://discourse.julialang.org/t/expressiveness-for-queries/82318)

<div class="topic-metadata">

**Author:** [@kumarbalachandran](https://discourse.julialang.org/u/kumarbalachandran)\
**Replies:** 3\
**Last updated:** [June 6, 2022, 6:58pm UTC](https://discourse.julialang.org/t/expressiveness-for-queries/82318 "2022-06-06T18:58:04Z")

</div>

I have a table, with some missing values and I wanted to do a data retrieval from the table. It so happened that a comparison of the DataFrames implementation I came up with is much more wordy than the equivalent Pandas.…

---

## [UInt128 to Float64 conversion](https://discourse.julialang.org/t/uint128-to-float64-conversion/82317)

<div class="topic-metadata">

**Author:** [@albheim](https://discourse.julialang.org/u/albheim)\
**Replies:** 2\
**Last updated:** [June 6, 2022, 3:14pm UTC](https://discourse.julialang.org/t/uint128-to-float64-conversion/82317 "2022-06-06T15:14:05Z")

</div>

Came upon an interesting blogpost where the author explains how they implemented their own unsigned 128 bit int to 64 bit float conversion in rust just because they didn’t think it existed, and when they realised it did …

---

## [How to tranform a vector into a matrix?](https://discourse.julialang.org/t/how-to-tranform-a-vector-into-a-matrix/82286)

<div class="topic-metadata">

**Author:** [@Leticia-maria](https://discourse.julialang.org/u/Leticia-maria)\
**Replies:** 5\
**Last updated:** [June 6, 2022, 1:26pm UTC](https://discourse.julialang.org/t/how-to-tranform-a-vector-into-a-matrix/82286 "2022-06-06T13:26:33Z")

</div>

How to transform a vector of type: \[\[1.021434087e-5, 1.532972083e-5, -1.493500137e-5\], \[-0.19951695340554, 0.87894179053067, -0.62713882127936\], \[0.76712229809243, 0.24863902907755, 0.74526241504934\], \[0.355803343995…

---

## [Array broadcasting slower than numpy?](https://discourse.julialang.org/t/array-broadcasting-slower-than-numpy/82212)

<div class="topic-metadata">

**Author:** [@chunjiw](https://discourse.julialang.org/u/chunjiw)\
**Replies:** 20\
**Last updated:** [June 4, 2022, 7:22am UTC](https://discourse.julialang.org/t/array-broadcasting-slower-than-numpy/82212 "2022-06-04T07:22:03Z")

</div>

@time let m = 10^7 + 19 v = fill(0, m) w = copy(v) for \_ in 1:100 i = mod(rand(Int), m) v\[1:i\] .+= @view w\[end-i+1:end\] v\[i+1:end\] .+= @view w\[1:end-i\] end end import time import numpy as np import random t0 …

---

## [Performance slowdown on AMD with Windows10 compared to Intel with Linux (arch)](https://discourse.julialang.org/t/performance-slowdown-on-amd-with-windows10-compared-to-intel-with-linux-arch/82180)

<div class="topic-metadata">

**Author:** [@Tambu](https://discourse.julialang.org/u/Tambu)\
**Replies:** 7\
**Last updated:** [June 3, 2022, 9:42pm UTC](https://discourse.julialang.org/t/performance-slowdown-on-amd-with-windows10-compared-to-intel-with-linux-arch/82180 "2022-06-03T21:42:23Z")

</div>

Update, TL;DR: the problem is the AMD processor, or the combination AMD+windows. Not Windows itself as on the same laptop, same version of julia (1.7.3), performance are similar. Hi all, I have two setups, as the title…

---

## [How to avoid vectors of abstract types?](https://discourse.julialang.org/t/how-to-avoid-vectors-of-abstract-types/82132)

<div class="topic-metadata">

**Author:** [@BatyLeo](https://discourse.julialang.org/u/BatyLeo)\
**Replies:** 5\
**Last updated:** [June 3, 2022, 7:47am UTC](https://discourse.julialang.org/t/how-to-avoid-vectors-of-abstract-types/82132 "2022-06-03T07:47:18Z")

</div>

Hello, I started using Julia intensively a few months ago, and I keep coming across situations where I have vectors of abstract types, which should be avoided for performance reasons. I can’t seem to find satisfying sol…

---

## [Julia vs Trilinos](https://discourse.julialang.org/t/julia-vs-trilinos/82128)

<div class="topic-metadata">

**Author:** [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Replies:** 8\
**Last updated:** [June 2, 2022, 2:15pm UTC](https://discourse.julialang.org/t/julia-vs-trilinos/82128 "2022-06-02T14:15:07Z")

</div>

Hi all, I am just learning about Julia, and see another package for mathematics named Trilinos. TrilinosHandsOnTutorial · trilinos/Trilinos\_tutorial Wiki https://trilinos.github.io/ I was thinking and wondering if I …

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

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