# Performance

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

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

**Page:** 50

---

## [Base.accumulate! seems slow due to keyword argument handling, can it be sped up?](https://discourse.julialang.org/t/base-accumulate-seems-slow-due-to-keyword-argument-handling-can-it-be-sped-up/93650)

<div class="topic-metadata">

**Author:** [@taotree](https://discourse.julialang.org/u/taotree)\
**Replies:** 3\
**Last updated:** [February 3, 2023, 2:11pm UTC](https://discourse.julialang.org/t/base-accumulate-seems-slow-due-to-keyword-argument-handling-can-it-be-sped-up/93650 "2023-02-03T14:11:22Z")

</div>

Before I found accumulate, I had written a simple implementation. Then I was informed about accumulate! and tried using that. @btime’ing it showed allocations and that it took nearly twice as long to run as the implement…

---

## [Possible performance regression in 1.9 / StaticArrays](https://discourse.julialang.org/t/possible-performance-regression-in-1-9-staticarrays/93422)

<div class="topic-metadata">

**Author:** [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Replies:** 11\
**Last updated:** [February 3, 2023, 1:07pm UTC](https://discourse.julialang.org/t/possible-performance-regression-in-1-9-staticarrays/93422 "2023-02-03T13:07:59Z")

</div>

This is a followup from: Accelerating an N^2 nested loop - #14 by lmiq I have the following code, which tries to compute some sort of acceleration for particles. There is an implementation based on standard 1D arrays to…

---

## [How to benchmark in-place functions?](https://discourse.julialang.org/t/how-to-benchmark-in-place-functions/36493)

<div class="topic-metadata">

**Author:** [@mlanghinrichs](https://discourse.julialang.org/u/mlanghinrichs)\
**Replies:** 8\
**Last updated:** [February 3, 2023, 12:32pm UTC](https://discourse.julialang.org/t/how-to-benchmark-in-place-functions/36493 "2023-02-03T12:32:13Z")

</div>

Hi all, I wondered how to benchmark functions correctly that modify always the same input in-place. In particular, using the @btime macro of BenchmarkTools.jl. For example consider the following minimal code: using Ben…

---

## [Based on which packages is Base.Threads built?](https://discourse.julialang.org/t/based-on-which-packages-is-base-threads-built/93930)

<div class="topic-metadata">

**Author:** [@Amro](https://discourse.julialang.org/u/Amro)\
**Replies:** 4\
**Last updated:** [February 3, 2023, 12:01pm UTC](https://discourse.julialang.org/t/based-on-which-packages-is-base-threads-built/93930 "2023-02-03T12:01:47Z")

</div>

I am happy to use the functions in Base.Threads, and I am carious to know that based on which packages this Base.Threads is built? is it OneAPI, OpenMP, etc.?

---

## [Globals / Constants Act Differently Depending on Use?](https://discourse.julialang.org/t/globals-constants-act-differently-depending-on-use/93933)

<div class="topic-metadata">

**Author:** [@dkzwart](https://discourse.julialang.org/u/dkzwart)\
**Replies:** 2\
**Last updated:** [February 2, 2023, 5:38pm UTC](https://discourse.julialang.org/t/globals-constants-act-differently-depending-on-use/93933 "2023-02-02T17:38:45Z")

</div>

I’ve been doing a lot of reading on Constants and Globals, and I realize I really don’t understand what I am reading. Having said that, can you all help me understand why var1 is undefined in the function? It seems to be…

---

## [Avoiding Allocations with User provided Closures](https://discourse.julialang.org/t/avoiding-allocations-with-user-provided-closures/31279)

<div class="topic-metadata">

**Author:** [@cshenton](https://discourse.julialang.org/u/cshenton)\
**Replies:** 12\
**Last updated:** [February 2, 2023, 3:29am UTC](https://discourse.julialang.org/t/avoiding-allocations-with-user-provided-closures/31279 "2023-02-02T03:29:41Z")

</div>

I’m writing a query API that allows a user to pass in a closure to be run on every entry satisfying the query, however this usually results in undesirable boxing. For example, here’s the kind of API I want to offer, with…

---

## [Why are two functions behave differently?](https://discourse.julialang.org/t/why-are-two-functions-behave-differently/93848)

<div class="topic-metadata">

**Author:** [@hungpham3112](https://discourse.julialang.org/u/hungpham3112)\
**Replies:** 2\
**Last updated:** [February 1, 2023, 5:53am UTC](https://discourse.julialang.org/t/why-are-two-functions-behave-differently/93848 "2023-02-01T05:53:30Z")

</div>

I’m doing some exercises in the ThinkJulia book. Specifically, I try to solve the exercise 10-10: Write a function that reads the file words.txt and builds an array with one element per word. Write two versions of thi…

---

## [Making an efficient function for ignoring unsupported kwargs](https://discourse.julialang.org/t/making-an-efficient-function-for-ignoring-unsupported-kwargs/93794)

<div class="topic-metadata">

**Author:** [@tictaccat](https://discourse.julialang.org/u/tictaccat)\
**Replies:** 4\
**Last updated:** [January 31, 2023, 4:45pm UTC](https://discourse.julialang.org/t/making-an-efficient-function-for-ignoring-unsupported-kwargs/93794 "2023-01-31T16:45:59Z")

</div>

Given a function f that may accept some keyword arguments, I want to make a function g that accepts any keyword arguments and ignores those that are unsupported by f. Below is code that achieves this goal: function igno…

---

## [Trying to translate a symbolic differentiation performance benchmark to Julia](https://discourse.julialang.org/t/trying-to-translate-a-symbolic-differentiation-performance-benchmark-to-julia/15735)

<div class="topic-metadata">

**Author:** [@Olof\_Salberger](https://discourse.julialang.org/u/Olof_Salberger)\
**Replies:** 3\
**Last updated:** [September 9, 2019, 1:23am UTC](https://discourse.julialang.org/t/trying-to-translate-a-symbolic-differentiation-performance-benchmark-to-julia/15735 "2019-09-09T01:23:58Z")

</div>

Hi, I was interested in translating Jon Harrop’s symbolic derivatives benchmark to Julia, but since the original code is really heavy on ADT’s and pattern matching I don’t really have a good intuition for what style woul…

---

## [Getting rid of memory allocations in nested functions](https://discourse.julialang.org/t/getting-rid-of-memory-allocations-in-nested-functions/93812)

<div class="topic-metadata">

**Author:** [@p-gw](https://discourse.julialang.org/u/p-gw)\
**Replies:** 3\
**Last updated:** [January 31, 2023, 9:31am UTC](https://discourse.julialang.org/t/getting-rid-of-memory-allocations-in-nested-functions/93812 "2023-01-31T09:31:06Z")

</div>

Hi, I am trying to minimize memory allocations of a function in my package. However, it displays some mysterious behaviour - at least for me. Since there are many experts here, maybe somebody can shed some light on wh…

---

## [Automatic resizing of struct internal array when value changes?](https://discourse.julialang.org/t/automatic-resizing-of-struct-internal-array-when-value-changes/93790)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 14\
**Last updated:** [January 30, 2023, 10:43pm UTC](https://discourse.julialang.org/t/automatic-resizing-of-struct-internal-array-when-value-changes/93790 "2023-01-30T22:43:41Z")

</div>

Hello! Suppose I have a struct as such: mutable struct TheStruct N::Int x::AbstractVector{Float32} end And at different times “N” might change, for example from 5 to 7. When this happens I want to resize!(…

---

## [Why is there a \`sleep\` in ODBC.jl](https://discourse.julialang.org/t/why-is-there-a-sleep-in-odbc-jl/93562)

<div class="topic-metadata">

**Author:** [@Impressium](https://discourse.julialang.org/u/Impressium)\
**Replies:** 14\
**Last updated:** [January 30, 2023, 9:26pm UTC](https://discourse.julialang.org/t/why-is-there-a-sleep-in-odbc-jl/93562 "2023-01-30T21:26:10Z")

</div>

Hi all :slight\_smile: Just reposting this here # By removing the sleep - query executes much faster #360 Does anyone know why there is an sleep? Does something horrible happen if I remove it? Cheers

---

## [Visualize long pmap process using Gtk.ProgressBarLeaf](https://discourse.julialang.org/t/visualize-long-pmap-process-using-gtk-progressbarleaf/93792)

<div class="topic-metadata">

**Author:** [@abbe](https://discourse.julialang.org/u/abbe)\
**Replies:** 0\
**Last updated:** [January 30, 2023, 8:51pm UTC](https://discourse.julialang.org/t/visualize-long-pmap-process-using-gtk-progressbarleaf/93792 "2023-01-30T20:51:53Z")

</div>

Hey all, I was wondering if it is possible to view the progress of the pmap function using GtkProgressBar when pmap is running on multiple (or all) processes. using Distributed, Statistics id = addprocs() @everywhere b…

---

## [@fastmath for library functions? (2x slowdown of binary search because of NaN checks in Base)](https://discourse.julialang.org/t/fastmath-for-library-functions-2x-slowdown-of-binary-search-because-of-nan-checks-in-base/93487)

<div class="topic-metadata">

**Author:** [@Az9DBvyVLWBjs8g](https://discourse.julialang.org/u/Az9DBvyVLWBjs8g)\
**Replies:** 14\
**Last updated:** [January 30, 2023, 7:15pm UTC](https://discourse.julialang.org/t/fastmath-for-library-functions-2x-slowdown-of-binary-search-because-of-nan-checks-in-base/93487 "2023-01-30T19:15:52Z")

</div>

Hello everyone, I’ve benchmarked Julia’s implementation of binary search (searchsortedlast) to test whether Julia can match C performance (spoiler: it can). However, I found that isnan checks within isless lead to a 1.5…

---

## [Reinterpret to existing vector](https://discourse.julialang.org/t/reinterpret-to-existing-vector/93706)

<div class="topic-metadata">

**Author:** [@CodeGodz](https://discourse.julialang.org/u/CodeGodz)\
**Replies:** 16\
**Last updated:** [January 29, 2023, 9:55am UTC](https://discourse.julialang.org/t/reinterpret-to-existing-vector/93706 "2023-01-29T09:55:50Z")

</div>

Lets say I have a byte (UInt8) array that looks like this: source = reinterpret(UInt8, Int64\[10,11\]) 0x0a 0x00 0x00 0x00 .... And an existing allocated array of two integers target = zeros(Int64, 2) I basically w…

---

## [How to see every allocating function call?](https://discourse.julialang.org/t/how-to-see-every-allocating-function-call/93654)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 1\
**Last updated:** [January 27, 2023, 8:34pm UTC](https://discourse.julialang.org/t/how-to-see-every-allocating-function-call/93654 "2023-01-27T20:34:25Z")

</div>

Hello! I have a small simulation program I made in Julia. I have a main function, that when I call it, it runs the whole function - lets call it Main(). Is there a macro similar to @profile for getting how many allocs …

---

## [Franklin website background error on deployment](https://discourse.julialang.org/t/franklin-website-background-error-on-deployment/93629)

<div class="topic-metadata">

**Author:** [@raman\_kumar](https://discourse.julialang.org/u/raman_kumar)\
**Replies:** 1\
**Last updated:** [January 27, 2023, 2:06pm UTC](https://discourse.julialang.org/t/franklin-website-background-error-on-deployment/93629 "2023-01-27T14:06:48Z")

</div>

Franklin website background image is visible in live server but not on gh-pages. How to make background image visible on gh-pages also ? :unamused: LIVE SERVER look GH pages look below The content of Franklin.…

---

## [Performance regression with StaticArrays?](https://discourse.julialang.org/t/performance-regression-with-staticarrays/93555)

<div class="topic-metadata">

**Author:** [@melonedo](https://discourse.julialang.org/u/melonedo)\
**Replies:** 5\
**Last updated:** [January 27, 2023, 11:53am UTC](https://discourse.julialang.org/t/performance-regression-with-staticarrays/93555 "2023-01-27T11:53:41Z")

</div>

Why in this example, the @SVector and @MVector macros both make performance worse? Code: (you can copy and paste into REPL) using BenchmarkTools using StaticArrays using Random function g1(T) levels = @SVector T\[.…

---

## [Taking advantage of pkgimages in 'scripts'](https://discourse.julialang.org/t/taking-advantage-of-pkgimages-in-scripts/93535)

<div class="topic-metadata">

**Author:** [@Mason](https://discourse.julialang.org/u/Mason)\
**Replies:** 2\
**Last updated:** [January 25, 2023, 10:47pm UTC](https://discourse.julialang.org/t/taking-advantage-of-pkgimages-in-scripts/93535 "2023-01-25T22:47:23Z")

</div>

There’s a lot of benchmark scripts out there right now where Julia is at a big disadvantage due to compiler overhead and such. Has anyone thought out an easy way that we can start taking advantage of pkgimages to reduce …

---

## [FLoops @init allocate only once](https://discourse.julialang.org/t/floops-init-allocate-only-once/93500)

<div class="topic-metadata">

**Author:** [@Salmon](https://discourse.julialang.org/u/Salmon)\
**Replies:** 13\
**Last updated:** [January 25, 2023, 6:34pm UTC](https://discourse.julialang.org/t/floops-init-allocate-only-once/93500 "2023-01-25T18:34:54Z")

</div>

Hi, Does anyone know if there are any tricks to using FLoops thread-safe buffers for better performance? I am trying to adapt my code which makes use of Buffers such as Buffers\[Threads.threadid()\] to the recommended app…

---

## [Mysterious memory allocation](https://discourse.julialang.org/t/mysterious-memory-allocation/93431)

<div class="topic-metadata">

**Author:** [@Ross\_Boylan](https://discourse.julialang.org/u/Ross_Boylan)\
**Replies:** 16\
**Last updated:** [January 24, 2023, 10:34pm UTC](https://discourse.julialang.org/t/mysterious-memory-allocation/93431 "2023-01-24T22:34:49Z")

</div>

Using julia --track-allocation identifies the top hotspots in my code for memory allocation: - function zSQdensity(z::Float64, wa::WorkArea) 0 ev = wa.evaluator 0 dat::DataFrame = wa.dat …

---

## [Efficient and in-place computation of A + adjoint(A)](https://discourse.julialang.org/t/efficient-and-in-place-computation-of-a-adjoint-a/93290)

<div class="topic-metadata">

**Author:** [@Ronan\_Gautier](https://discourse.julialang.org/u/Ronan_Gautier)\
**Replies:** 14\
**Last updated:** [January 24, 2023, 10:14am UTC](https://discourse.julialang.org/t/efficient-and-in-place-computation-of-a-adjoint-a/93290 "2023-01-24T10:14:04Z")

</div>

If A is any complex-valued matrix, is there a more efficient way of computing A + adjoint(A) in-place than the following ? function hermitian(A, A\_tmp) adjoint!(A\_tmp, A) A .+= A\_tmp end Benchmarking with using Li…

---

## [Switching between StaticArray and regular array depending on size (?)](https://discourse.julialang.org/t/switching-between-staticarray-and-regular-array-depending-on-size/93437)

<div class="topic-metadata">

**Author:** [@baptiste](https://discourse.julialang.org/u/baptiste)\
**Replies:** 5\
**Last updated:** [January 24, 2023, 3:49am UTC](https://discourse.julialang.org/t/switching-between-staticarray-and-regular-array-depending-on-size/93437 "2023-01-24T03:49:55Z")

</div>

I’m developing a package for physics simulations, where the core routine solves a dense linear system of complex equations, \\mathbf{A} \\mathbf{X} = \\mathbf{B} The matrix \\mathbf{A} can be small in some applications, …

---

## [How to improve a Generator to be more memory efficient when it is collected?](https://discourse.julialang.org/t/how-to-improve-a-generator-to-be-more-memory-efficient-when-it-is-collected/92932)

<div class="topic-metadata">

**Author:** [@camilogarciabotero](https://discourse.julialang.org/u/camilogarciabotero)\
**Replies:** 21\
**Last updated:** [January 23, 2023, 6:26pm UTC](https://discourse.julialang.org/t/how-to-improve-a-generator-to-be-more-memory-efficient-when-it-is-collected/92932 "2023-01-23T18:26:18Z")

</div>

Hi all, I wrote a function that searches through a sequence (a BioSequences.LongDNA but could also be a String) for start codons (predefined as constants subsequence searches) and generates ranges of indices correspondi…

---

## [Accelerating an N^2 nested loop](https://discourse.julialang.org/t/accelerating-an-n-2-nested-loop/93399)

<div class="topic-metadata">

**Author:** [@jibe](https://discourse.julialang.org/u/jibe)\
**Replies:** 13\
**Last updated:** [January 23, 2023, 5:33pm UTC](https://discourse.julialang.org/t/accelerating-an-n-2-nested-loop/93399 "2023-01-23T17:33:24Z")

</div>

Given a fixed integer N, and some arrays \\{ x\_{i} , y\_{i} \\}\_{i}, I am interested in (repeatedly) computing expressions of the form \\dot{x}\_{i} = - \\sum\_{j=1}^{N} (y\_{i} \\!-\\! y\_{j})/d\_{ij}; \\;\\; \\dot{y}\_{i} = \\sum\_{j=1…

---

## [Efficient sparse-dense matrix multiplication for diagonal-like sparse matrices](https://discourse.julialang.org/t/efficient-sparse-dense-matrix-multiplication-for-diagonal-like-sparse-matrices/93341)

<div class="topic-metadata">

**Author:** [@Ronan\_Gautier](https://discourse.julialang.org/u/Ronan_Gautier)\
**Replies:** 8\
**Last updated:** [January 22, 2023, 5:09pm UTC](https://discourse.julialang.org/t/efficient-sparse-dense-matrix-multiplication-for-diagonal-like-sparse-matrices/93341 "2023-01-22T17:09:39Z")

</div>

I want to implement an efficient and in-place sparse-dense matrix multiplication for sparse matrices with only a few non-zero offset diagonals (known as DIA sparse matrices). Here however, the number of non-zero diagonal…

---

## [Should @FastPow not make this faster?](https://discourse.julialang.org/t/should-fastpow-not-make-this-faster/93296)

<div class="topic-metadata">

**Author:** [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Replies:** 7\
**Last updated:** [January 21, 2023, 6:25pm UTC](https://discourse.julialang.org/t/should-fastpow-not-make-this-faster/93296 "2023-01-21T18:25:08Z")

</div>

Hello everyone! Suppose I have a set of parameters as: ρ₀ = 1000; c₀ = 20; γ = 7; ρ = ρ₀ .+ ρ₀\*rand(10^6)\*0.1; And I wish to evaluate the function: function Pressure(ρ,c₀,γ,ρ₀) return ((c₀^2\*ρ₀)/γ) \* ((ρ/ρ₀)^γ - …

---

## [High performance vector/matrix/tensor linear algebra operations](https://discourse.julialang.org/t/high-performance-vector-matrix-tensor-linear-algebra-operations/88756)

<div class="topic-metadata">

**Author:** [@FireCrumb](https://discourse.julialang.org/u/FireCrumb)\
**Replies:** 9\
**Last updated:** [January 20, 2023, 9:12am UTC](https://discourse.julialang.org/t/high-performance-vector-matrix-tensor-linear-algebra-operations/88756 "2023-01-20T09:12:59Z")

</div>

Hi, I have vectors (say 20 of them) of the same size (say 256 Float64). Now I want to add two of them and put the result into the third one, with the index of which one given as input. TL;DR: what is the fastest way to…

---

## [Scaling of @threads for "embarrassingly parallel" problem](https://discourse.julialang.org/t/scaling-of-threads-for-embarrassingly-parallel-problem/92949)

<div class="topic-metadata">

**Author:** [@goerz](https://discourse.julialang.org/u/goerz)\
**Replies:** 29\
**Last updated:** [January 20, 2023, 9:01am UTC](https://discourse.julialang.org/t/scaling-of-threads-for-embarrassingly-parallel-problem/92949 "2023-01-20T09:01:22Z")

</div>

I’m having a “trivially parallel” an “embarrassingly parallel” problem, where I’m running the following function: function map\_fidelity(potential\_depth\_values, separation\_time\_values; kwargs...) N = length(potentia…

---

## [How do I import a module to another program](https://discourse.julialang.org/t/how-do-i-import-a-module-to-another-program/93197)

<div class="topic-metadata">

**Author:** [@dmtrung14](https://discourse.julialang.org/u/dmtrung14)\
**Replies:** 1\
**Last updated:** [January 19, 2023, 10:43am UTC](https://discourse.julialang.org/t/how-do-i-import-a-module-to-another-program/93197 "2023-01-19T10:43:26Z")

</div>

I am trying to import a module from another file to my program (i.e. my program and my module is not in the same folder) Can I do that or do I have to install my own package? If so, how can I do that? Thanks

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

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