Skip to content

Commit

Permalink
XHTTP XMUX: cMaxLifetimeMs -> hMaxReusableSecs, Refactor default …
Browse files Browse the repository at this point in the history
…values

"xmux": {
    "maxConcurrency": "16-32",
    "maxConnections": 0,
    "cMaxReuseTimes": 0,
    "hMaxRequestTimes": "600-900",
    "hMaxReusableSecs": "1800-3000",
    "hKeepAlivePeriod": 0
}

Fixes #4113 (reply in thread)
  • Loading branch information
RPRX authored Dec 31, 2024
1 parent 93f72db commit 4ce65fc
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 130 deletions.
10 changes: 5 additions & 5 deletions infra/conf/transport_internet.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ type XmuxConfig struct {
MaxConcurrency Int32Range `json:"maxConcurrency"`
MaxConnections Int32Range `json:"maxConnections"`
CMaxReuseTimes Int32Range `json:"cMaxReuseTimes"`
CMaxLifetimeMs Int32Range `json:"cMaxLifetimeMs"`
HMaxRequestTimes Int32Range `json:"hMaxRequestTimes"`
HMaxReusableSecs Int32Range `json:"hMaxReusableSecs"`
HKeepAlivePeriod int64 `json:"hKeepAlivePeriod"`
}

Expand Down Expand Up @@ -287,10 +287,10 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) {
if c.Xmux == (XmuxConfig{}) {
c.Xmux.MaxConcurrency.From = 16
c.Xmux.MaxConcurrency.To = 32
c.Xmux.CMaxReuseTimes.From = 256
c.Xmux.CMaxReuseTimes.To = 512
c.Xmux.HMaxRequestTimes.From = 800
c.Xmux.HMaxRequestTimes.From = 600
c.Xmux.HMaxRequestTimes.To = 900
c.Xmux.HMaxReusableSecs.From = 1800
c.Xmux.HMaxReusableSecs.To = 3000
}

config := &splithttp.Config{
Expand All @@ -308,8 +308,8 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) {
MaxConcurrency: newRangeConfig(c.Xmux.MaxConcurrency),
MaxConnections: newRangeConfig(c.Xmux.MaxConnections),
CMaxReuseTimes: newRangeConfig(c.Xmux.CMaxReuseTimes),
CMaxLifetimeMs: newRangeConfig(c.Xmux.CMaxLifetimeMs),
HMaxRequestTimes: newRangeConfig(c.Xmux.HMaxRequestTimes),
HMaxReusableSecs: newRangeConfig(c.Xmux.HMaxReusableSecs),
HKeepAlivePeriod: c.Xmux.HKeepAlivePeriod,
},
}
Expand Down
53 changes: 27 additions & 26 deletions transport/internet/splithttp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,15 @@ func (c *Config) WriteResponseHeader(writer http.ResponseWriter) {
}
}

func (c *Config) GetNormalizedScMaxBufferedPosts() int {
if c.ScMaxBufferedPosts == 0 {
return 30
func (c *Config) GetNormalizedXPaddingBytes() RangeConfig {
if c.XPaddingBytes == nil || c.XPaddingBytes.To == 0 {
return RangeConfig{
From: 100,
To: 1000,
}
}

return int(c.ScMaxBufferedPosts)
return *c.XPaddingBytes
}

func (c *Config) GetNormalizedScMaxEachPostBytes() RangeConfig {
Expand All @@ -94,69 +97,67 @@ func (c *Config) GetNormalizedScMinPostsIntervalMs() RangeConfig {
return *c.ScMinPostsIntervalMs
}

func (c *Config) GetNormalizedXPaddingBytes() RangeConfig {
if c.XPaddingBytes == nil || c.XPaddingBytes.To == 0 {
return RangeConfig{
From: 100,
To: 1000,
}
func (c *Config) GetNormalizedScMaxBufferedPosts() int {
if c.ScMaxBufferedPosts == 0 {
return 30
}

return *c.XPaddingBytes
return int(c.ScMaxBufferedPosts)
}

func (m *XmuxConfig) GetNormalizedCMaxRequestTimes() RangeConfig {
if m.HMaxRequestTimes == nil {
func (m *XmuxConfig) GetNormalizedMaxConcurrency() RangeConfig {
if m.MaxConcurrency == nil {
return RangeConfig{
From: 0,
To: 0,
}
}

return *m.HMaxRequestTimes
return *m.MaxConcurrency
}

func (m *XmuxConfig) GetNormalizedCMaxReuseTimes() RangeConfig {
if m.CMaxReuseTimes == nil {
func (m *XmuxConfig) GetNormalizedMaxConnections() RangeConfig {
if m.MaxConnections == nil {
return RangeConfig{
From: 0,
To: 0,
}
}

return *m.CMaxReuseTimes
return *m.MaxConnections
}

func (m *XmuxConfig) GetNormalizedCMaxLifetimeMs() RangeConfig {
if m.CMaxLifetimeMs == nil {
func (m *XmuxConfig) GetNormalizedCMaxReuseTimes() RangeConfig {
if m.CMaxReuseTimes == nil {
return RangeConfig{
From: 0,
To: 0,
}
}
return *m.CMaxLifetimeMs

return *m.CMaxReuseTimes
}

func (m *XmuxConfig) GetNormalizedMaxConnections() RangeConfig {
if m.MaxConnections == nil {
func (m *XmuxConfig) GetNormalizedHMaxRequestTimes() RangeConfig {
if m.HMaxRequestTimes == nil {
return RangeConfig{
From: 0,
To: 0,
}
}

return *m.MaxConnections
return *m.HMaxRequestTimes
}

func (m *XmuxConfig) GetNormalizedMaxConcurrency() RangeConfig {
if m.MaxConcurrency == nil {
func (m *XmuxConfig) GetNormalizedHMaxReusableSecs() RangeConfig {
if m.HMaxReusableSecs == nil {
return RangeConfig{
From: 0,
To: 0,
}
}

return *m.MaxConcurrency
return *m.HMaxReusableSecs
}

func init() {
Expand Down
Loading

0 comments on commit 4ce65fc

Please sign in to comment.