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

Safety #8

Merged
merged 4 commits into from
Apr 1, 2020
Merged

Safety #8

merged 4 commits into from
Apr 1, 2020

Conversation

twmb
Copy link
Owner

@twmb twmb commented Apr 1, 2020

  • fixes non-amd64 code (missing import)
  • changes some testing to not run against the canonical source on big arches
  • follow Go's safety rules to the T (0.4ns perf hit)
  • add endianness and safety to readme and update benchmarks

twmb added 4 commits April 1, 2020 15:01
How this was missing is beyond me.
The canonical source does the unsafe bytes to int trick. This code
always reads as little endian. On big arches, the canonical source will
return different results than our little endian reading, so we avoid
testing against the canonical source on big arches.
Go issue 19367 (golang/go#19367)
and a linked issue at the bottom indicate that the following trick

  *(*string)(unsafe.Pointer(&slice))

is not theoretically safe. While I doubt that the Go people will ever
actually break that code since it would break a loooot of other code, we
may as well convert back to safe code. The prior commit removed reflect
because we were converting from a string to a slice; this re-introduces
it because converting from a slice to a string adds only 0.4ns of
overhead but adds following the rules of Go to the letter.

After this commit, this library effectively follows all rules of
unsafety (and is likely one of the few murmur3 libraries that does so).
@twmb twmb mentioned this pull request Apr 1, 2020
@twmb twmb merged commit 6cbffd7 into master Apr 1, 2020
@twmb twmb deleted the safety branch April 1, 2020 21:02
@twmb twmb restored the safety branch April 1, 2020 21:04
@twmb twmb deleted the safety branch April 1, 2020 21:05
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