Răsfoiți Sursa

fasthttp: removed 'prefork' hack on periodic connection closing

This hack is irrelevant for the benchmark, since 16K connections
in plaintext benchmark are guaranteed to be spread among available
CPU cores, so every CPU core is fully loaded.
Aliaksandr Valialkin 9 ani în urmă
părinte
comite
f42b82d390

+ 0 - 17
frameworks/Go/fasthttp-mysql/src/hello/hello.go

@@ -13,8 +13,6 @@ import (
 	"runtime"
 	"sort"
 	"sync"
-	"sync/atomic"
-	"time"
 
 	_ "github.com/go-sql-driver/mysql"
 	"github.com/valyala/fasthttp"
@@ -95,22 +93,7 @@ func main() {
 	}
 }
 
-const maxConnDuration = time.Millisecond * 1500
-
-var connDurationJitter uint64
-
 func mainHandler(ctx *fasthttp.RequestCtx) {
-	// Performance hack for prefork mode - periodically close keepalive
-	// connections for evenly distributing connections among available
-	// processes.
-	if *prefork {
-		maxDuration := maxConnDuration + time.Millisecond*time.Duration(atomic.LoadUint64(&connDurationJitter))
-		if time.Since(ctx.ConnTime()) > maxDuration {
-			atomic.StoreUint64(&connDurationJitter, uint64(rand.Intn(100)))
-			ctx.SetConnectionClose()
-		}
-	}
-
 	path := ctx.Path()
 	switch string(path) {
 	case "/plaintext":

+ 0 - 17
frameworks/Go/fasthttp-postgresql/src/hello/hello.go

@@ -13,8 +13,6 @@ import (
 	"runtime"
 	"sort"
 	"sync"
-	"sync/atomic"
-	"time"
 
 	"github.com/jackc/pgx"
 	"github.com/valyala/fasthttp"
@@ -86,22 +84,7 @@ func main() {
 	}
 }
 
-const maxConnDuration = time.Millisecond * 1500
-
-var connDurationJitter uint64
-
 func mainHandler(ctx *fasthttp.RequestCtx) {
-	// Performance hack for prefork mode - periodically close keepalive
-	// connections for evenly distributing connections among available
-	// processes.
-	if *prefork {
-		maxDuration := maxConnDuration + time.Millisecond*time.Duration(atomic.LoadUint64(&connDurationJitter))
-		if time.Since(ctx.ConnTime()) > maxDuration {
-			atomic.StoreUint64(&connDurationJitter, uint64(rand.Intn(100)))
-			ctx.SetConnectionClose()
-		}
-	}
-
 	path := ctx.Path()
 	switch string(path) {
 	case "/plaintext":