Commit 00ae9d1
perf(v8): memoize the snapshot cache key instead of re-digesting per exec
`snapshot_cache_key` SHA-256s the bridge bundle (~2.5 MB) plus the userland
bundle. Both are process-lifetime constants, and every execution derives the key
four times: the snapshot-cache lookup, the warm-worker pool key on the pre-warm
path, and again on the claim path inside session creation. Each digest measured
~7 ms, so a warm guest exec spent ~28 ms hashing two strings that never change —
the flat ~14 ms "snapshot-ready/pre-warm handshake" and the flat ~14 ms
"JS execution dispatch" on the launch path were almost entirely this.
Memoize by content: a bounded process-wide table keyed on full equality of the
bridge and userland text. A memcmp over the same bytes is ~35x cheaper than the
digest, and content equality means a lookup can only return the key of a bundle
byte-identical to the one asked for, so the memo is indistinguishable from
recomputing and cannot surface another caller's bundle. Also hash the two inputs
as streaming updates rather than concatenating them into a fresh 2.8 MB buffer
first; the digest is unchanged.
Sidecar phases for a warm `sh -c "echo x"`: snapshot-ready + pre-warm handshake
14.0 -> 0.3 ms, JS execution dispatch 14.3 -> 0.5 ms, execution finish
28.5 -> 1.1 ms.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 3497abe commit 00ae9d1
1 file changed
Lines changed: 91 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
746 | 746 | | |
747 | 747 | | |
748 | 748 | | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
749 | 771 | | |
750 | 772 | | |
751 | 773 | | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
752 | 782 | | |
753 | | - | |
754 | | - | |
755 | | - | |
756 | | - | |
757 | | - | |
758 | | - | |
759 | | - | |
760 | | - | |
761 | | - | |
762 | | - | |
763 | | - | |
764 | | - | |
765 | | - | |
766 | | - | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
767 | 802 | | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
768 | 808 | | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
769 | 820 | | |
770 | 821 | | |
771 | 822 | | |
| |||
2102 | 2153 | | |
2103 | 2154 | | |
2104 | 2155 | | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
2105 | 2181 | | |
2106 | 2182 | | |
2107 | 2183 | | |
| |||
0 commit comments