The “Mary Sue Protocol” (“MSP” for short) is a simple challenge/response protocol for RP UI add-ons within WoW to communicate with each other and publish text information to other clients (such as RP character names and descriptions).
This changeset improves the performance of the CRC32 hash function by approximately ~10% (increasing with larger payload sizes) by unrolling loop to reduce the number of string.byte calls to deal with bytes in blocks of 8.
Additionally the tohex function has been simplified to use string.format with bit.arshift, which works around the overflow issue it was trying to avoid by ensuring that inputs to string.format are signed when above 2^31-1.
Unfortunately I lost the specific test data I was using, but the before/after should show below quite well. The test strings used for the benchmark were strings of mixed length (0, 10, 25, 50, 200, and 1000 in-order). The tests were run 10 times without and with the changes:
With changes applied:
While the zero-byte string case gets worse, I think it's likely that there aren't going to be many zero byte strings being hashed. The gains from everything larger than that should outweigh the hits taken by very small strings.
This changeset improves the performance of the CRC32 hash function by approximately ~10% (increasing with larger payload sizes) by unrolling loop to reduce the number of
string.byte
calls to deal with bytes in blocks of 8.Additionally the
tohex
function has been simplified to usestring.format
withbit.arshift
, which works around the overflow issue it was trying to avoid by ensuring that inputs tostring.format
are signed when above 2^31-1.Unfortunately I lost the specific test data I was using, but the before/after should show below quite well. The test strings used for the benchmark were strings of mixed length (0, 10, 25, 50, 200, and 1000 in-order). The tests were run 10 times without and with the changes:
With changes applied:
While the zero-byte string case gets worse, I think it's likely that there aren't going to be many zero byte strings being hashed. The gains from everything larger than that should outweigh the hits taken by very small strings.