mirror of
https://github.com/Gouryella/drip.git
synced 2026-02-26 22:31:35 +00:00
- Removed the manual performance optimization configuration in main.go and replaced it with a new tuning module. - Add patterned GC tuning in server.go and tunnel_runner.go - Updated yamux configuration to a unified optimized configuration to improve throughput. - Implement connection pool preheating function to eliminate cold start delay. - Optimize session selection using a min-heap, reducing the time complexity from O(n) to O(log n). - Add a bufio.Reader pool and a buffer pool to reduce memory allocation. - Implement a fragmented lock manager to improve performance under high concurrency. - Adjust heartbeat and timeout configurations to suit high-throughput scenarios BREAKING CHANGE: Manual GC tuning configuration has been removed; automatic tuning mode is now used.
36 lines
999 B
Go
36 lines
999 B
Go
package mux
|
|
|
|
import (
|
|
"io"
|
|
|
|
"github.com/hashicorp/yamux"
|
|
|
|
"drip/internal/shared/constants"
|
|
)
|
|
|
|
// NewOptimizedConfig returns a multiplexer config optimized for tunnel scenarios.
|
|
func NewOptimizedConfig() *yamux.Config {
|
|
cfg := yamux.DefaultConfig()
|
|
cfg.AcceptBacklog = constants.YamuxAcceptBacklog
|
|
cfg.MaxStreamWindowSize = constants.YamuxMaxStreamWindowSize
|
|
cfg.StreamOpenTimeout = constants.YamuxStreamOpenTimeout
|
|
cfg.StreamCloseTimeout = constants.YamuxStreamCloseTimeout
|
|
cfg.ConnectionWriteTimeout = constants.YamuxConnectionWriteTimeout
|
|
cfg.EnableKeepAlive = true
|
|
cfg.KeepAliveInterval = constants.YamuxKeepAliveInterval
|
|
cfg.LogOutput = io.Discard
|
|
return cfg
|
|
}
|
|
|
|
// NewServerConfig returns a multiplexer config for server-side use.
|
|
func NewServerConfig() *yamux.Config {
|
|
return NewOptimizedConfig()
|
|
}
|
|
|
|
// NewClientConfig returns a multiplexer config for client-side use.
|
|
func NewClientConfig() *yamux.Config {
|
|
cfg := NewOptimizedConfig()
|
|
cfg.EnableKeepAlive = false
|
|
return cfg
|
|
}
|