Perhaps it will have a small benefit.  However, according to the benchmark,
the performance is slightly better in the case where there is 1 alloc/op,
Normally people avoid the heap allocation for better performance and there
is no evidence of that here.

On Fri, Aug 26, 2022 at 3:32 AM Lee Chou <mozartz.2...@gmail.com> wrote:

> Thanks for taking the time for the clue. It seems that this is an open
> issue.
>
> Actually, It work for this case. aovid the alloc will have more benefit
> for gc.
>
> 在2022年8月26日星期五 UTC+8 02:49:08<seanc...@gmail.com> 写道:
>
>> Actually, looking more closely at your benchmark numbers, the trick does
>> not work in your case.  Which makes sense to me, I don't see why it would
>> work.
>>
>> On Wednesday, August 24, 2022 at 2:59:34 AM UTC-4 mozart...@gmail.com
>> wrote:
>>
>>> I was try using net.Buffers for writev. But I meet a unexptected allocs
>>> in benchmark.
>>>
>>> https://go.dev/play/p/SHpxSYbP1I5
>>>
>>> when I run the benchmark:
>>>
>>> goos: linux
>>> goarch: amd64
>>> pkg: writev
>>> BenchmarkWrite_Writev/escape-4               272901          4198 ns/op
>>>          24 B/op           1 allocs/op
>>> BenchmarkWrite_Writev/noescape-4             273751          4267 ns/op
>>>           0 B/op           0 allocs/op
>>> PASS
>>> ok      writev    3.410s
>>>
>>> Is the noescape safe ?
>>> Is there a better way to avoid the alloc/escape ?
>>> -
>>> Best regards
>>> Lee
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/95daef29-ff45-4d3a-bca8-d8911b74eabbn%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/95daef29-ff45-4d3a-bca8-d8911b74eabbn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAKL%3DS7FSm_kZn5CqPvvCJaJbLOQxH3rgJ05Lu50Br8a7B1XBfg%40mail.gmail.com.

Reply via email to