-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: add variable length [N]T algs, for T in {string, float32, float64, iface} #41776
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
Comments
For string hashes the direction looks a lot like what I had in mind with an early working version of https://go-review.googlesource.com/c/go/+/148177/4 which wasn’t liked back then when send for review. The new scope seems to be broader and generate wrappers for specific lengths on demand to deduce them but the direction of thought seems basically the same. I’m happy to rework algs generation in that direction again by continuing the original intent of my CL linked above (and taking improvements from josh into account) into a new cl with more types and generating wrappers for specific lengths on demand to dedupe. With Register based calling convention the additional call needed will also be cheaper so could be a better binary size and speed tradeoff. For discussion of general approach: To generate code inside other types algs wont using a direct call to a type array alg with additional length argument be better then a closure? |
On the larger question of direction, I guess let's let @randall77 weigh in.
Definitely. The CL I linked is missing that and more, like the optimization to check all string lengths before checking any of their contents, and calling bytealg.Equal directly to compare contents. |
Using a helper in We'll still need to use a closure for functions which will be directly assigned to You've probably already seen this, but note the one possible complication for these optimizations is that for hashes, any optimized hashing needs to still match |
Algs generally seem to be a good part of the compiler/runtime where more can be done. I will focus on them again (assigned this issue to me) and besides general cleanup and refactoring will look into:
I refactor my earlier https://golang.org/cl/148177 to take into account other improvements here and split out the dereferencing part. After the above I think we can see whats left on the table and potentialy also look into masked memequals as a general concept to be used in the runtime/compiler: #41774 |
This issue has not been forgotten and is back on my list to be tackled for go1.18. Working on updating and syncing my existing CLs to HEAD. |
See discussion in https://golang.org/cl/255317 for more discussion.
I threw together a very crude prototype in golang.org/cl/259303 to start playing with it. It has many obvious flaws and todos (I didn't even bother fixing typos), but it might be helpful for someone wanting to work on this.
cc @randall77 @martisch
The text was updated successfully, but these errors were encountered: