mirror of
https://github.com/lukaszraczylo/go-simple-graphql.git
synced 2026-10-15 01:07:34 +00:00
General improvements:
Added sharded cache to reduce lock contention Optimized buffer usage with pre-sized pools Improved HTTP client with connection pooling and timeouts Reduced allocations in JSON handling
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package gql
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var (
|
||||
// Pre-sized buffer pool for better performance
|
||||
bufferPool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
// Pre-allocate buffer with 4KB capacity
|
||||
b := bytes.NewBuffer(make([]byte, 0, 4096))
|
||||
return b
|
||||
},
|
||||
}
|
||||
|
||||
// Pre-allocate error maps to reduce allocations
|
||||
errPairsPool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
return make(map[string]interface{}, 1)
|
||||
},
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user