Commit 9c2cce6
Use AllocCheck.check_allocs for zero-allocation tests (#66)
The allocation tests in test/alloc_tests.jl used `@allocated`, which measures
allocations of a single runtime call. On Julia 1.12+ this surfaced false
positives that did not reflect any real allocation in the package:
- `dr[8]` (DisjointRange second-range branch) was never warmed up before its
`@allocated`, so it measured ~700k bytes of first-call compilation.
- The iteration test accumulated into a global-scope variable inside the
`@allocated begin ... end` block, so the accumulator was boxed (704 bytes) —
an artifact of measuring in non-function scope, not of the iterate methods.
- The first `@allocated A[50, 50]` after a single warmup still captured residual
specialization allocations (16 bytes).
`AllocCheck.check_allocs` (a test dependency already declared but unused)
statically proves the absence of any allocating code path for the given argument
types. It is immune to compilation and global-scope boxing noise and is a
strictly stronger guarantee than `@allocated == 0`. `check_allocs` reports zero
allocation sites for every operation on Julia 1.10, 1.12.6, and 1.13.0-rc1,
confirming the package code is genuinely allocation-free; only the test
methodology was flaky.
Co-authored-by: ChrisRackauckas-Claude <accounts@chrisrackauckas.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent b3bcb59 commit 9c2cce6
1 file changed
Lines changed: 29 additions & 84 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
8 | 23 | | |
9 | 24 | | |
10 | | - | |
11 | 25 | | |
12 | 26 | | |
13 | 27 | | |
14 | 28 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
46 | 34 | | |
47 | 35 | | |
48 | 36 | | |
| |||
52 | 40 | | |
53 | 41 | | |
54 | 42 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
66 | 46 | | |
67 | 47 | | |
68 | 48 | | |
| |||
72 | 52 | | |
73 | 53 | | |
74 | 54 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
| 55 | + | |
85 | 56 | | |
86 | 57 | | |
87 | 58 | | |
| |||
91 | 62 | | |
92 | 63 | | |
93 | 64 | | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
| 65 | + | |
| 66 | + | |
113 | 67 | | |
114 | 68 | | |
115 | 69 | | |
| |||
119 | 73 | | |
120 | 74 | | |
121 | 75 | | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
| 76 | + | |
| 77 | + | |
133 | 78 | | |
134 | 79 | | |
0 commit comments