mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-24 01:38:50 +02:00
perf(pool): split bytes pool into tiered sized and unsized pools
- Remove BytesPoolWithMemory; split into UnsizedBytesPool and 11-tier SizedBytesPool - Track buffer capacities with xsync Map to prevent capacity leaks - Improve buffer reuse: split large buffers and put remainders back in pool - Optimize small buffers to use unsized pool - Expand test coverage and benchmarks for various allocation sizes
This commit is contained in:
@@ -76,7 +76,7 @@ const (
|
||||
errBurst = 5
|
||||
)
|
||||
|
||||
var lineBufPool = synk.GetBytesPoolWithUniqueMemory()
|
||||
var bytesPool = synk.GetUnsizedBytesPool()
|
||||
|
||||
func NewAccessLogger(parent task.Parent, cfg AnyConfig) (*AccessLogger, error) {
|
||||
io, err := cfg.IO()
|
||||
@@ -156,13 +156,13 @@ func (l *AccessLogger) Log(req *http.Request, res *http.Response) {
|
||||
return
|
||||
}
|
||||
|
||||
line := lineBufPool.Get()
|
||||
line := bytesPool.Get()
|
||||
line = l.AppendRequestLog(line, req, res)
|
||||
if line[len(line)-1] != '\n' {
|
||||
line = append(line, '\n')
|
||||
}
|
||||
l.write(line)
|
||||
lineBufPool.Put(line)
|
||||
bytesPool.Put(line)
|
||||
}
|
||||
|
||||
func (l *AccessLogger) LogError(req *http.Request, err error) {
|
||||
@@ -170,13 +170,13 @@ func (l *AccessLogger) LogError(req *http.Request, err error) {
|
||||
}
|
||||
|
||||
func (l *AccessLogger) LogACL(info *maxmind.IPInfo, blocked bool) {
|
||||
line := lineBufPool.Get()
|
||||
line := bytesPool.Get()
|
||||
line = l.AppendACLLog(line, info, blocked)
|
||||
if line[len(line)-1] != '\n' {
|
||||
line = append(line, '\n')
|
||||
}
|
||||
l.write(line)
|
||||
lineBufPool.Put(line)
|
||||
bytesPool.Put(line)
|
||||
}
|
||||
|
||||
func (l *AccessLogger) ShouldRotate() bool {
|
||||
|
||||
Reference in New Issue
Block a user