mirror of
				https://github.com/redis/go-redis.git
				synced 2025-11-04 02:33:24 +03:00 
			
		
		
		
	feat(pool): Improve success rate of new connections (#3518)
* async create conn * update default values and testcase * fix comments * fix data race * remove context.WithoutCancel, which is a function introduced in Go 1.21 * fix TestDialerRetryConfiguration/DefaultDialerRetries, because tryDial are likely done in async flow * change to share failed to delivery connection to other waiting * remove chinese comment * fix: optimize WantConnQueue benchmarks to prevent memory exhaustion - Fix BenchmarkWantConnQueue_Dequeue timeout issue by limiting pre-population - Use object pooling in BenchmarkWantConnQueue_Enqueue to reduce allocations - Optimize BenchmarkWantConnQueue_EnqueueDequeue with reusable wantConn pool - Prevent GitHub Actions benchmark failures due to excessive memory usage Before: BenchmarkWantConnQueue_Dequeue ran for 11+ minutes and was killed After: All benchmarks complete in ~8 seconds with consistent performance * format * fix turn leaks --------- Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com> Co-authored-by: Hristo Temelski <hristo.temelski@redis.com>
This commit is contained in:
		@@ -53,8 +53,9 @@ func TestEventDrivenHandoffIntegration(t *testing.T) {
 | 
			
		||||
			Dialer: func(ctx context.Context) (net.Conn, error) {
 | 
			
		||||
				return &mockNetConn{addr: "original:6379"}, nil
 | 
			
		||||
			},
 | 
			
		||||
			PoolSize:    int32(5),
 | 
			
		||||
			PoolTimeout: time.Second,
 | 
			
		||||
			PoolSize:           int32(5),
 | 
			
		||||
			MaxConcurrentDials: 5,
 | 
			
		||||
			PoolTimeout:        time.Second,
 | 
			
		||||
		})
 | 
			
		||||
 | 
			
		||||
		// Add the hook to the pool after creation
 | 
			
		||||
@@ -153,8 +154,9 @@ func TestEventDrivenHandoffIntegration(t *testing.T) {
 | 
			
		||||
				return &mockNetConn{addr: "original:6379"}, nil
 | 
			
		||||
			},
 | 
			
		||||
 | 
			
		||||
			PoolSize:    int32(10),
 | 
			
		||||
			PoolTimeout: time.Second,
 | 
			
		||||
			PoolSize:           int32(10),
 | 
			
		||||
			MaxConcurrentDials: 10,
 | 
			
		||||
			PoolTimeout:        time.Second,
 | 
			
		||||
		})
 | 
			
		||||
		defer testPool.Close()
 | 
			
		||||
 | 
			
		||||
@@ -225,8 +227,9 @@ func TestEventDrivenHandoffIntegration(t *testing.T) {
 | 
			
		||||
				return &mockNetConn{addr: "original:6379"}, nil
 | 
			
		||||
			},
 | 
			
		||||
 | 
			
		||||
			PoolSize:    int32(3),
 | 
			
		||||
			PoolTimeout: time.Second,
 | 
			
		||||
			PoolSize:           int32(3),
 | 
			
		||||
			MaxConcurrentDials: 3,
 | 
			
		||||
			PoolTimeout:        time.Second,
 | 
			
		||||
		})
 | 
			
		||||
		defer testPool.Close()
 | 
			
		||||
 | 
			
		||||
@@ -288,8 +291,9 @@ func TestEventDrivenHandoffIntegration(t *testing.T) {
 | 
			
		||||
				return &mockNetConn{addr: "original:6379"}, nil
 | 
			
		||||
			},
 | 
			
		||||
 | 
			
		||||
			PoolSize:    int32(2),
 | 
			
		||||
			PoolTimeout: time.Second,
 | 
			
		||||
			PoolSize:           int32(2),
 | 
			
		||||
			MaxConcurrentDials: 2,
 | 
			
		||||
			PoolTimeout:        time.Second,
 | 
			
		||||
		})
 | 
			
		||||
		defer testPool.Close()
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user