Re: [go-nuts] Re: Why is the cpu usage so high in a golang tcp server?

2017-12-19 Thread Jesper Louis Andersen
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 wrote: > You don't need to use bufio,

Re: [go-nuts] Re: Why is the cpu usage so high in a golang tcp server?

2017-12-19 Thread Gulácsi Tamás
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 ezt írta (időpont: 2017. dec. 19., K, 11:30): > If I have

Re: [go-nuts] Re: Why is the cpu usage so high in a golang tcp server?

2017-12-19 Thread Vasiliy Tolstov
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 пользователь

Re: [go-nuts] Re: Why is the cpu usage so high in a golang tcp server?

2017-12-19 Thread Dan Kortschak
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

[go-nuts] Re: Why is the cpu usage so high in a golang tcp server?

2017-12-18 Thread Tamás Gulácsi
2017. december 18., hétfő 14:11:34 UTC+1 időpontban Tamás Gulácsi a következőt írta: > > > 2017. december 18., hétfő 13:51:26 UTC+1 időpontban eric.sh...@gmail.com > a következőt írta: >> >> I try to implement a golang tcp server, and I found the concurrency is >> satisfied for me, but the

[go-nuts] Re: Why is the cpu usage so high in a golang tcp server?

2017-12-18 Thread Tamás Gulácsi
2017. december 18., hétfő 13:51:26 UTC+1 időpontban eric.sh...@gmail.com a következőt írta: > > I try to implement a golang tcp server, and I found the concurrency is > satisfied for me, but the CPU usage is too high(concurrency is 15W+/s, but > the CPU usage is about 800% in a 24 cores linux