feat: reduce LRU cache size and channel buffer for connection records

This commit is contained in:
SunBK201 2025-12-08 21:31:05 +08:00
parent 02bb6f343d
commit b311fa1572
8 changed files with 11 additions and 11 deletions

View File

@ -28,7 +28,7 @@ func New(cfg *config.Config, rw *rewrite.Rewriter, rc *statistics.Recorder) *Ser
Cfg: cfg, Cfg: cfg,
Rewriter: rw, Rewriter: rw,
Recorder: rc, Recorder: rc,
Cache: expirable.NewLRU[string, struct{}](1024, nil, 30*time.Minute), Cache: expirable.NewLRU[string, struct{}](512, nil, 30*time.Minute),
}, },
so_mark: base.SO_MARK, so_mark: base.SO_MARK,
} }

View File

@ -36,7 +36,7 @@ func New(cfg *config.Config, rw *rewrite.Rewriter, rc *statistics.Recorder) *Ser
Cfg: cfg, Cfg: cfg,
Rewriter: rw, Rewriter: rw,
Recorder: rc, Recorder: rc,
Cache: expirable.NewLRU[string, struct{}](1024, nil, 30*time.Minute), Cache: expirable.NewLRU[string, struct{}](512, nil, 30*time.Minute),
SkipIpChan: make(chan *net.IP, 512), SkipIpChan: make(chan *net.IP, 512),
}, },
SniffCtMarkLower: 10201, SniffCtMarkLower: 10201,

View File

@ -32,7 +32,7 @@ func New(cfg *config.Config, rw *rewrite.Rewriter, rc *statistics.Recorder) *Ser
Cfg: cfg, Cfg: cfg,
Rewriter: rw, Rewriter: rw,
Recorder: rc, Recorder: rc,
Cache: expirable.NewLRU[string, struct{}](1024, nil, 30*time.Minute), Cache: expirable.NewLRU[string, struct{}](512, nil, 30*time.Minute),
SkipIpChan: make(chan *net.IP, 512), SkipIpChan: make(chan *net.IP, 512),
}, },
so_mark: base.SO_MARK, so_mark: base.SO_MARK,

View File

@ -29,7 +29,7 @@ func New(cfg *config.Config, rw *rewrite.Rewriter, rc *statistics.Recorder) *Ser
Cfg: cfg, Cfg: cfg,
Rewriter: rw, Rewriter: rw,
Recorder: rc, Recorder: rc,
Cache: expirable.NewLRU[string, struct{}](1024, nil, 30*time.Minute), Cache: expirable.NewLRU[string, struct{}](512, nil, 30*time.Minute),
}, },
so_mark: base.SO_MARK, so_mark: base.SO_MARK,
} }

View File

@ -38,7 +38,7 @@ func New(cfg *config.Config, rw *rewrite.Rewriter, rc *statistics.Recorder) *Ser
Cfg: cfg, Cfg: cfg,
Rewriter: rw, Rewriter: rw,
Recorder: rc, Recorder: rc,
Cache: expirable.NewLRU[string, struct{}](1024, nil, 30*time.Minute), Cache: expirable.NewLRU[string, struct{}](512, nil, 30*time.Minute),
SkipIpChan: make(chan *net.IP, 512), SkipIpChan: make(chan *net.IP, 512),
}, },
so_mark: base.SO_MARK, so_mark: base.SO_MARK,

View File

@ -28,8 +28,8 @@ type ConnectionRecord struct {
func NewConnectionRecordList(dumpFile string) *ConnectionRecordList { func NewConnectionRecordList(dumpFile string) *ConnectionRecordList {
return &ConnectionRecordList{ return &ConnectionRecordList{
recordAddChan: make(chan *ConnectionRecord, 500), recordAddChan: make(chan *ConnectionRecord, 100),
recordRemoveChan: make(chan *ConnectionRecord, 500), recordRemoveChan: make(chan *ConnectionRecord, 100),
records: make(map[string]*ConnectionRecord, 500), records: make(map[string]*ConnectionRecord, 500),
mu: sync.RWMutex{}, mu: sync.RWMutex{},
dumpFile: dumpFile, dumpFile: dumpFile,

View File

@ -26,8 +26,8 @@ type PassThroughRecord struct {
func NewPassThroughRecordList(dumpFile string) *PassThroughRecordList { func NewPassThroughRecordList(dumpFile string) *PassThroughRecordList {
return &PassThroughRecordList{ return &PassThroughRecordList{
recordAddChan: make(chan *PassThroughRecord, 500), recordAddChan: make(chan *PassThroughRecord, 100),
records: make(map[string]*PassThroughRecord, 500), records: make(map[string]*PassThroughRecord, 100),
mu: sync.RWMutex{}, mu: sync.RWMutex{},
dumpFile: dumpFile, dumpFile: dumpFile,
} }

View File

@ -25,8 +25,8 @@ type RewriteRecord struct {
func NewRewriteRecordList(dumpFile string) *RewriteRecordList { func NewRewriteRecordList(dumpFile string) *RewriteRecordList {
return &RewriteRecordList{ return &RewriteRecordList{
recordAddChan: make(chan *RewriteRecord, 500), recordAddChan: make(chan *RewriteRecord, 100),
records: make(map[string]*RewriteRecord, 500), records: make(map[string]*RewriteRecord, 100),
mu: sync.RWMutex{}, mu: sync.RWMutex{},
dumpFile: dumpFile, dumpFile: dumpFile,
} }