Skip to content

Precompile show, \, products, broadcast and concatenation of sparse Float64 arrays - #1103

Open
ViralBShah wants to merge 1 commit into
mainfrom
vs/precompile-workload
Open

ViralBShah wants to merge 1 commit into
mainfrom
vs/precompile-workload

Conversation

@ViralBShah

@ViralBShah ViralBShah commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

SparseArrays is not in the sysimage, and its package image holds almost no native code (a 56 KB .so), so the first call of every common operation compiles: show of a matrix takes about 0.4 s and A\b about 0.6 s.

Before (main), first calls in a fresh session, Float64 SparseMatrixCSC with Int indices:

load .ji + .so show A\b A*x 25 common operations
main 195 ms 7.7 MB + 0.06 MB 430 ms 605 ms 115 ms 1.95 s

After:

load .ji + .so show A\b A*x 25 common operations
this PR 220 ms 13.2 MB + 1.5 MB 2 ms 0.4 ms 0.0 ms 0.43 s

src/precompile.jl runs the common operations on small Float64 literals behind Base.generating_output(), the pattern Profile and Pkg use, so their native code goes into the package image; nothing runs at load. The solver calls are behind Base.USE_GPL_LIBS.

The cost is 25 ms of load time, a package image about 7 MB larger, and about 4 s more to build it, which Julia's build and download carry too. Left out: ComplexF64, which would take load to 229 ms and the image to 16 MB + 2.7 MB.

🤖 Generated with Claude Code

…se Float64 arrays

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ViralBShah

Copy link
Copy Markdown
Member Author

@KristofferC Is it ok to include this in an stdlib (which is not in the system image)?

@github-actions

Copy link
Copy Markdown

TTFX: 3 robust regressions, 3 robust improvements.

SparseArrays #1103 (cfb5048) vs a49c313 · run

  • SparseArrays: precompile +169.5%, run (cold) -53.9%, load+run (warm) -30.2%
  • All packages (geometric mean): precompile +37.0%, load (cold) +8.5%, load+run (warm) -6.4%
Details

Julia 1.14.0-DEV.3740 · Linux X64 · 4 blocks (ABBA)

metric base (s) head (s) change per block with GC off
precompile (regression) 5.38, 5.39, 5.39, 5.4 14.5, 14.5, 14.5, 14.6 +169.9%, +168.7%, +169.5%, +169.6% –
load (cold) 0.261, 0.26, 0.26, 0.266 0.286, 0.286, 0.286, 0.286 +9.5%, +9.7%, +10.0%, +7.7% +9.7%, +11.2%, +10.1%, +9.8%
run (cold) (improvement) 0.693, 0.681, 0.682, 0.685 0.318, 0.316, 0.315, 0.313 -54.1%, -53.6%, -53.8%, -54.3% -53.2%, -50.2%, -54.9%, -54.5%
load+run (warm) (improvement) 0.524, 0.524, 0.526, 0.53 0.372, 0.366, 0.367, 0.368 -29.0%, -30.1%, -30.3%, -30.5% –

Dependents (median change over blocks)

package precompile load (cold) run (cold) load+run (warm)
Krylov +0.8% +9.1% – +9.1%
SparseMatrixColorings -5.6% +6.7% – +6.8%
all packages (geomean) change per block with GC off
precompile (regression) +36.8%, +36.9%, +37.2%, +37.0% –
load (cold) (regression) +8.3%, +8.9%, +8.7%, +8.0% +8.1%, +9.0%, +8.6%, +8.6%
load+run (warm) (improvement) -6.1%, -6.2%, -6.7%, -7.5% –
Dependents per block

Krylov

metric base (s) head (s) change per block with GC off
precompile 6.7, 6.74, 6.72, 6.74 6.72, 6.78, 6.83, 6.81 +0.4%, +0.6%, +1.7%, +1.0% –
load (cold) 0.282, 0.282, 0.28, 0.281 0.306, 0.306, 0.307, 0.308 +8.8%, +8.8%, +9.6%, +9.4% +8.8%, +9.2%, +9.1%, +8.4%
load+run (warm) 0.28, 0.28, 0.281, 0.286 0.305, 0.306, 0.307, 0.305 +9.0%, +9.2%, +9.4%, +6.7% –

SparseMatrixColorings

metric base (s) head (s) change per block with GC off
precompile 7.06, 7.04, 7.05, 7.04 6.67, 6.69, 6.64, 6.65 -5.6%, -5.1%, -5.8%, -5.5% –
load (cold) 0.334, 0.331, 0.336, 0.332 0.356, 0.357, 0.358, 0.355 +6.5%, +8.1%, +6.5%, +6.9% +5.8%, +6.7%, +6.8%, +7.5%
load+run (warm) 0.33, 0.33, 0.331, 0.333 0.352, 0.357, 0.353, 0.355 +6.9%, +8.1%, +6.6%, +6.6% –

A change is robust when every block clears the threshold (precompile 8%, load (cold) 10%, run (cold) 15%, load+run (warm) 15%), the samples of the two commits do not overlap, and the medians differ by at least the floor (precompile 0.25 s, load (cold) 0.1 s, run (cold) 0.05 s, load+run (warm) 0.05 s). Load and run are also judged with the GC off, and either counts. Over all packages whose base value is at least the floor, each metric's geometric mean must clear a threshold in every block (precompile 2%, load (cold) 2%, run (cold) 3%, load+run (warm) 3%).

@codecov

codecov Bot commented Oct 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.83%. Comparing base (a49c313) to head (7963dbe).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1103   +/-   ##
=======================================
  Coverage   94.83%   94.83%           
=======================================
  Files          16       16           
  Lines       10252    10257    +5     
=======================================
+ Hits         9722     9727    +5     
  Misses        530      530           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ViralBShah

Copy link
Copy Markdown
Member Author

@IanButterworth Seems like TTFX is doing its job here. Pinging for you to take a look since I thought you may find it useful to see it in action.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant