-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
hash/maphash: Provide a purego
implementation
#47342
Comments
cc @dmitshur |
purego
implementation of rthash
purego
implementation
My initial reaction was "I thought purego was for avoiding asm and cgo, not unsafe", but I'm wrong: #23172 (comment) |
Are you proposing to replace |
No. I would keep the existing one for performance where useable, and add a purego version behind build tags.
TBD. But probably logically equivalent to what GopherJS is doing now (i.e. a slight variation from the Go 1.16 version). |
So far the only purego tags in the main repo are crypto libraries. I think there's a higher level decision to be made as to how much we want to sprinkle the standard library with purego backstops. For instance, we'd probably need a purego builder to test that the code works. |
This proposal has been added to the active column of the proposals project |
In net and os/user we have netgo and osusergo tags instead of purego. Given that, it seems fine to have a purego hash/maphash. |
Not sure but maybe this should be accepted first? #23172 |
#23172 is accepted. It just needs to be done. |
Based on the discussion above, this proposal seems like a likely accept. |
This pulls in a few select functions from Go 1.16, which were optimized and thus made unsafe in Go 1.17. golang/go#47342 should render this change obsolete if/when implemented.
This pulls in a few select functions from Go 1.16, which were optimized and thus made unsafe in Go 1.17. golang/go#47342 should render this change obsolete if/when implemented.
No change in consensus, so accepted. 🎉 |
purego
implementationpurego
implementation
I would like to contribute to the implementation, but I don't think I would be able to help much with testing infrastructure concerns @randall77 mentioned in #47342 (comment). One alternative I can think of is that both optimized and purego implementations are included in the default build as private functions, and build constraints only select which one is actually used. In that case it would be possible to add a test that verifies that both implementation behave exactly the same. Dead code elimination should be able to strip out one of the implementations in the build. The drawback of this option would be that the code might get a bit less intuitive, and it's not an approach that's easy to generalize other packages we might want a purego version of. |
Change https://go.dev/cl/468795 mentions this issue: |
This ultimately will make a novice programmers try to use binaries from system commands; and instead will be able to build proper libraries around ABIs from C libraries; this project may have a specific scope for you but overall this is pretty massive for the Go community; it will make it both easier and faster to use C tools which was becoming a problem. |
What version of Go are you using (
go version
)?1.17rc1
What operating system and processor architecture are you using (
go env
)?GopherJS with Go 1.17
What did you do?
64d323f improves the performance of the
hash/maphash
package, but in doing so makes the package even "less" safe than it was before. In 1.16 this was worked around in GopherJS (where pointer arithmetic is not possible) with gopherjs/gopherjs@ccebfda. The recent changes will require a much larger delta, as now every caller torthash
will need to be updated, to use calling semantics more similar to the 1.16 version.What did you
expecthope to see?A
purego
implementation ofhash/maphash
would solve this problem. And perhaps it would be useful in other scenarios as well?The text was updated successfully, but these errors were encountered: