合并多个计数器,便于统一的内存控制

This commit is contained in:
GoEdgeLab
2023-10-05 09:45:46 +08:00
parent 4cebb4d876
commit b6c19168fd
7 changed files with 18 additions and 28 deletions

View File

@@ -11,7 +11,9 @@ import (
"time"
)
const maxItemsPerGroup = 100_000
const maxItemsPerGroup = 60_000
var SharedCounter = NewCounter().WithGC()
type Counter struct {
countMaps uint64
@@ -25,11 +27,9 @@ type Counter struct {
// NewCounter create new counter
func NewCounter() *Counter {
var count = utils.SystemMemoryGB() * 2
var count = utils.SystemMemoryGB() * 4
if count < 8 {
count = 8
} else if count > 128 {
count = 128
}
var itemMaps = []map[uint64]*Item{}