Skip to content

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Aug 24, 2018

If we know the size of a type at compile time (like we do for all the integer types), it is cheaper to assign the data buffer directly instead of using a memcpy.

@ahoppen ahoppen requested review from rintaro and nkcsgexi August 24, 2018 18:12
@ahoppen
Copy link
Member Author

ahoppen commented Aug 24, 2018

@swift-ci Please smoke test

@nkcsgexi
Copy link
Contributor

Out of curiosity, what difference can this optimization make, i.e. *(T *)(Data.data() + Offset) = Value; vs. ::memcpy(Data.data() + Offset, Buffer.data(), Buffer.size());?

@ahoppen
Copy link
Member Author

ahoppen commented Aug 24, 2018

I would need to test again for exact numbers, but if I remember correct it improved serialisation performance by around 5%

@nkcsgexi
Copy link
Contributor

ah, OK. Then i think the change is worth it. 👍

If we know the size of a type at compile time (like we do for all the
integer types), it is cheaper to assign the data buffer directly instead
of using a memcpy.
@ahoppen ahoppen force-pushed the optimized-fixed-data branch from 0422c30 to 33d86d5 Compare August 24, 2018 22:27
@ahoppen
Copy link
Member Author

ahoppen commented Aug 24, 2018

@swift-ci Please smoke test

@ahoppen ahoppen merged commit 209ba2d into swiftlang:master Aug 27, 2018
@ahoppen ahoppen deleted the optimized-fixed-data branch August 29, 2018 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants