JuliaArrays / JuliaArrays/StaticArrays.jl

Disparate performance in diff methods

Open
#541 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

performance
Dominant language
Julia
Stars
844
Forks
159
Avg merge
3d 21h
Merged PRs (30d)
3

Description

First of all, thank you for this great package! I'm a relatively new Julia user and I was using Static Arrays for some polynomial math that needs to use diff. I noticed that the benchmark speeds are very different for the two diff methods. MWE:

julia> A = @SMatrix randn(3,20);

julia> @btime diff($A,dims=$2);
  3.299 μs (2 allocations: 1.06 KiB)

julia> @btime diff($A,dims=$(Val(2)));
  37.283 ns (0 allocations: 0 bytes)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two diff benchmarks from the issue with a 3×20 @SMatrix and compare the dims=2 and dims=Val(2) paths. Trace the diff implementation used by StaticArrays and identify why their allocations and timings differ; done means the discrepancy is explained and the intended behavior is covered by a regression test or benchmark.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
performance
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.