Commit 53de07f
committed
perf: Optimize hotpath memory management and reduce allocations
- Replace hex::encode(to_be_bytes()) with direct format!("{:016x}") in
TurboHash::hash(), eliminating intermediate byte array and the hex
crate dependency entirely
- Pre-size capnp first segment for FileHashes, LockFilePackages, and
LockFilePackagesRef based on entry count, avoiding repeated segment
growth allocations during message construction
- Use as_str() instead of to_string() for package_dir in TaskHashable
serialization, avoiding a per-task-hash String allocation
- Replace HashSet with sort_unstable+dedup in calculate_dependency_hashes,
removing HashSet hashing overhead and reducing allocations when
dependency fan-out is large
- Pre-allocate HashMap capacity in RepoGitIndex::get_package_hashes
using exact count (full-repo) or BTreeMap range size_hint (per-package)
- Use String::new() instead of "".into() for zero-allocation empty
string returns in get_external_deps_hash and get_internal_deps_hash
https://claude.ai/code/session_01TXs2FAMUjxXr25hLQwTMzF1 parent 6ef1582 commit 53de07f
File tree
6 files changed
+59
-33
lines changed- crates
- turborepo-hash
- src
- turborepo-scm/src
- turborepo-task-hash/src
6 files changed
+59
-33
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
156 | 159 | | |
157 | 160 | | |
158 | 161 | | |
159 | | - | |
| 162 | + | |
160 | 163 | | |
161 | 164 | | |
162 | 165 | | |
| |||
189 | 192 | | |
190 | 193 | | |
191 | 194 | | |
| 195 | + | |
| 196 | + | |
192 | 197 | | |
193 | 198 | | |
194 | 199 | | |
195 | | - | |
| 200 | + | |
196 | 201 | | |
197 | 202 | | |
198 | 203 | | |
| |||
225 | 230 | | |
226 | 231 | | |
227 | 232 | | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
228 | 239 | | |
229 | 240 | | |
230 | 241 | | |
231 | | - | |
| 242 | + | |
232 | 243 | | |
233 | 244 | | |
234 | 245 | | |
| |||
268 | 279 | | |
269 | 280 | | |
270 | 281 | | |
| 282 | + | |
| 283 | + | |
271 | 284 | | |
272 | 285 | | |
273 | 286 | | |
274 | | - | |
| 287 | + | |
275 | 288 | | |
276 | 289 | | |
277 | 290 | | |
| |||
313 | 326 | | |
314 | 327 | | |
315 | 328 | | |
316 | | - | |
317 | | - | |
| 329 | + | |
| 330 | + | |
318 | 331 | | |
319 | 332 | | |
320 | 333 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | 5 | | |
| |||
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| 25 | + | |
23 | 26 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
| 27 | + | |
31 | 28 | | |
32 | | - | |
| 29 | + | |
33 | 30 | | |
34 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
64 | 65 | | |
65 | | - | |
| 66 | + | |
66 | 67 | | |
| 68 | + | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
70 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
71 | 78 | | |
72 | | - | |
| 79 | + | |
73 | 80 | | |
74 | 81 | | |
75 | | - | |
| 82 | + | |
| 83 | + | |
76 | 84 | | |
77 | 85 | | |
78 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
430 | 430 | | |
431 | 431 | | |
432 | 432 | | |
433 | | - | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
434 | 438 | | |
435 | 439 | | |
436 | 440 | | |
| |||
440 | 444 | | |
441 | 445 | | |
442 | 446 | | |
443 | | - | |
| 447 | + | |
444 | 448 | | |
445 | 449 | | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
450 | 456 | | |
451 | | - | |
452 | 457 | | |
453 | | - | |
| 458 | + | |
454 | 459 | | |
455 | 460 | | |
456 | 461 | | |
| |||
497 | 502 | | |
498 | 503 | | |
499 | 504 | | |
500 | | - | |
| 505 | + | |
501 | 506 | | |
502 | 507 | | |
503 | 508 | | |
| |||
519 | 524 | | |
520 | 525 | | |
521 | 526 | | |
522 | | - | |
| 527 | + | |
523 | 528 | | |
524 | 529 | | |
525 | 530 | | |
| |||
0 commit comments