Closed klauspost closed 10 months ago
ws.ReadHeader allocates a 12 byte temporary buffer to read the header into. Since io.ReadFull is used, it escapes to the heap.
ws.ReadHeader
io.ReadFull
wsutil.NewCipherReader is allocated on each call to NextFrame.
wsutil.NewCipherReader
Since the NextFrame shouldn't have concurrent calls, both of these should be possible to have internally.
NextFrame
I am forced to copy "readHeader" from ws, since there is not way to eliminate the alloc otherwise as far as I can tell.
ws
Thanks! I will finish #171 tomorrow and will release a new version.
Sorry for the delay, released as v1.3.1 https://github.com/gobwas/ws/releases/tag/v1.3.1
ws.ReadHeader
allocates a 12 byte temporary buffer to read the header into. Sinceio.ReadFull
is used, it escapes to the heap.wsutil.NewCipherReader
is allocated on each call to NextFrame.Since the
NextFrame
shouldn't have concurrent calls, both of these should be possible to have internally.I am forced to copy "readHeader" from
ws
, since there is not way to eliminate the alloc otherwise as far as I can tell.