# Performance

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

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

**Page:** 88

---

## [LoopVectorization triggers segfault or deadlock for complex finite difference stencil](https://discourse.julialang.org/t/loopvectorization-triggers-segfault-or-deadlock-for-complex-finite-difference-stencil/65217)

<div class="topic-metadata">

**Author:** [@Chiil](https://discourse.julialang.org/u/Chiil)\
**Replies:** 1\
**Last updated:** [July 27, 2021, 3:54pm UTC](https://discourse.julialang.org/t/loopvectorization-triggers-segfault-or-deadlock-for-complex-finite-difference-stencil/65217 "2021-07-27T15:54:04Z")

</div>

I have written a finite difference 4th-order stencil generator macro and use the @tturbo to accelerate my loop. My code gives perfect results for a single thread run, but triggers either a segfault or a deadlock in multi…

---

## [How to create an empty TimeArray](https://discourse.julialang.org/t/how-to-create-an-empty-timearray/65372)

<div class="topic-metadata">

**Author:** [@Yuan\_Jiun\_Thai](https://discourse.julialang.org/u/Yuan_Jiun_Thai)\
**Replies:** 1\
**Last updated:** [July 27, 2021, 2:55pm UTC](https://discourse.julialang.org/t/how-to-create-an-empty-timearray/65372 "2021-07-27T14:55:47Z")

</div>

How could I create an empty Time Array? I would like to “vcat” a few TimeArrays using for loop, but I would need an empty TimeArray to initialize the for loop. May I know how could I do that?

---

## [Add testing for memory allocations](https://discourse.julialang.org/t/add-testing-for-memory-allocations/49398)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 13\
**Last updated:** [July 27, 2021, 8:32am UTC](https://discourse.julialang.org/t/add-testing-for-memory-allocations/49398 "2021-07-27T08:32:21Z")

</div>

In the last few days I have been working in eliminating all unnecessary allocations in a package, found some type-instabilities, etc, and everything is much better now. I created, then, a set of tests to evaluate if, in…

---

## [Reduce allocations and speed up](https://discourse.julialang.org/t/reduce-allocations-and-speed-up/65221)

<div class="topic-metadata">

**Author:** [@daviddoij](https://discourse.julialang.org/u/daviddoij)\
**Replies:** 15\
**Last updated:** [July 27, 2021, 1:12am UTC](https://discourse.julialang.org/t/reduce-allocations-and-speed-up/65221 "2021-07-27T01:12:50Z")

</div>

Hi there, in my attempt to teach myself Julia, I’m solving Project Euler problems. The following code works and give the correct answer, although I was expecting better performance, as the time is similar to what I got …

---

## [Could this function be faster?](https://discourse.julialang.org/t/could-this-function-be-faster/64710)

<div class="topic-metadata">

**Author:** [@babaq](https://discourse.julialang.org/u/babaq)\
**Replies:** 13\
**Last updated:** [July 27, 2021, 12:03am UTC](https://discourse.julialang.org/t/could-this-function-be-faster/64710 "2021-07-27T00:03:20Z")

</div>

Hi, I recently have to read raw images from a camera. The pixel format is Mono color 12bit packed. I first tried a MATLAB version which managed to read&unpack in ~30ms for a 2080\*2080 image. Here is a julia version…

---

## [Discussion on ThreadPools.jl](https://discourse.julialang.org/t/discussion-on-threadpools-jl/65283)

<div class="topic-metadata">

**Author:** [@tkf](https://discourse.julialang.org/u/tkf)\
**Replies:** 5\
**Last updated:** [July 26, 2021, 6:59pm UTC](https://discourse.julialang.org/t/discussion-on-threadpools-jl/65283 "2021-07-26T18:59:02Z")

</div>

Continuing the discussion from Multithreaded compute farm: @tkf could you explain this a little more? I always assumed / hoped that ThreadPools would eventually be made obsolete by Julia’s evolution, but I haven’t seen…

---

## [Fastest way to partition array, given a condition](https://discourse.julialang.org/t/fastest-way-to-partition-array-given-a-condition/65243)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 26\
**Last updated:** [July 26, 2021, 6:27pm UTC](https://discourse.julialang.org/t/fastest-way-to-partition-array-given-a-condition/65243 "2021-07-26T18:27:00Z")

</div>

I need to sort (usually small, i. e. 5 to 20 elements, but the algorithm cannot scale badly) arrays, but only partially. That is, I need that the elements get split into elements smaller than a cutoff, and elements great…

---

## [Multithreaded compute farm](https://discourse.julialang.org/t/multithreaded-compute-farm/65047)

<div class="topic-metadata">

**Author:** [@nabla](https://discourse.julialang.org/u/nabla)\
**Replies:** 26\
**Last updated:** [July 26, 2021, 3:14pm UTC](https://discourse.julialang.org/t/multithreaded-compute-farm/65047 "2021-07-26T15:14:14Z")

</div>

I searched for a function in Julia that creates a “compute farm” based on a channel: workers take tasks from a channel and put back 0 or more tasks to the same channel. (many mathematical problems seem to be approachable…

---

## [Speed up column looping in matrix](https://discourse.julialang.org/t/speed-up-column-looping-in-matrix/65295)

<div class="topic-metadata">

**Author:** [@HJW019](https://discourse.julialang.org/u/HJW019)\
**Replies:** 6\
**Last updated:** [July 26, 2021, 1:54pm UTC](https://discourse.julialang.org/t/speed-up-column-looping-in-matrix/65295 "2021-07-26T13:54:23Z")

</div>

I am working on a project where one of the functions is the bottleneck of speed. The problem seems to do with accessing a large matrix. I’d appreciate any advice to improve the code. The problem is represented by the fo…

---

## [How to improve performance of sum()](https://discourse.julialang.org/t/how-to-improve-performance-of-sum/64928)

<div class="topic-metadata">

**Author:** [@andrewkhardy](https://discourse.julialang.org/u/andrewkhardy)\
**Replies:** 19\
**Last updated:** [July 19, 2021, 8:13pm UTC](https://discourse.julialang.org/t/how-to-improve-performance-of-sum/64928 "2021-07-19T20:13:40Z")

</div>

Hello. I recently tried out Julia because I was hoping for a speed improvement over numpy.sum(). I’m trying to benchmark a sum for a 2D integral and so far my Julia code is much slower. I’m wondering if there’s any perf…

---

## [Overwrite the subdataframes made with a for loop](https://discourse.julialang.org/t/overwrite-the-subdataframes-made-with-a-for-loop/65176)

<div class="topic-metadata">

**Author:** [@bojusemo](https://discourse.julialang.org/u/bojusemo)\
**Replies:** 10\
**Last updated:** [July 26, 2021, 1:54am UTC](https://discourse.julialang.org/t/overwrite-the-subdataframes-made-with-a-for-loop/65176 "2021-07-26T01:54:42Z")

</div>

Hi Guys, Could someone help me, please? I have a function with two dataframes (df1 and df2) as input that filter df1 based on a column that contains unique identifiers (IDs) and creates a subdataframe, makes a series o…

---

## [Avoiding memory allocation when repeatedly using small arrays](https://discourse.julialang.org/t/avoiding-memory-allocation-when-repeatedly-using-small-arrays/65261)

<div class="topic-metadata">

**Author:** [@weymouth](https://discourse.julialang.org/u/weymouth)\
**Replies:** 5\
**Last updated:** [July 25, 2021, 5:13pm UTC](https://discourse.julialang.org/t/avoiding-memory-allocation-when-repeatedly-using-small-arrays/65261 "2021-07-25T17:13:11Z")

</div>

I often find myself needing fairly simple, small autodiff vector operations applied repeatedly. I don’t know how to do this without allocation each time. Is it possible? Here is an example where I’m integrating an array…

---

## [Naive dot product faster in Fortran than in Juila](https://discourse.julialang.org/t/naive-dot-product-faster-in-fortran-than-in-juila/63317)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 12\
**Last updated:** [July 24, 2021, 11:03pm UTC](https://discourse.julialang.org/t/naive-dot-product-faster-in-fortran-than-in-juila/63317 "2021-07-24T23:03:42Z")

</div>

Does anyone knows why this simple dot product is faster in Fortran then in Julia? (LinearAlgebra.dot is faster and with LoopVectorization the Julia code gets also faster. but this is not what I am questioning. I am curi…

---

## [Why does Julia allocate memory when I already pre-allocated?](https://discourse.julialang.org/t/why-does-julia-allocate-memory-when-i-already-pre-allocated/65223)

<div class="topic-metadata">

**Author:** [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Replies:** 5\
**Last updated:** [July 24, 2021, 9:25am UTC](https://discourse.julialang.org/t/why-does-julia-allocate-memory-when-i-already-pre-allocated/65223 "2021-07-24T09:25:16Z")

</div>

Look at the code here. julia\> results = Vector{Int}(undef, 10^7); julia\> @time for i in 1:10^7 results\[i\] = i end 0.315568 seconds (20.00 M allocations: 305.160 MiB, 5.86% gc time) Why is there mem…

---

## [Iterators over observations/data](https://discourse.julialang.org/t/iterators-over-observations-data/65158)

<div class="topic-metadata">

**Author:** [@stephancb](https://discourse.julialang.org/u/stephancb)\
**Replies:** 1\
**Last updated:** [July 23, 2021, 3:39pm UTC](https://discourse.julialang.org/t/iterators-over-observations-data/65158 "2021-07-23T15:39:32Z")

</div>

Is there a reason why in StatsBase fit(Histogram, obs::AbstractArray, bins,...) does not accept an iterator over the observations? Possible sources of observations are streams, csv files, databases etc. To just bin them…

---

## [Making RNG's fast](https://discourse.julialang.org/t/making-rngs-fast/65129)

<div class="topic-metadata">

**Author:** [@viraltux](https://discourse.julialang.org/u/viraltux)\
**Replies:** 4\
**Last updated:** [July 22, 2021, 9:28pm UTC](https://discourse.julialang.org/t/making-rngs-fast/65129 "2021-07-22T21:28:16Z")

</div>

I am playing around with RNG’s, specifically this one: function squares(ctr::UInt64, key::UInt64)::UInt32 y = x = ctr \* key; z = y + key x = x\*x + y; x = (x\>\>32) | (x\<\<32) # round 1 x = x\*x + z; x = (…

---

## [Should I use HDF5 to speed up reading image data repeatedly?](https://discourse.julialang.org/t/should-i-use-hdf5-to-speed-up-reading-image-data-repeatedly/57576)

<div class="topic-metadata">

**Author:** [@kimlaberinto](https://discourse.julialang.org/u/kimlaberinto)\
**Replies:** 12\
**Last updated:** [July 22, 2021, 6:45pm UTC](https://discourse.julialang.org/t/should-i-use-hdf5-to-speed-up-reading-image-data-repeatedly/57576 "2021-07-22T18:45:46Z")

</div>

Hi all, I’m trying to speed-up the following piece of code for an art project. I have a collection of png images. All of them together is 25GB+ And in a loop, I need to keep copying an arbitrary pixel in one of the pn…

---

## [Comparing Julia and Python for basic operations](https://discourse.julialang.org/t/comparing-julia-and-python-for-basic-operations/65087)

<div class="topic-metadata">

**Author:** [@daviddoij](https://discourse.julialang.org/u/daviddoij)\
**Replies:** 8\
**Last updated:** [July 22, 2021, 12:50pm UTC](https://discourse.julialang.org/t/comparing-julia-and-python-for-basic-operations/65087 "2021-07-22T12:50:33Z")

</div>

Hi there Julia community!, I’m quite new to the language and I’m falling in love more and more with it every day :slight\_smile: In order to improve my knowledge, I’m revisiting Project Euler problems, which I’ve done i…

---

## [Performance of abstract argument in methods](https://discourse.julialang.org/t/performance-of-abstract-argument-in-methods/65066)

<div class="topic-metadata">

**Author:** [@filchristou](https://discourse.julialang.org/u/filchristou)\
**Replies:** 2\
**Last updated:** [July 21, 2021, 9:50pm UTC](https://discourse.julialang.org/t/performance-of-abstract-argument-in-methods/65066 "2021-07-21T21:50:20Z")

</div>

It occurs to me, maybe mistakenly, that there is a tendency to believe that being precise with your type arguments in functions also gives you performant code. Performance Tips doesn’t explicitly mention something like t…

---

## [Multi-threadded processing of large number of files faster when reading in batch](https://discourse.julialang.org/t/multi-threadded-processing-of-large-number-of-files-faster-when-reading-in-batch/64968)

<div class="topic-metadata">

**Author:** [@Tomas\_Pevny](https://discourse.julialang.org/u/Tomas_Pevny)\
**Replies:** 10\
**Last updated:** [July 21, 2021, 1:27pm UTC](https://discourse.julialang.org/t/multi-threadded-processing-of-large-number-of-files-faster-when-reading-in-batch/64968 "2021-07-21T13:27:17Z")

</div>

Dear All, I would like to ask a question about a behavior of multi-threadding. My usecase is following. I have on disk 800 000 files containing compressed JSONs, and I want to find those containing some predefined set o…

---

## [How can I speed up my Neural ODE?](https://discourse.julialang.org/t/how-can-i-speed-up-my-neural-ode/64848)

<div class="topic-metadata">

**Author:** [@Antonino\_Gandolfo](https://discourse.julialang.org/u/Antonino_Gandolfo)\
**Replies:** 4\
**Last updated:** [July 20, 2021, 3:14pm UTC](https://discourse.julialang.org/t/how-can-i-speed-up-my-neural-ode/64848 "2021-07-20T15:14:12Z")

</div>

Hi @ChrisRackauckas , I would like to ask you how can I speed up my code. I tried to do a system identification about an HVAC system. Here’s the code: using CSV,DataFrames,DifferentialEquations,Plots,Flux,DiffEqFlux,…

---

## [NLopt - Same complex clalculations in objetive function and nonlinear constraints](https://discourse.julialang.org/t/nlopt-same-complex-clalculations-in-objetive-function-and-nonlinear-constraints/41677)

<div class="topic-metadata">

**Author:** [@wg030](https://discourse.julialang.org/u/wg030)\
**Replies:** 17\
**Last updated:** [July 19, 2021, 1:31pm UTC](https://discourse.julialang.org/t/nlopt-same-complex-clalculations-in-objetive-function-and-nonlinear-constraints/41677 "2021-07-19T13:31:52Z")

</div>

Hey guys, I need a hint on how to effectivley solve a nonlinear optimization problem with NLopt package when my objective function contains some complex calculations and my nonlinear constraint contains the same complex…

---

## [Compilation does not terminate (\>3 hours) with nested numerical integration](https://discourse.julialang.org/t/compilation-does-not-terminate-3-hours-with-nested-numerical-integration/64922)

<div class="topic-metadata">

**Author:** [@meew0](https://discourse.julialang.org/u/meew0)\
**Replies:** 0\
**Last updated:** [July 19, 2021, 11:30am UTC](https://discourse.julialang.org/t/compilation-does-not-terminate-3-hours-with-nested-numerical-integration/64922 "2021-07-19T11:30:58Z")

</div>

I am trying to do two-dimensional numerical integration. For this my first attempt was something like the following, using DoubleExponentialFormulas.jl. This example is significantly reduced and no longer does anything m…

---

## [Strange performance characteristics and regression with tuple recursion](https://discourse.julialang.org/t/strange-performance-characteristics-and-regression-with-tuple-recursion/64888)

<div class="topic-metadata">

**Author:** [@jfeist](https://discourse.julialang.org/u/jfeist)\
**Replies:** 5\
**Last updated:** [July 19, 2021, 10:14am UTC](https://discourse.julialang.org/t/strange-performance-characteristics-and-regression-with-tuple-recursion/64888 "2021-07-19T10:14:09Z")

</div>

I have a custom iterator that produces the unique indices of an M-dimensional array with exchange symmetry (i.e., where the value is the same for any permutation of the indices), which is the same as the nonzero indices …

---

## [Squeeze out the last 10% of performance for a sorting function?](https://discourse.julialang.org/t/squeeze-out-the-last-10-of-performance-for-a-sorting-function/64539)

<div class="topic-metadata">

**Author:** [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Replies:** 26\
**Last updated:** [July 18, 2021, 11:55pm UTC](https://discourse.julialang.org/t/squeeze-out-the-last-10-of-performance-for-a-sorting-function/64539 "2021-07-18T23:55:42Z")

</div>

I wrote a straightforward implementation of the insertion sort algorithm in Julia below. Then I wrote the exact translation in C to compare with Julia. I noticed a performance gap of about 10% in favor of C implementatio…

---

## [Why loading a Package is slow (Julia 1.6)](https://discourse.julialang.org/t/why-loading-a-package-is-slow-julia-1-6/64868)

<div class="topic-metadata">

**Author:** [@filchristou](https://discourse.julialang.org/u/filchristou)\
**Replies:** 1\
**Last updated:** [July 18, 2021, 7:00pm UTC](https://discourse.julialang.org/t/why-loading-a-package-is-slow-julia-1-6/64868 "2021-07-18T19:00:53Z")

</div>

I know that there has been a lot of conversation in the past about this, but most of the questions end with a response like “in Julia 1.6 the loading time will be much better”. Since we are in Julia 1.6 I would like to …

---

## [StaticArrays compilation performance bug](https://discourse.julialang.org/t/staticarrays-compilation-performance-bug/64811)

<div class="topic-metadata">

**Author:** [@nabla](https://discourse.julialang.org/u/nabla)\
**Replies:** 4\
**Last updated:** [July 18, 2021, 4:26am UTC](https://discourse.julialang.org/t/staticarrays-compilation-performance-bug/64811 "2021-07-18T04:26:01Z")

</div>

I also posted this as a StaticArrays issue: with Julia 1.7 and StaticArrays v0.12.5: julia\> N = 14; m = SMatrix{N,N}(rand(N,N)); julia\> x-\>x\*m # works fine #1 (generic function with 1 method) julia\> @time \[x-\>x\*g for …

---

## [How to reduce large memory allocation by lu! with sparse matrices](https://discourse.julialang.org/t/how-to-reduce-large-memory-allocation-by-lu-with-sparse-matrices/64791)

<div class="topic-metadata">

**Author:** [@YukiyaSaito](https://discourse.julialang.org/u/YukiyaSaito)\
**Replies:** 8\
**Last updated:** [July 17, 2021, 9:12pm UTC](https://discourse.julialang.org/t/how-to-reduce-large-memory-allocation-by-lu-with-sparse-matrices/64791 "2021-07-17T21:12:54Z")

</div>

In my code, I have to solve a large sparse linear system (14000 x 14000) many times to integrate a stiff system of ODE. Since the memory allocation by the backslash operator \\ is quite large, I thought of manually perfo…

---

## [Trouble creating a type to be a vector of another defined type](https://discourse.julialang.org/t/trouble-creating-a-type-to-be-a-vector-of-another-defined-type/64786)

<div class="topic-metadata">

**Author:** [@mistamista](https://discourse.julialang.org/u/mistamista)\
**Replies:** 3\
**Last updated:** [July 17, 2021, 4:25am UTC](https://discourse.julialang.org/t/trouble-creating-a-type-to-be-a-vector-of-another-defined-type/64786 "2021-07-17T04:25:15Z")

</div>

So what I want to do is something like: Define a type Point that is constructed from floats passed by the user. This is supposed to store the coordinates of a point. struct Point x::Float64 y::Float64 end This works…

---

## [Counterintuitive array update allocations](https://discourse.julialang.org/t/counterintuitive-array-update-allocations/63490)

<div class="topic-metadata">

**Author:** [@ismedina](https://discourse.julialang.org/u/ismedina)\
**Replies:** 11\
**Last updated:** [July 17, 2021, 3:59am UTC](https://discourse.julialang.org/t/counterintuitive-array-update-allocations/63490 "2021-07-17T03:59:32Z")

</div>

I’ve run into a kind-of counterintuitive behavior when coding some example. I have an array A\_field, which I want to update by adding certain values in certain positions. These are provided by a an array of arrays of (fl…

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

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