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.

Reply via email to