# Performance

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

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

**Page:** 103

---

## [@code\_warntype gives yellow ::Union{Nothing, Tuple{Int64,Int64}} in for loops](https://discourse.julialang.org/t/code-warntype-gives-yellow-union-nothing-tuple-int64-int64-in-for-loops/52814)

<div class="topic-metadata">

**Author:** [@claudio20497](https://discourse.julialang.org/u/claudio20497)\
**Replies:** 1\
**Last updated:** [January 4, 2021, 12:41pm UTC](https://discourse.julialang.org/t/code-warntype-gives-yellow-union-nothing-tuple-int64-int64-in-for-loops/52814 "2021-01-04T12:41:28Z")

</div>

Hello, I’d have the following usage question. If I have a function with a for loop inside, like: function f() for i in 1:2 end end And I call @code\_warntype on it, i get a yellow line: @code\_warntype f() V…

---

## [Parallel independent loops in julia](https://discourse.julialang.org/t/parallel-independent-loops-in-julia/52737)

<div class="topic-metadata">

**Author:** [@Nishan](https://discourse.julialang.org/u/Nishan)\
**Replies:** 5\
**Last updated:** [January 3, 2021, 2:55pm UTC](https://discourse.julialang.org/t/parallel-independent-loops-in-julia/52737 "2021-01-03T14:55:07Z")

</div>

Hello everyone, I am new to julia and currently I am converting my tensor networks codes from python to julia and till now it seems great and I could do it without much pain and just by rewriting it in julia I have gaine…

---

## [Spdiagm allocation madness](https://discourse.julialang.org/t/spdiagm-allocation-madness/52703)

<div class="topic-metadata">

**Author:** [@ctkelley](https://discourse.julialang.org/u/ctkelley)\
**Replies:** 2\
**Last updated:** [January 2, 2021, 10:07pm UTC](https://discourse.julialang.org/t/spdiagm-allocation-madness/52703 "2021-01-02T22:07:14Z")

</div>

I am seeing surprisingly large allocations from spdiagm. The compute times are ok for what I need to do, so perhaps this is a case where large allocations do not harm. Here’s the story. I compute the discrete negative…

---

## [The @avx and @btime macros: strange interdependency](https://discourse.julialang.org/t/the-avx-and-btime-macros-strange-interdependency/52698)

<div class="topic-metadata">

**Author:** [@VivMendes](https://discourse.julialang.org/u/VivMendes)\
**Replies:** 4\
**Last updated:** [January 1, 2021, 6:13pm UTC](https://discourse.julialang.org/t/the-avx-and-btime-macros-strange-interdependency/52698 "2021-01-01T18:13:50Z")

</div>

I am a newbie to Julia, and I came up with a script to produce a bifurcation diagram for the logistic map. The logistic map is well known and I will be brief here: x(t+1) = r\*x(t)\*(1-x(t)), 0 ≤ r ≤ 4. For accuracy, I cho…

---

## [Performance problems when dealing with deliberately type-unstable code. How to use type knowledge better?](https://discourse.julialang.org/t/performance-problems-when-dealing-with-deliberately-type-unstable-code-how-to-use-type-knowledge-better/52535)

<div class="topic-metadata">

**Author:** [@jules](https://discourse.julialang.org/u/jules)\
**Replies:** 33\
**Last updated:** [December 30, 2020, 1:47pm UTC](https://discourse.julialang.org/t/performance-problems-when-dealing-with-deliberately-type-unstable-code-how-to-use-type-knowledge-better/52535 "2020-12-30T13:47:40Z")

</div>

I have a problem that crops up again and again, which relates to the use of different concrete types in situations where I can’t possibly establish type stability. Here’s a contrived example: There are three different su…

---

## [Filter array of CartesianIndex based on x-value](https://discourse.julialang.org/t/filter-array-of-cartesianindex-based-on-x-value/52583)

<div class="topic-metadata">

**Author:** [@zxjroger](https://discourse.julialang.org/u/zxjroger)\
**Replies:** 9\
**Last updated:** [December 30, 2020, 8:35am UTC](https://discourse.julialang.org/t/filter-array-of-cartesianindex-based-on-x-value/52583 "2020-12-30T08:35:35Z")

</div>

I have a vector of Cartesian indexes, for example: temp = \[CartesianIndex(3, 1), CartesianIndex(2, 2), CartesianIndex(6, 3), CartesianIndex(3, 4), CartesianIndex(1, 5), CartesianIndex(5, 6), CartesianIndex(1, 7…

---

## ["Pluto" memory usage](https://discourse.julialang.org/t/pluto-memory-usage/52493)

<div class="topic-metadata">

**Author:** [@vshesh](https://discourse.julialang.org/u/vshesh)\
**Replies:** 9\
**Last updated:** [December 29, 2020, 7:59pm UTC](https://discourse.julialang.org/t/pluto-memory-usage/52493 "2020-12-29T19:59:16Z")

</div>

I had a session of pluto open and I was doing some standard machine learning tasks, like: loading a data frame with ~3000 entries doing some clustering training some models evaluating some models making plots to see wh…

---

## [Fastest way to filter when right hand sinde of \`in\` is large](https://discourse.julialang.org/t/fastest-way-to-filter-when-right-hand-sinde-of-in-is-large/52526)

<div class="topic-metadata">

**Author:** [@danielw2904](https://discourse.julialang.org/u/danielw2904)\
**Replies:** 3\
**Last updated:** [December 28, 2020, 6:48pm UTC](https://discourse.julialang.org/t/fastest-way-to-filter-when-right-hand-sinde-of-in-is-large/52526 "2020-12-28T18:48:41Z")

</div>

I’m facing a problem where I would like to filter a dataset by using only those IDs that occur in another vector (that is around 100,000 elements long). If I just use in that takes forever as, I assume it checks every el…

---

## [Fastest way to run a for loop in parallel](https://discourse.julialang.org/t/fastest-way-to-run-a-for-loop-in-parallel/52477)

<div class="topic-metadata">

**Author:** [@rcesarpacheco](https://discourse.julialang.org/u/rcesarpacheco)\
**Replies:** 4\
**Last updated:** [December 27, 2020, 10:58pm UTC](https://discourse.julialang.org/t/fastest-way-to-run-a-for-loop-in-parallel/52477 "2020-12-27T22:58:02Z")

</div>

I am a new user of Julia and I am trying to run a for loop in parallel using .Threads but I don’t know if this is the fastest way that I can do this. The for loop is: res = zeros(length(posicao),2) Threads.@thr…

---

## [A data struct is required almost all sub functions](https://discourse.julialang.org/t/a-data-struct-is-required-almost-all-sub-functions/52360)

<div class="topic-metadata">

**Author:** [@chkwon](https://discourse.julialang.org/u/chkwon)\
**Replies:** 3\
**Last updated:** [December 25, 2020, 11:06am UTC](https://discourse.julialang.org/t/a-data-struct-is-required-almost-all-sub-functions/52360 "2020-12-25T11:06:25Z")

</div>

Merry Christmas, everyone. I have a struct containing all data required for running an algorithm to solve the problem, say: struct ProblemData x :: Float64 y :: Vector{Float64} z :: Matrix{Float64} end Thi…

---

## [Julia simple String process and file I/O is slow](https://discourse.julialang.org/t/julia-simple-string-process-and-file-i-o-is-slow/52112)

<div class="topic-metadata">

**Author:** [@vedasulo](https://discourse.julialang.org/u/vedasulo)\
**Replies:** 12\
**Last updated:** [December 23, 2020, 2:43pm UTC](https://discourse.julialang.org/t/julia-simple-string-process-and-file-i-o-is-slow/52112 "2020-12-23T14:43:07Z")

</div>

I was doing i/o in julia from string. Code as follows function func(strd) a = Any\[\]; for url in split(replace(strd, "\\n" =\> ""), "✖") if occursin(".",url) push!(a, url); end end …

---

## [Array concatenation results in type inconsistency](https://discourse.julialang.org/t/array-concatenation-results-in-type-inconsistency/52237)

<div class="topic-metadata">

**Author:** [@a-ill](https://discourse.julialang.org/u/a-ill)\
**Replies:** 8\
**Last updated:** [December 22, 2020, 7:24pm UTC](https://discourse.julialang.org/t/array-concatenation-results-in-type-inconsistency/52237 "2020-12-22T19:24:10Z")

</div>

Here is an example. function test\_func() array1 = rand(Float64,10,10) array2 = rand(Float64,10,10) out = cat(array1,array2,dims=1) return out end @code\_warntype test\_func() Variables #self#::Core.Comp…

---

## [Hashing tuples of tuples is seemingly very slow](https://discourse.julialang.org/t/hashing-tuples-of-tuples-is-seemingly-very-slow/52223)

<div class="topic-metadata">

**Author:** [@rdl](https://discourse.julialang.org/u/rdl)\
**Replies:** 6\
**Last updated:** [December 22, 2020, 11:15am UTC](https://discourse.julialang.org/t/hashing-tuples-of-tuples-is-seemingly-very-slow/52223 "2020-12-22T11:15:10Z")

</div>

I’ve been using Julia to complete advent of code this year. Today’s problem had a part which naturally lent itself to storing pairs of tuples of integers in a set. My program was running far more slowly that I expected t…

---

## [Speed of broadcast operations](https://discourse.julialang.org/t/speed-of-broadcast-operations/52113)

<div class="topic-metadata">

**Author:** [@rakeshvar](https://discourse.julialang.org/u/rakeshvar)\
**Replies:** 4\
**Last updated:** [December 22, 2020, 5:36am UTC](https://discourse.julialang.org/t/speed-of-broadcast-operations/52113 "2020-12-22T05:36:02Z")

</div>

:bowing\_man: M, N = 10000, 10000 a = randn((M, N)); ssa = sum(a); sa=sum(a, dims=1); @btime a .- ssa .- sa; @btime a .- sa .- ssa; @btime a .- (sa .+ ssa); 287.707 ms …

---

## [Growing memory with broadcast assignment](https://discourse.julialang.org/t/growing-memory-with-broadcast-assignment/52206)

<div class="topic-metadata">

**Author:** [@ancorso](https://discourse.julialang.org/u/ancorso)\
**Replies:** 6\
**Last updated:** [December 22, 2020, 1:37am UTC](https://discourse.julialang.org/t/growing-memory-with-broadcast-assignment/52206 "2020-12-22T01:37:12Z")

</div>

Here is a MWE of the problem: function foo!(v) i = rand(1:size(v, 4) - 3) v\[:,:,:,i:i+3\] .= 1. end v = Array{Float32}(undef, 105, 80, 4, 50000) for i=1:50000 foo!(v) end When I run the code, julia’s memory…

---

## [Very simple code, why would there be performance problems](https://discourse.julialang.org/t/very-simple-code-why-would-there-be-performance-problems/51848)

<div class="topic-metadata">

**Author:** [@Zq\_F](https://discourse.julialang.org/u/Zq_F)\
**Replies:** 12\
**Last updated:** [December 21, 2020, 1:25am UTC](https://discourse.julialang.org/t/very-simple-code-why-would-there-be-performance-problems/51848 "2020-12-21T01:25:21Z")

</div>

Hello, everyone Very simple code, the speed is really slow, I suspect that the method of using Ref in the structure is wrong Everyone, please take a look, thank you mutable struct T3 f1::Int64 f2::String f3::Fl…

---

## [Custom array index, multiple index one value](https://discourse.julialang.org/t/custom-array-index-multiple-index-one-value/52041)

<div class="topic-metadata">

**Author:** [@Atomtomate](https://discourse.julialang.org/u/Atomtomate)\
**Replies:** 4\
**Last updated:** [December 20, 2020, 1:32pm UTC](https://discourse.julialang.org/t/custom-array-index-multiple-index-one-value/52041 "2020-12-20T13:32:38Z")

</div>

Hello there, my question is about the optimal way to realize the following data structure in Julia: I have a couple of very large rank 4 arrays from a numerical simulation. Typical, these have around 500^4 complex valu…

---

## [How fast ist a binary file from packagecomplier.jl and what is its file size](https://discourse.julialang.org/t/how-fast-ist-a-binary-file-from-packagecomplier-jl-and-what-is-its-file-size/51415)

<div class="topic-metadata">

**Author:** [@boroboro77](https://discourse.julialang.org/u/boroboro77)\
**Replies:** 3\
**Last updated:** [December 19, 2020, 11:20pm UTC](https://discourse.julialang.org/t/how-fast-ist-a-binary-file-from-packagecomplier-jl-and-what-is-its-file-size/51415 "2020-12-19T23:20:03Z")

</div>

Hello, If I create a binary file using packagecompliler.jl, will the code be as (or almost as) fast as a C++ binary file? Or are there any hidden performance issues? If I use any external library, will the size of the…

---

## [SIMD and compiled code](https://discourse.julialang.org/t/simd-and-compiled-code/52082)

<div class="topic-metadata">

**Author:** [@lungben](https://discourse.julialang.org/u/lungben)\
**Replies:** 5\
**Last updated:** [December 19, 2020, 4:33pm UTC](https://discourse.julialang.org/t/simd-and-compiled-code/52082 "2020-12-19T16:33:14Z")

</div>

Hi, Different processors have different SIMD capabilities, especially different vector sizes on which the processor can work at once. However, there are a few points w.r.t. code compilation which I am not sure about. I…

---

## [Can you beat our solutions for the raindrops exercise?](https://discourse.julialang.org/t/can-you-beat-our-solutions-for-the-raindrops-exercise/52006)

<div class="topic-metadata">

**Author:** [@Luapulu](https://discourse.julialang.org/u/Luapulu)\
**Replies:** 16\
**Last updated:** [December 18, 2020, 8:29pm UTC](https://discourse.julialang.org/t/can-you-beat-our-solutions-for-the-raindrops-exercise/52006 "2020-12-18T20:29:48Z")

</div>

So, @cmcaine, @SaschaMann, @tomerarnon and I have been discussing the raindrops exercise in Exercism and solutions to it. The ExerciseCreate a function raindrops, which will return a string given a number as follows: …

---

## [Fast reading of multiple big-endian binary files](https://discourse.julialang.org/t/fast-reading-of-multiple-big-endian-binary-files/52060)

<div class="topic-metadata">

**Author:** [@Thomas\_Lei](https://discourse.julialang.org/u/Thomas_Lei)\
**Replies:** 1\
**Last updated:** [December 18, 2020, 5:13pm UTC](https://discourse.julialang.org/t/fast-reading-of-multiple-big-endian-binary-files/52060 "2020-12-18T17:13:47Z")

</div>

Hi all, I have to read and preprocess a huge quantity of binary (big-endian) data from thousands of files. I managed to get everything to work properly, but my function is slow… However, as I’m a Julia beginner, I doubt…

---

## [Synchronizing 2 loops in multi-threading](https://discourse.julialang.org/t/synchronizing-2-loops-in-multi-threading/52015)

<div class="topic-metadata">

**Author:** [@dopamine](https://discourse.julialang.org/u/dopamine)\
**Replies:** 2\
**Last updated:** [December 18, 2020, 1:40pm UTC](https://discourse.julialang.org/t/synchronizing-2-loops-in-multi-threading/52015 "2020-12-18T13:40:13Z")

</div>

What’s the best way to synchronize 2 while loops, each running on its own thread? In the example below, loop1 runs 80 times per second while loop2 (blocking/IO) runs 20 times per second. Currently, without any locks/syn…

---

## [Tensor contractions very inefficient in julia](https://discourse.julialang.org/t/tensor-contractions-very-inefficient-in-julia/52016)

<div class="topic-metadata">

**Author:** [@Nishan](https://discourse.julialang.org/u/Nishan)\
**Replies:** 13\
**Last updated:** [December 18, 2020, 2:21am UTC](https://discourse.julialang.org/t/tensor-contractions-very-inefficient-in-julia/52016 "2020-12-18T02:21:40Z")

</div>

I am new to julia (just few days) and I want to shift from python to julia by rewriting my DMRG code in julia. For Tensor contractions in python I was using np.tensordot, I searched for equivalent packages in julia and t…

---

## [Julia Binary Heap Benchmark](https://discourse.julialang.org/t/julia-binary-heap-benchmark/51945)

<div class="topic-metadata">

**Author:** [@ndrsh](https://discourse.julialang.org/u/ndrsh)\
**Replies:** 12\
**Last updated:** [December 17, 2020, 10:25am UTC](https://discourse.julialang.org/t/julia-binary-heap-benchmark/51945 "2020-12-17T10:25:26Z")

</div>

Hey Community. Seems like it might be possible that Julia gets adopted at Codeforces. In order to make that happen I need to provide an implementation for this Binary Heap benchmark. My Julia code is quite ugly, becaus…

---

## [Is the type-instability in take!(::RemoteChannel) of practical concern?](https://discourse.julialang.org/t/is-the-type-instability-in-take-remotechannel-of-practical-concern/51864)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 1\
**Last updated:** [December 15, 2020, 12:15pm UTC](https://discourse.julialang.org/t/is-the-type-instability-in-take-remotechannel-of-practical-concern/51864 "2020-12-15T12:15:18Z")

</div>

For example: julia\> using Distributed julia\> r = RemoteChannel(()-\>Channel{Bool}(Inf)) RemoteChannel{Channel{Bool}}(1, 1, 1) julia\> @code\_warntype take!(r) Variables #self#::Core.Compiler.Const(take!, false) rr::R…

---

## [How to let the compiler know that a global variable is type-stable for duration of function](https://discourse.julialang.org/t/how-to-let-the-compiler-know-that-a-global-variable-is-type-stable-for-duration-of-function/51732)

<div class="topic-metadata">

**Author:** [@Deduction42](https://discourse.julialang.org/u/Deduction42)\
**Replies:** 6\
**Last updated:** [December 13, 2020, 6:43pm UTC](https://discourse.julialang.org/t/how-to-let-the-compiler-know-that-a-global-variable-is-type-stable-for-duration-of-function/51732 "2020-12-13T18:43:02Z")

</div>

I’m trying to run a simulation on a process where a process stream can contain various chemical components. For example, ethanol (C2H5OH) and water (H2). There’s a lot of places in the simulation where it makes sense to …

---

## [Pmap usage](https://discourse.julialang.org/t/pmap-usage/51718)

<div class="topic-metadata">

**Author:** [@jmurga](https://discourse.julialang.org/u/jmurga)\
**Replies:** 1\
**Last updated:** [December 13, 2020, 7:43am UTC](https://discourse.julialang.org/t/pmap-usage/51718 "2020-12-13T07:43:26Z")

</div>

Hi everyone, I am trying to execute a custom function in my own server using pmap function. The server accounts for two physical cpus and a 24 threads. The problem is at the second execution of the functions, the numbe…

---

## [Branching in loop decrease perf by ~x5](https://discourse.julialang.org/t/branching-in-loop-decrease-perf-by-x5/51387)

<div class="topic-metadata">

**Author:** [@wizebt](https://discourse.julialang.org/u/wizebt)\
**Replies:** 6\
**Last updated:** [December 13, 2020, 7:42am UTC](https://discourse.julialang.org/t/branching-in-loop-decrease-perf-by-x5/51387 "2020-12-13T07:42:11Z")

</div>

Hi, In Julia 1.3.x version extrema function use to be much slower that minimum + maximum execution. At that time I wrote my own specialized extrema function and gained ~x3 by avoiding one test out of the two in each ite…

---

## [Mul! vs SparseMatrix](https://discourse.julialang.org/t/mul-vs-sparsematrix/51720)

<div class="topic-metadata">

**Author:** [@ctkelley](https://discourse.julialang.org/u/ctkelley)\
**Replies:** 2\
**Last updated:** [December 12, 2020, 10:22pm UTC](https://discourse.julialang.org/t/mul-vs-sparsematrix/51720 "2020-12-12T22:22:55Z")

</div>

I’m trying to use mul! to compute the product of a sparse matrix and a sparse diagonal matrix. My problem is that mul! allocates very litte, but takes a lot more time than a matrix multiply. Is this what’s supposed to h…

---

## [NamedTuple type is unstable, or my usage is wrong?](https://discourse.julialang.org/t/namedtuple-type-is-unstable-or-my-usage-is-wrong/51644)

<div class="topic-metadata">

**Author:** [@Zq\_F](https://discourse.julialang.org/u/Zq_F)\
**Replies:** 5\
**Last updated:** [December 12, 2020, 4:56pm UTC](https://discourse.julialang.org/t/namedtuple-type-is-unstable-or-my-usage-is-wrong/51644 "2020-12-12T16:56:45Z")

</div>

Hello everyone help me see a question, I want to define a NamedTuple type that can accept multiple parameters, but I can’t do it well. pm::NamedTuple((:b, ),Tuple(Int64)) #This definition is fast, but it can only accep…

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

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