-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move unboxing helpers to managed code (#109135)
Move the unboxing helpers to managed code. Behavior is basically identical except for the Unbox_Nullable paths, which required some investigation to find the fastest implementation. Notably, there interruptibility of managed code makes the copying/zeroing of values more difficult, but with the opportunity/requirement to specialize the codebase came a few micro-optimizations that are somewhat nice. Overall I don't expect anyone to notice the performance changes here, but since my earlier code was about 2X slower than the native implementation, I did feel the need to optimize until everything looked good. Performance results: | TestName | With PR | Without PR | % Speedup | | --- | --- | --- | --- | | TestJustAPrimitive| 1217.0047| 1221.203| 0.34% | | TestJustObject| 1212.6415| 1211.6437|-0.08% | | TestJust5Primitive| 1496.5304| 1522.4968|1.74% | | TestJust5Object| 1461.0507| 1488.3328|1.87% | | TestJust10Primitive| 1473.2814| 1493.5238|1.37% | | TestJust10Object| 3215.6339| 2854.6186|-11.23% | | TestJustAPrimitiveNullableWithValue| 2727.9085| 5182.2611|89.97% | | TestJustObjectNullableWithValue| 3148.9484| 5672.2985|80.13% | | TestJust5PrimitiveNullableWithValue| 5443.9232| 7795.6109|43.20% | | TestJust5ObjectNullableWithValue| 6492.9071| 8095.1508|24.68% | | TestJust10PrimitiveNullableWithValue| 6022.6274| 8723.572| 44.85% | | TestJust10ObjectNullableWithValue| 7728.3239| 9671.1382|25.14% | | TestJustAPrimitiveNullNullable| 1786.1337| 2230.0932|24.86% | | TestJustObjectNullNullable| 1675.0683| 2326.0395|38.86% | | TestJust5PrimitiveNullNullable| 2921.9497| 3298.4642|12.89% | | TestJust5ObjectNullNullable| 3389.4043| 3615.3131|6.67% | | TestJust10PrimitiveNullNullable| 3050.809| 4054.9683|32.91% | | TestJust10ObjectNullNullable| 4658.8316| 5335.0686|14.52% | Results are very positive, or within the margin of error in this test suite. These results were generated using a small benchmark which mostly targeted measuring the performance of the Unbox_Nullable helper, as it has the most complex and potentially slow code. Generally the impact on that helper is that the performance of the type system portion of the helper is faster, and the performance of code which actually copies the contents of a valuetype is a little better. This isn't quite a fair test of managed vs native performance though, as I took the opportunity to restructure some of the memory on `MethodTable` so that it could more easily be read in managed code, and that happened to make a fair bit of complex code become simpler and thus faster.
- Loading branch information
1 parent
25f9673
commit eb456e6
Showing
20 changed files
with
373 additions
and
304 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.