Skip to content

Commit 1d1c5c2

Browse files
Merge pull request #515 from ChrisRackauckas-Claude/precompile-improvements-20260102-040044
Add PrecompileTools workload to reduce TTFX
2 parents 0992b12 + 67c3fbd commit 1d1c5c2

File tree

3 files changed

+77
-1
lines changed

3 files changed

+77
-1
lines changed

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
name = "RecursiveArrayTools"
22
uuid = "731186ca-8d62-57ce-b412-fbd966d074cd"
3-
version = "3.42.1"
43
authors = ["Chris Rackauckas <accounts@chrisrackauckas.com>"]
4+
version = "3.42.1"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
88
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
99
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
1010
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
1111
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
12+
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
1213
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
1314
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
1415
SymbolicIndexingInterface = "2efcf032-c050-4f8e-a9bb-153293bab1f5"
@@ -56,6 +57,7 @@ Measurements = "2.11"
5657
MonteCarloMeasurements = "1.2"
5758
NLsolve = "4.5"
5859
Pkg = "1"
60+
PrecompileTools = "1.2.1"
5961
Random = "1"
6062
RecipesBase = "1.3.4"
6163
ReverseDiff = "1.15"

src/RecursiveArrayTools.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,6 @@ export recursivecopy, recursivecopy!, recursivefill!, vecvecapply, copyat_or_pus
142142

143143
export ArrayPartition, NamedArrayPartition
144144

145+
include("precompilation.jl")
146+
145147
end # module

src/precompilation.jl

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using PrecompileTools
2+
3+
@setup_workload begin
4+
@compile_workload begin
5+
# VectorOfArray with Vector{Float64}
6+
u_vec = [rand(3) for _ in 1:5]
7+
va = VectorOfArray(u_vec)
8+
9+
# Basic indexing operations
10+
_ = va[1, 1]
11+
_ = va[:, 1]
12+
_ = va[1, :]
13+
_ = va[:, :]
14+
15+
# Array conversion
16+
_ = Array(va)
17+
_ = Vector(va)
18+
19+
# Broadcasting
20+
va2 = va .+ 1.0
21+
va3 = va .* 2.0
22+
va4 = va .+ va
23+
24+
# copyto!
25+
copyto!(va, va2)
26+
27+
# similar
28+
_ = similar(va)
29+
30+
# DiffEqArray with Vector{Float64}
31+
t = collect(1.0:5.0)
32+
da = DiffEqArray(u_vec, t)
33+
34+
# Basic DiffEqArray operations
35+
_ = da[1, 1]
36+
_ = da[:, 1]
37+
_ = da[1, :]
38+
_ = Array(da)
39+
40+
# ArrayPartition with Float64 vectors
41+
ap = ArrayPartition([1.0, 2.0], [3.0, 4.0, 5.0])
42+
43+
# ArrayPartition operations
44+
_ = ap[1]
45+
_ = length(ap)
46+
_ = Array(ap)
47+
48+
# ArrayPartition broadcasting
49+
ap2 = ap .+ 1.0
50+
ap3 = ap .* 2.0
51+
ap4 = ap .+ ap
52+
53+
# copyto! for ArrayPartition
54+
copyto!(ap, ap2)
55+
56+
# similar for ArrayPartition
57+
_ = similar(ap)
58+
59+
# recursive operations
60+
_ = recursive_mean(ap)
61+
_ = recursivecopy(ap)
62+
63+
# fill!
64+
fill!(similar(va), 0.0)
65+
fill!(similar(ap), 0.0)
66+
67+
# size and ndims
68+
_ = size(va)
69+
_ = ndims(va)
70+
_ = size(ap)
71+
end
72+
end

0 commit comments

Comments
 (0)