-
Notifications
You must be signed in to change notification settings - Fork 56
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
bug: Avoid the overhead cost of WriteString in write function in compiler.go #188
Comments
Hello @paganotoni , I pushed a fix for the above. |
Thanks @Mido-sys, Is there a way to benchmark this one? I would love to understand the impact of it better. A test (and/or benchmark) would be appreciated. |
Also, due to go.mod is 1.13 we couldn't use the recommended way of using unsafe which was introduced in 1.17 So I got the function from here https://stackoverflow.com/a/59210739. The original author of this function is Ian Lance Taylor |
ok. Good. Its time to cut a v5 for plush, with some breaking changes. one of those is reduce the dependencies that the helpers bring in. Once we do that we can change it to the recommended way of doing it. Thanks @Mido-sys ! |
Also with Go1.22 we can use this []byte("STRING") with zero overhead cost. |
@Mido-sys I just tagged v5 with Go 1.21. |
@paganotoni I upgraded the function. |
@Mido-sys String-to-byte conversion should still trigger allocations. I believe you are victim of a bad benchmark. |
Description
The WriteString() causes an overhead as the underlying bytes change. We know that the string value for each WriteString line of code won't change so we can include use
unsafe. pointer
which will result in zero allocation.To Reproduce
No response
Additional Context
Details
The text was updated successfully, but these errors were encountered: