Closed Mido-sys closed 1 month ago
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.
Before the fix, this was result from pprof
After applying the fix, plushRender didn't appear
Also, due to go.mod is 1.13 we couldn't use the recommended way of using unsafe which was introduced in 1.17
unsafe.Slice(unsafe.StringData(s), len(s))
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 See this comment: https://github.com/kubernetes/kubernetes/issues/124656#issuecomment-2327677824
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