Repository navigation
Commit 6478d51
Put VortexError's payload behind one Arc
VortexError was 56 bytes, so every VortexResult was too, whatever it
carried. A result that large is returned through memory: the caller
reserves a stack slot, passes its address, and reads the outcome back.
That is the path for nearly every call in the codebase, almost all of
which succeed: 3158 functions return VortexResult<()> and 684 return
VortexResult<ArrayRef>.
The kind, message, source and backtrace now live in one shared
allocation, and VortexError is a single pointer:
VortexResult<T> for T before after
() 56 8
bool, usize, ArrayRef 56 16
Option<ArrayRef>, Vec 56 24
Results of 16 bytes or less come back in registers on x86-64 and
aarch64. Const assertions pin the error and VortexResult<()> to one
word.
Constructing an error costs no more than before. It already allocated
every time, for the Arc around its backtrace; the backtrace now sits
inline in the payload, so that allocation is the payload's. Wrapping a
foreign error drops from three allocations to two, because its source
is now boxed once instead of boxed and then copied into an Arc.
Cloning stays a reference-count bump. with_context writes into the
payload when it holds the only reference, which is the usual case while
an error propagates. On an error that has been cloned, it builds a new
payload that points back at the shared one for its source and backtrace,
so the other clones are unchanged and nothing is lost.
Signed-off-by: Robert Kruszewski <github@robertk.io>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S7EtMqoZ91rrCCh9vS2yTm1 parent 4442700 commit 6478d51
2 files changed
Lines changed: 104 additions & 31 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
135 | 140 | | |
136 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
137 | 147 | | |
138 | | - | |
| 148 | + | |
139 | 149 | | |
140 | | - | |
141 | | - | |
| 150 | + | |
142 | 151 | | |
143 | 152 | | |
144 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
145 | 166 | | |
146 | 167 | | |
147 | 168 | | |
148 | 169 | | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
| 170 | + | |
155 | 171 | | |
156 | 172 | | |
157 | 173 | | |
| |||
162 | 178 | | |
163 | 179 | | |
164 | 180 | | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
| 181 | + | |
171 | 182 | | |
172 | 183 | | |
173 | 184 | | |
| |||
178 | 189 | | |
179 | 190 | | |
180 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
181 | 207 | | |
182 | 208 | | |
183 | | - | |
| 209 | + | |
184 | 210 | | |
185 | 211 | | |
186 | 212 | | |
187 | 213 | | |
188 | 214 | | |
189 | 215 | | |
190 | 216 | | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
196 | 227 | | |
197 | 228 | | |
198 | 229 | | |
199 | 230 | | |
200 | | - | |
| 231 | + | |
201 | 232 | | |
202 | 233 | | |
203 | 234 | | |
204 | 235 | | |
205 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
206 | 251 | | |
207 | 252 | | |
208 | 253 | | |
209 | 254 | | |
210 | | - | |
211 | | - | |
| 255 | + | |
| 256 | + | |
212 | 257 | | |
213 | 258 | | |
214 | 259 | | |
215 | 260 | | |
216 | | - | |
217 | | - | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
218 | 264 | | |
219 | 265 | | |
220 | 266 | | |
| |||
228 | 274 | | |
229 | 275 | | |
230 | 276 | | |
231 | | - | |
232 | | - | |
233 | | - | |
| 277 | + | |
| 278 | + | |
234 | 279 | | |
235 | 280 | | |
236 | 281 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
144 | 172 | | |
145 | 173 | | |
146 | 174 | | |
| |||
0 commit comments