mirror of
https://github.com/SunBK201/UA3F.git
synced 2025-12-16 16:57:08 +00:00
feat: reduce LRU cache size and channel buffer for connection records
This commit is contained in:
parent
02bb6f343d
commit
b311fa1572
@ -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,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
@ -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,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
@ -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,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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,
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user