JuliaCI / JuliaCI/BenchmarkTools.jl

Warn against possible code invalidations

Open
#167 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation
Dominant language
Julia
Stars
684
Forks
107
PR merge metrics
No merged PRs in 30d

Description

Suppose I execute the following code in a fresh REPL (I haven't imported SpecialFunctions):

julia> f(x) = erf(x);
julia> f(1)
ERROR: UndefVarError: erf not defined
Stacktrace:
 [1] f(::Int64) at ./REPL[1]:1
 [2] top-level scope at REPL[2]:1
julia> using BenchmarkTools, SpecialFunctions
julia> x = 1; @btime f($x);
  27.645 ns (1 allocation: 16 bytes)

This allocation is not "real". See upstream issue: https://github.com/JuliaLang/julia/issues/35889. If I start a new fresh REPL, and this time load SpecialFunctions at the beginning:

julia> using BenchmarkTools, SpecialFunctions
julia> f(x) = erf(x);
julia> x = 1; @btime f($x);
  22.195 ns (0 allocations: 0 bytes)

the allocation is gone.

I think we should warn about this in the README or the docs.

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 with the README or documentation in BenchmarkTools.jl and review the invalidation example and linked Julia issue #35889. Add a warning explaining that defining code before loading SpecialFunctions can affect benchmark allocations, and confirm the documented guidance covers both REPL sequences shown.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
documentation, performance
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.