Commit f2b116c
committed
perf: Parallelize package.json loading and reduce builder allocations
- Parallelize package.json file I/O and JSON parsing with rayon. Each
file is read and parsed independently, so this is embarrassingly
parallel. The sequential add_json processing loop is unchanged.
- Use HashMap entry API in add_json to avoid cloning PackageName on
every insert. The old code cloned unconditionally for the insert key,
then cloned again on the error path for the get. Now we only clone
once in the success path for add_node.
- Pre-allocate workspaces and node_lookup HashMaps with the known
package count before the add_json loop.1 parent d16f081 commit f2b116c
File tree
3 files changed
+38
-18
lines changed- crates/turborepo-repository
- src/package_graph
3 files changed
+38
-18
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 | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
Lines changed: 36 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
281 | 285 | | |
282 | | - | |
283 | | - | |
284 | 286 | | |
285 | 287 | | |
286 | 288 | | |
| |||
293 | 295 | | |
294 | 296 | | |
295 | 297 | | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
300 | 315 | | |
301 | 316 | | |
302 | 317 | | |
303 | 318 | | |
304 | 319 | | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
305 | 323 | | |
306 | 324 | | |
307 | 325 | | |
| |||
0 commit comments