Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read partial vector first [breaking change] #6

Merged
merged 1 commit into from
Nov 17, 2023
Merged

Conversation

ogxd
Copy link
Owner

@ogxd ogxd commented Nov 17, 2023

Context

Often, the input message does not fit a whole number of SIMD vectors (for 128-bit SIMD, it means the message size in bits is not a multiple of 128). Because of this, we currently often finish by reading a "partial" vector. To do this at high-speed, a small function verifies that we can read beyond the bounds of the input message without risking a segfault or some other dramatic exception (using the page size).
In practice, this works well, but this check as a small overhead. It turns out we can simply start first by reading the partial vector, and only then read a whole number of blocks. This allows us to skip the safety check in some situations because we aren't reading beyond the bounds of the message anymore (because we have at least one message block after this).
This change is about reading first the partial vector. This change will help boost performances, but will however break the stability (meaning that from this change generates hashes will be different from the hash generated by previous versions of the algorithm, for the same inputs)

Todo

  • Read partial vector first
  • Remove "range" logic which is not necessary anymore with this approach
  • Bump to 2.0.0
  • Update benchmark results

@ogxd ogxd self-assigned this Nov 17, 2023
@ogxd ogxd force-pushed the read-partial-first branch 4 times, most recently from 31ef1d8 to 309fd66 Compare November 17, 2023 13:52
@ogxd ogxd force-pushed the read-partial-first branch from 309fd66 to 9681398 Compare November 17, 2023 14:10
@ogxd ogxd merged commit 791cfbd into main Nov 17, 2023
1 check passed
@ogxd ogxd deleted the read-partial-first branch November 17, 2023 14:15
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.

1 participant