ws
ws copied to clipboard
Is it necessary to use sync.Pool to reuse Reader Object in readData?
Recently,I used go tool trace to test my project which uses ws v1.0.4.The log shows readData function triggers gc easily when creates "Reader".
runtime.mallocgc:1166
runtime.newobject:1177
github.com/gobwas/ws/wsutil.readData:250
github.com/gobwas/ws/wsutil.ReadData:88
github.com/gobwas/ws/wsutil.ReadClientData:97
In my project,I use a goroutine to recieve remote data.
for {
select {
case _, ok := <-c.Stop:
if !ok {
return
}
default:
message, msgType, err := websocketUtil.ReadClientData(*c.Conn)
if err != nil {
break
}
c.Received <- model.ClientMessage{Type: msgType, Data: message}
}
}
Can optimize performance if use sync.Pool to reuse "Reader"? Reader contains many members,how to reset them properly?
I have the same problem as you
