shadowsocks-go
shadowsocks-go copied to clipboard
Performance improvement, avoid create new slice for each Read
https://github.com/shadowsocks/shadowsocks-go/blob/49161ddf51fc65cf557554b8909aeb82e9da5409/shadowsocks/conn.go#L109
103.60MB 103.60MB (flat, cum) 88.15% of Total
. . 104: }
. . 105: }
. . 106:
. . 107: cipherData := c.readBuf
. . 108: if len(b) > len(cipherData) {
103.60MB 103.60MB 109: cipherData = make([]byte, len(b))
. . 110: } else {
. . 111: cipherData = cipherData[:len(b)]
. . 112: }
. . 113:
. . 114: n, err = c.Conn.Read(cipherData)
(pprof)
avoid create new slice for each Read().
cipherData := c.readBuf
if len(b) < len(cipherData) {
cipherData = cipherData[:len(b)]
}
Would you like to put up a or for this?
Have an awesome day
✉️✉️✉️✉️✉️✉️✉️✉️✉️✉️✉️✉️ Arthur lee
On 22 Jan 2019, at 11:03 AM, IrineBrunner [email protected] wrote:
https://github.com/shadowsocks/shadowsocks-go/blob/49161ddf51fc65cf557554b8909aeb82e9da5409/shadowsocks/conn.go#L109
103.60MB 103.60MB (flat, cum) 88.15% of Total . . 104: } . . 105: } . . 106: . . 107: cipherData := c.readBuf . . 108: if len(b) > len(cipherData) { 103.60MB 103.60MB 109: cipherData = make([]byte, len(b)) . . 110: } else { . . 111: cipherData = cipherData[:len(b)] . . 112: } . . 113: . . 114: n, err = c.Conn.Read(cipherData) (pprof)
avoid create new slice for each Read().
cipherData := c.readBuf if len(b) < len(cipherData) { cipherData = cipherData[:len(b)] }
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.