mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-17 16:26:47 +03:00
Scalability improvement: use distinct workerChan pool per each workerPool
This commit is contained in:
+4
-4
@@ -32,6 +32,8 @@ type workerPool struct {
|
||||
ready []*workerChan
|
||||
|
||||
stopCh chan struct{}
|
||||
|
||||
workerChanPool sync.Pool
|
||||
}
|
||||
|
||||
type workerChan struct {
|
||||
@@ -148,7 +150,7 @@ func (wp *workerPool) getCh() *workerChan {
|
||||
if !createWorker {
|
||||
return nil
|
||||
}
|
||||
vch := workerChanPool.Get()
|
||||
vch := wp.workerChanPool.Get()
|
||||
if vch == nil {
|
||||
vch = &workerChan{
|
||||
ch: make(chan net.Conn, workerChanCap),
|
||||
@@ -157,7 +159,7 @@ func (wp *workerPool) getCh() *workerChan {
|
||||
ch = vch.(*workerChan)
|
||||
go func() {
|
||||
wp.workerFunc(ch)
|
||||
workerChanPool.Put(vch)
|
||||
wp.workerChanPool.Put(vch)
|
||||
}()
|
||||
}
|
||||
return ch
|
||||
@@ -175,8 +177,6 @@ func (wp *workerPool) release(ch *workerChan) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
var workerChanPool sync.Pool
|
||||
|
||||
func (wp *workerPool) workerFunc(ch *workerChan) {
|
||||
var c net.Conn
|
||||
var err error
|
||||
|
||||
Reference in New Issue
Block a user