LINUX.ORG.RU

История изменений

Исправление beastie, (текущая версия) :

По ходу там горилла буянит. Выделяет по 2GB на каждый коннект.

(pprof) top
Showing nodes accounting for 4GB, 100% of 4GB total
      flat  flat%   sum%        cum   cum%
       2GB 50.00% 50.00%        4GB   100%  github.com/gorilla/websocket.newConn
       2GB 50.00%   100%        2GB 50.00%  bufio.NewReaderSize (inline)
         0     0%   100%        4GB   100%  github.com/gorilla/websocket.(*Upgrader).Upgrade
         0     0%   100%        4GB   100%  main.wsHandler
         0     0%   100%        4GB   100%  net/http.(*ServeMux).ServeHTTP
         0     0%   100%        4GB   100%  net/http.(*conn).serve
         0     0%   100%        4GB   100%  net/http.HandlerFunc.ServeHTTP
         0     0%   100%        4GB   100%  net/http.serverHandler.ServeHTTP
(pprof) list newConn
Total: 4GB
ROUTINE ======================== github.com/gorilla/websocket.newConn in /Users/dima/go/pkg/mod/github.com/gorilla/websocket@v1.5.0/conn.go
       2GB        4GB (flat, cum)   100% of Total
         .          .    285:func newConn(conn net.Conn, isServer bool, readBufferSize, writeBufferSize int, writeBufferPool BufferPool, br *bufio.Reader, writeBuf []byte) *Conn {
         .          .    286:
         .          .    287:	if br == nil {
         .          .    288:		if readBufferSize == 0 {
         .          .    289:			readBufferSize = defaultReadBufferSize
         .          .    290:		} else if readBufferSize < maxControlFramePayloadSize {
         .          .    291:			// must be large enough for control frame
         .          .    292:			readBufferSize = maxControlFramePayloadSize
         .          .    293:		}
         .        2GB    294:		br = bufio.NewReaderSize(conn, readBufferSize)
         .          .    295:	}
         .          .    296:
         .          .    297:	if writeBufferSize <= 0 {
         .          .    298:		writeBufferSize = defaultWriteBufferSize
         .          .    299:	}
         .          .    300:	writeBufferSize += maxFrameHeaderSize
         .          .    301:
         .          .    302:	if writeBuf == nil && writeBufferPool == nil {
       2GB        2GB    303:		writeBuf = make([]byte, writeBufferSize)
         .          .    304:	}
         .          .    305:
         .          .    306:	mu := make(chan struct{}, 1)
         .          .    307:	mu <- struct{}{}
         .          .    308:	c := &Conn{
(pprof)

Исходная версия beastie, :

По ходу там горилла буянит. Выделяет по 2GB на каждый коннект.

Total: 4GB
ROUTINE ======================== github.com/gorilla/websocket.newConn in /Users/dima/go/pkg/mod/github.com/gorilla/websocket@v1.5.0/conn.go
       2GB        4GB (flat, cum)   100% of Total
         .          .    285:func newConn(conn net.Conn, isServer bool, readBufferSize, writeBufferSize int, writeBufferPool BufferPool, br *bufio.Reader, writeBuf []byte) *Conn {
         .          .    286:
         .          .    287:	if br == nil {
         .          .    288:		if readBufferSize == 0 {
         .          .    289:			readBufferSize = defaultReadBufferSize
         .          .    290:		} else if readBufferSize < maxControlFramePayloadSize {
         .          .    291:			// must be large enough for control frame
         .          .    292:			readBufferSize = maxControlFramePayloadSize
         .          .    293:		}
         .        2GB    294:		br = bufio.NewReaderSize(conn, readBufferSize)
         .          .    295:	}
         .          .    296:
         .          .    297:	if writeBufferSize <= 0 {
         .          .    298:		writeBufferSize = defaultWriteBufferSize
         .          .    299:	}
         .          .    300:	writeBufferSize += maxFrameHeaderSize
         .          .    301:
         .          .    302:	if writeBuf == nil && writeBufferPool == nil {
       2GB        2GB    303:		writeBuf = make([]byte, writeBufferSize)
         .          .    304:	}
         .          .    305:
         .          .    306:	mu := make(chan struct{}, 1)
         .          .    307:	mu <- struct{}{}
         .          .    308:	c := &Conn{