Commit fa7004b
perf(npm-resolver): cache meta in memory for exact version matches. (#12458)
On the exact-version disk fast path in pickPackage(), promote the parsed
packument into the in-memory metaCache so later resolutions of the same package
in one install skip the disk read and parse. In large monorepos this brings
adding a package down from minutes to seconds.
The in-memory cache key is now registry-qualified via a shared
getPkgMetaCacheKey(registry, name, fullMetadata) helper. Previously the key was
only the package name (plus a `:full` suffix) while the on-disk mirror was
registry-qualified, so a package of the same name served by two registries in
one install could share one cache slot and resolve the wrong tarball/integrity.
The registry is threaded through createNpmResolutionVerifier's shared-meta reads
(readSharedMeta / readSharedMetaForTrust), which already noted that a
registry-qualified read required the resolver's metaCache key shape to change
first. Added a regression test that resolves the same package name from two
registries and asserts each gets its own tarball.
The Rust pacquet port already implements both behaviors (registry-scoped cache
key and disk-fast-path cache population), so no port is required.
---------
Co-authored-by: Zoltan Kochan <[email protected]>1 parent 0f11c40 commit fa7004b
7 files changed
Lines changed: 314 additions & 52 deletions
File tree
- .changeset
- pacquet/crates/resolving-npm-resolver/src
- pick_package
- resolving/npm-resolver
- src
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
Lines changed: 15 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
290 | | - | |
291 | | - | |
292 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
293 | 298 | | |
294 | 299 | | |
295 | 300 | | |
| |||
427 | 432 | | |
428 | 433 | | |
429 | 434 | | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
430 | 440 | | |
431 | | - | |
| 441 | + | |
432 | 442 | | |
433 | 443 | | |
434 | 444 | | |
| |||
457 | 467 | | |
458 | 468 | | |
459 | 469 | | |
460 | | - | |
| 470 | + | |
461 | 471 | | |
462 | 472 | | |
463 | 473 | | |
| |||
Lines changed: 55 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1087 | 1087 | | |
1088 | 1088 | | |
1089 | 1089 | | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
Lines changed: 43 additions & 38 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
455 | 455 | | |
456 | 456 | | |
457 | 457 | | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
472 | 465 | | |
473 | 466 | | |
474 | 467 | | |
| |||
565 | 558 | | |
566 | 559 | | |
567 | 560 | | |
568 | | - | |
569 | | - | |
570 | | - | |
571 | | - | |
572 | | - | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
573 | 567 | | |
574 | 568 | | |
575 | 569 | | |
| |||
721 | 715 | | |
722 | 716 | | |
723 | 717 | | |
724 | | - | |
725 | | - | |
726 | | - | |
727 | | - | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
728 | 721 | | |
729 | 722 | | |
730 | 723 | | |
| |||
741 | 734 | | |
742 | 735 | | |
743 | 736 | | |
| 737 | + | |
744 | 738 | | |
745 | 739 | | |
746 | 740 | | |
747 | | - | |
748 | | - | |
749 | | - | |
750 | | - | |
751 | | - | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
752 | 745 | | |
753 | | - | |
754 | | - | |
| 746 | + | |
| 747 | + | |
755 | 748 | | |
756 | 749 | | |
757 | 750 | | |
758 | 751 | | |
| 752 | + | |
759 | 753 | | |
760 | 754 | | |
761 | 755 | | |
762 | 756 | | |
763 | 757 | | |
764 | | - | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
765 | 772 | | |
766 | 773 | | |
767 | | - | |
768 | | - | |
769 | | - | |
770 | | - | |
771 | | - | |
772 | | - | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
773 | 778 | | |
774 | 779 | | |
775 | 780 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
80 | 82 | | |
81 | 83 | | |
82 | 84 | | |
| |||
211 | 213 | | |
212 | 214 | | |
213 | 215 | | |
214 | | - | |
215 | | - | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
216 | 221 | | |
217 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
218 | 226 | | |
219 | 227 | | |
220 | 228 | | |
| |||
281 | 289 | | |
282 | 290 | | |
283 | 291 | | |
| 292 | + | |
284 | 293 | | |
285 | 294 | | |
286 | 295 | | |
| |||
587 | 596 | | |
588 | 597 | | |
589 | 598 | | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
590 | 636 | | |
591 | 637 | | |
592 | 638 | | |
| |||
0 commit comments