Repository navigation
Conversation
Merging this PR will improve performance by 1.01%1 warning
Performance Changes
Tip Curious why performance improved? Comment Comparing |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1776 +/- ##
=======================================
Coverage 98.23% 98.23%
=======================================
Files 185 185
Lines 17131 17150 +19
Branches 3912 3914 +2
=======================================
+ Hits 16829 16848 +19
Misses 233 233
Partials 69 69
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
4290c5a to
2598edd
Compare
CALLDATALOAD copied every word through a zeroed 32-byte buffer, which GCC and Clang compile to a memcpy call. Check first, on the index's 64-bit words, whether the whole word is in the input and load it in place. The other cases stay inline in the unlikely branch.
2598edd to
37ba282
Compare
CALLDATALOAD copied every word through a zeroed 32-byte buffer, which GCC and Clang compile to a memcpy call, also when the whole word is in the input. That is nearly every CALLDATALOAD: 98.5% of them in a profile of 1000 recent mainnet blocks. Now this case is checked first, on the index's 64-bit words instead of with a 256-bit comparison, and the word is loaded in place. The index past the input and the word that the input ends inside stay inline, in the unlikely branch.
Instructions per CALLDATALOAD in the Baseline interpreter built for the default x86-64-v2, dispatch included, measured with callgrind on a loop of each case:
The Baseline loop's code is 23 bytes smaller with GCC and 16 bytes larger with Clang. The library's code is smaller with both, by 64 and 48 bytes.
The new test loads the words at the end of the input. The input is followed by a non-zero byte, so a load that reads past its end gives a wrong result. The test also loads at the largest 64-bit index, where the index plus 32 overflows 64 bits, and at three indexes whose low word is inside the input while one of the high words is not zero.