In addition, look at allocation. If you can keep the garbage collector
constantly busy it'll use the available CPU cores in the machine. It is
likely to improve the system by quite a lot.

On Tue, Dec 19, 2017 at 11:36 AM Gulácsi Tamás <tgulacs...@gmail.com> wrote:

> You don't need to use bufio, but you'll need buffering to decrement the
> count of Read calls (thus, syscalls).
> Reusing []byte slices: use a sync.Pool. Or several sync.Pools for
> different byte slices.
>
> Vasiliy Tolstov <v.tols...@selfip.ru> ezt írta (időpont: 2017. dec. 19.,
> K, 11:30):
>
>> If I have something like this, but I know that client sends fixed sized
>> message header 48 byte and variable sized body based on data in header, and
>> want to minimize allocations. Does I need to use bufio?
>> Now I'm use goleveldb util package for reusable byte slice.
>>
>> 19 Дек 2017 г. 11:22 пользователь "Dan Kortschak" <
>> dan.kortsc...@adelaide.edu.au> написал:
>>
>>> bufio.NewReader
>>>
>>> On Mon, 2017-12-18 at 05:11 -0800, Tamás Gulácsi wrote:
>>> > >         n, err := sock.Read(buf)
>>> > >
>>> > >
>>> > This will be slow: TCP is a streaming protocol, so this Read can read
>>> > any
>>> > length between 0 (! yes !) and 1024 bytes.
>>> > Use buffering (bytes.NewReader) and some kind of message separation
>>> > (e.g.
>>> > bufio.Scanner for a line-oriented protocol).
>>>
>>> --
>>> 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.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to