mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-12-02 03:26:47 +00:00
chore: reduce gVisor memory usage
This commit is contained in:
1 parent
fd74ecb6e2
commit
92433dbafc
7 files changed
+37
-12
No files matched your search
+15
-9
@@ -324,6 +324,9 @@ type RawTun struct {
|
||||
// darwin special config
|
||||
RecvMsgX bool `yaml:"recvmsgx" json:"recvmsgx,omitempty"`
|
||||
SendMsgX bool `yaml:"sendmsgx" json:"sendmsgx,omitempty"`
|
||||
|
||||
// gvisor special config (Non-public option; do not include it in the document.)
|
||||
ProcessorsPerChannel int `yaml:"processors-per-channel" json:"processors-per-channel,omitempty"`
|
||||
}
|
||||
|
||||
type RawTuicServer struct {
|
||||
@@ -538,15 +541,16 @@ func DefaultRawConfig() *RawConfig {
|
||||
Interval: 30,
|
||||
},
|
||||
Tun: RawTun{
|
||||
Enable: false,
|
||||
Device: "",
|
||||
Stack: C.TunGvisor,
|
||||
DNSHijack: []string{"0.0.0.0:53"}, // default hijack all dns query
|
||||
AutoRoute: true,
|
||||
AutoDetectInterface: true,
|
||||
Inet6Address: []netip.Prefix{netip.MustParsePrefix("fdfe:dcba:9876::1/126")},
|
||||
RecvMsgX: true,
|
||||
SendMsgX: false, // In the current implementation, if enabled, the kernel may freeze during multi-thread downloads, so it is disabled by default.
|
||||
Enable: false,
|
||||
Device: "",
|
||||
Stack: C.TunGvisor,
|
||||
DNSHijack: []string{"0.0.0.0:53"}, // default hijack all dns query
|
||||
AutoRoute: true,
|
||||
AutoDetectInterface: true,
|
||||
Inet6Address: []netip.Prefix{netip.MustParsePrefix("fdfe:dcba:9876::1/126")},
|
||||
RecvMsgX: true,
|
||||
SendMsgX: false, // In the current implementation, if enabled, the kernel may freeze during multi-thread downloads, so it is disabled by default.
|
||||
ProcessorsPerChannel: 1, // For most users, memory usage is more important than peak performance. Setting this to 1 can significantly reduce memory consumption.
|
||||
},
|
||||
TuicServer: RawTuicServer{
|
||||
Enable: false,
|
||||
@@ -1732,6 +1736,8 @@ func parseTun(rawTun RawTun, dns *DNS, general *General) error {
|
||||
|
||||
RecvMsgX: rawTun.RecvMsgX,
|
||||
SendMsgX: rawTun.SendMsgX,
|
||||
|
||||
ProcessorsPerChannel: rawTun.ProcessorsPerChannel,
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -38,7 +38,7 @@ require (
|
||||
github.com/metacubex/sing-quic v0.0.0-20260904234848-1c242664697a
|
||||
github.com/metacubex/sing-shadowsocks v0.2.12
|
||||
github.com/metacubex/sing-shadowsocks2 v0.2.7
|
||||
github.com/metacubex/sing-tun v0.4.22
|
||||
github.com/metacubex/sing-tun v0.4.23
|
||||
github.com/metacubex/sing-vmess v0.2.5
|
||||
github.com/metacubex/sing-wireguard v0.0.0-20260826105301-c3ae17d19f9e
|
||||
github.com/metacubex/smux v0.0.0-20260105030934-d0c8756d3141
|
||||
|
||||
@@ -161,8 +161,8 @@ github.com/metacubex/sing-shadowsocks v0.2.12 h1:Wqzo8bYXrK5aWqxu/TjlTnYZzAKtKsa
|
||||
github.com/metacubex/sing-shadowsocks v0.2.12/go.mod h1:2e5EIaw0rxKrm1YTRmiMnDulwbGxH9hAFlrwQLQMQkU=
|
||||
github.com/metacubex/sing-shadowsocks2 v0.2.7 h1:hSuuc0YpsfiqYqt1o+fP4m34BQz4e6wVj3PPBVhor3A=
|
||||
github.com/metacubex/sing-shadowsocks2 v0.2.7/go.mod h1:vOEbfKC60txi0ca+yUlqEwOGc3Obl6cnSgx9Gf45KjE=
|
||||
github.com/metacubex/sing-tun v0.4.22 h1:6ARRJ2BIFD1u4r/DTMNcxaNuGyimfXEeUyD4iFJRaZs=
|
||||
github.com/metacubex/sing-tun v0.4.22/go.mod h1:9T0SN+FHvzRrn7hgl2kmXy5v8xzzLKW1hITButIPAco=
|
||||
github.com/metacubex/sing-tun v0.4.23 h1:k9QZ+GU0C8uCymXoXB8PZcQ/vEt4kXMuh620q3Ht8zE=
|
||||
github.com/metacubex/sing-tun v0.4.23/go.mod h1:9T0SN+FHvzRrn7hgl2kmXy5v8xzzLKW1hITButIPAco=
|
||||
github.com/metacubex/sing-vmess v0.2.5 h1:m9Zt5I27lB9fmLMZfism9sH2LcnAfShZfwSkf6/KJoE=
|
||||
github.com/metacubex/sing-vmess v0.2.5/go.mod h1:AwtlzUgf8COe9tRYAKqWZ+leDH7p5U98a0ZUpYehl8Q=
|
||||
github.com/metacubex/sing-wireguard v0.0.0-20260826105301-c3ae17d19f9e h1:KGKZt//rrELT/dEwgYcHCqNYEGr3a7uVutlZrzrZZWY=
|
||||
|
||||
@@ -108,6 +108,9 @@ type tunSchema struct {
|
||||
// darwin special config
|
||||
RecvMsgX *bool `yaml:"recvmsgx" json:"recvmsgx,omitempty"`
|
||||
SendMsgX *bool `yaml:"sendmsgx" json:"sendmsgx,omitempty"`
|
||||
|
||||
// gvisor special config (Non-public option; do not include it in the document.)
|
||||
ProcessorsPerChannel *int `yaml:"processors-per-channel" json:"processors-per-channel,omitempty"`
|
||||
}
|
||||
|
||||
type tuicServerSchema struct {
|
||||
@@ -270,6 +273,9 @@ func pointerOrDefaultTun(p *tunSchema, def LC.Tun) LC.Tun {
|
||||
if p.SendMsgX != nil {
|
||||
def.SendMsgX = *p.SendMsgX
|
||||
}
|
||||
if p.ProcessorsPerChannel != nil {
|
||||
def.ProcessorsPerChannel = *p.ProcessorsPerChannel
|
||||
}
|
||||
}
|
||||
return def
|
||||
}
|
||||
|
||||
@@ -63,6 +63,9 @@ type Tun struct {
|
||||
// darwin special config
|
||||
RecvMsgX bool `yaml:"recvmsgx" json:"recvmsgx,omitempty"`
|
||||
SendMsgX bool `yaml:"sendmsgx" json:"sendmsgx,omitempty"`
|
||||
|
||||
// gvisor special config (Non-public option; do not include it in the document.)
|
||||
ProcessorsPerChannel int `yaml:"processors-per-channel" json:"processors-per-channel,omitempty"`
|
||||
}
|
||||
|
||||
func (t *Tun) Sort() {
|
||||
@@ -232,5 +235,9 @@ func (t *Tun) Equal(other Tun) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
if t.ProcessorsPerChannel != other.ProcessorsPerChannel {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -64,6 +64,9 @@ type TunOption struct {
|
||||
// darwin special config
|
||||
RecvMsgX bool `inbound:"recvmsgx,omitempty"`
|
||||
SendMsgX bool `inbound:"sendmsgx,omitempty"`
|
||||
|
||||
// gvisor special config (Non-public option; do not include it in the document.)
|
||||
ProcessorsPerChannel int `inbound:"processors-per-channel,omitempty"`
|
||||
}
|
||||
|
||||
var _ encoding.TextUnmarshaler = (*netip.Addr)(nil) // ensure netip.Addr can decode direct by structure package
|
||||
@@ -141,6 +144,8 @@ func NewTun(options *TunOption) (*Tun, error) {
|
||||
|
||||
RecvMsgX: options.RecvMsgX,
|
||||
SendMsgX: options.SendMsgX,
|
||||
|
||||
ProcessorsPerChannel: options.ProcessorsPerChannel,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -418,6 +418,7 @@ func New(options LC.Tun, tunnel C.Tunnel, additions ...inbound.Addition) (l *Lis
|
||||
InterfaceMonitor: defaultInterfaceMonitor,
|
||||
EXP_RecvMsgX: options.RecvMsgX,
|
||||
EXP_SendMsgX: options.SendMsgX,
|
||||
EXP_ProcessorsPerChannel: options.ProcessorsPerChannel,
|
||||
}
|
||||
|
||||
if options.AutoRedirect {
|
||||
|
||||
Reference in new issue
Block a user