From 04bff814d98914624c712f75eaf2e07668644303 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Thu, 28 Mar 2024 17:17:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/caches/list_file_db_sqlite.go | 4 ++-- internal/caches/list_file_hash_map_sqlite.go | 4 ++-- internal/caches/manager.go | 4 ++-- internal/caches/memory_fragment_pool.go | 4 ++-- internal/caches/open_file_cache.go | 4 ++-- internal/caches/storage_memory.go | 3 ++- internal/compressions/reader_pool_brotli.go | 4 ++-- internal/compressions/reader_pool_deflate.go | 4 ++-- internal/compressions/reader_pool_gzip.go | 4 ++-- internal/compressions/reader_pool_zstd.go | 4 ++-- internal/compressions/writer_pool_brotli.go | 4 ++-- internal/compressions/writer_pool_deflate.go | 4 ++-- internal/compressions/writer_pool_gzip.go | 4 ++-- internal/compressions/writer_pool_zstd.go | 4 ++-- internal/nodes/http_access_log_queue.go | 3 ++- internal/nodes/node.go | 3 ++- internal/stats/user_agent_parser.go | 4 ++-- internal/ttlcache/cache.go | 6 +++--- internal/ttlcache/cache_test.go | 4 ++-- internal/utils/byte_pool.go | 8 ++++---- internal/utils/cachehits/stat.go | 4 ++-- internal/utils/counters/counter.go | 4 ++-- internal/utils/kvstore/store.go | 4 ++-- internal/utils/{ => mem}/system.go | 2 +- internal/utils/{ => mem}/system_1.19.go | 2 +- internal/utils/{ => mem}/system_before_1.19.go | 2 +- internal/utils/system_test.go | 14 -------------- 27 files changed, 52 insertions(+), 63 deletions(-) rename internal/utils/{ => mem}/system.go (98%) rename internal/utils/{ => mem}/system_1.19.go (95%) rename internal/utils/{ => mem}/system_before_1.19.go (91%) delete mode 100644 internal/utils/system_test.go diff --git a/internal/caches/list_file_db_sqlite.go b/internal/caches/list_file_db_sqlite.go index 72ce0de..039f078 100644 --- a/internal/caches/list_file_db_sqlite.go +++ b/internal/caches/list_file_db_sqlite.go @@ -7,9 +7,9 @@ import ( "fmt" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" - "github.com/TeaOSLab/EdgeNode/internal/utils" "github.com/TeaOSLab/EdgeNode/internal/utils/dbs" "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" + memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "github.com/iwind/TeaGo/logs" "github.com/iwind/TeaGo/types" "net" @@ -64,7 +64,7 @@ func (this *SQLiteFileListDB) Open(dbPath string) error { // 动态调整Cache值 var cacheSize = 512 - var memoryGB = utils.SystemMemoryGB() + var memoryGB = memutils.SystemMemoryGB() if memoryGB >= 1 { cacheSize = 256 * memoryGB } diff --git a/internal/caches/list_file_hash_map_sqlite.go b/internal/caches/list_file_hash_map_sqlite.go index 6fe347f..b8d4792 100644 --- a/internal/caches/list_file_hash_map_sqlite.go +++ b/internal/caches/list_file_hash_map_sqlite.go @@ -3,7 +3,7 @@ package caches import ( - "github.com/TeaOSLab/EdgeNode/internal/utils" + memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "github.com/TeaOSLab/EdgeNode/internal/zero" "math/big" "sync" @@ -46,7 +46,7 @@ func NewSQLiteFileListHashMap() *SQLiteFileListHashMap { func (this *SQLiteFileListHashMap) Load(db *SQLiteFileListDB) error { // 如果系统内存过小,我们不缓存 - if utils.SystemMemoryGB() < 3 { + if memutils.SystemMemoryGB() < 3 { return nil } diff --git a/internal/caches/manager.go b/internal/caches/manager.go index bd4913c..fb87e28 100644 --- a/internal/caches/manager.go +++ b/internal/caches/manager.go @@ -7,7 +7,7 @@ import ( teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/events" "github.com/TeaOSLab/EdgeNode/internal/remotelogs" - "github.com/TeaOSLab/EdgeNode/internal/utils" + memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "github.com/iwind/TeaGo/lists" "github.com/iwind/TeaGo/types" "golang.org/x/sys/unix" @@ -299,7 +299,7 @@ func (this *Manager) MaxSystemMemoryBytesPerStorage() int64 { count = 1 } - var resultBytes = int64(utils.SystemMemoryBytes()) / 3 / int64(count) // 1/3 of the system memory + var resultBytes = int64(memutils.SystemMemoryBytes()) / 3 / int64(count) // 1/3 of the system memory if resultBytes < 1<<30 { resultBytes = 1 << 30 } diff --git a/internal/caches/memory_fragment_pool.go b/internal/caches/memory_fragment_pool.go index 9e4541a..6a13b63 100644 --- a/internal/caches/memory_fragment_pool.go +++ b/internal/caches/memory_fragment_pool.go @@ -5,8 +5,8 @@ package caches import ( teaconst "github.com/TeaOSLab/EdgeNode/internal/const" "github.com/TeaOSLab/EdgeNode/internal/goman" - "github.com/TeaOSLab/EdgeNode/internal/utils" "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" + memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "github.com/iwind/TeaGo/logs" "os" "sync" @@ -93,7 +93,7 @@ func NewMemoryFragmentPool() *MemoryFragmentPool { } func (this *MemoryFragmentPool) init() { - var capacity = int64(utils.SystemMemoryGB()) << 30 / 16 + var capacity = int64(memutils.SystemMemoryGB()) << 30 / 16 if capacity > 256<<20 { this.isOk = true this.capacity = capacity diff --git a/internal/caches/open_file_cache.go b/internal/caches/open_file_cache.go index 7a8a88a..5872a5f 100644 --- a/internal/caches/open_file_cache.go +++ b/internal/caches/open_file_cache.go @@ -5,8 +5,8 @@ package caches import ( "fmt" "github.com/TeaOSLab/EdgeNode/internal/goman" - "github.com/TeaOSLab/EdgeNode/internal/utils" "github.com/TeaOSLab/EdgeNode/internal/utils/linkedlist" + memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "github.com/fsnotify/fsnotify" "github.com/iwind/TeaGo/logs" "github.com/iwind/TeaGo/types" @@ -43,7 +43,7 @@ func NewOpenFileCache(maxCount int) (*OpenFileCache, error) { maxCount: maxCount, poolMap: map[string]*OpenFilePool{}, poolList: linkedlist.NewList[*OpenFilePool](), - capacitySize: (int64(utils.SystemMemoryGB()) << 30) / 16, + capacitySize: (int64(memutils.SystemMemoryGB()) << 30) / 16, } watcher, err := fsnotify.NewWatcher() diff --git a/internal/caches/storage_memory.go b/internal/caches/storage_memory.go index a102335..262dbd7 100644 --- a/internal/caches/storage_memory.go +++ b/internal/caches/storage_memory.go @@ -9,6 +9,7 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/utils" "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" + memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" setutils "github.com/TeaOSLab/EdgeNode/internal/utils/sets" "github.com/TeaOSLab/EdgeNode/internal/zero" "github.com/cespare/xxhash" @@ -66,7 +67,7 @@ func NewMemoryStorage(policy *serverconfigs.HTTPCachePolicy, parentStorage Stora if parentStorage != nil { if queueSize <= 0 { - queueSize = utils.SystemMemoryGB() * 100_000 + queueSize = memutils.SystemMemoryGB() * 100_000 } dirtyChan = make(chan string, queueSize) diff --git a/internal/compressions/reader_pool_brotli.go b/internal/compressions/reader_pool_brotli.go index 37bcbcf..282bde2 100644 --- a/internal/compressions/reader_pool_brotli.go +++ b/internal/compressions/reader_pool_brotli.go @@ -4,7 +4,7 @@ package compressions import ( teaconst "github.com/TeaOSLab/EdgeNode/internal/const" - "github.com/TeaOSLab/EdgeNode/internal/utils" + memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "io" ) @@ -15,7 +15,7 @@ func init() { return } - var maxSize = utils.SystemMemoryGB() * 256 + var maxSize = memutils.SystemMemoryGB() * 256 if maxSize == 0 { maxSize = 256 } diff --git a/internal/compressions/reader_pool_deflate.go b/internal/compressions/reader_pool_deflate.go index c83c607..03b3bfa 100644 --- a/internal/compressions/reader_pool_deflate.go +++ b/internal/compressions/reader_pool_deflate.go @@ -4,7 +4,7 @@ package compressions import ( teaconst "github.com/TeaOSLab/EdgeNode/internal/const" - "github.com/TeaOSLab/EdgeNode/internal/utils" + memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "io" ) @@ -15,7 +15,7 @@ func init() { return } - var maxSize = utils.SystemMemoryGB() * 256 + var maxSize = memutils.SystemMemoryGB() * 256 if maxSize == 0 { maxSize = 256 } diff --git a/internal/compressions/reader_pool_gzip.go b/internal/compressions/reader_pool_gzip.go index b6afe47..197a4f0 100644 --- a/internal/compressions/reader_pool_gzip.go +++ b/internal/compressions/reader_pool_gzip.go @@ -4,7 +4,7 @@ package compressions import ( teaconst "github.com/TeaOSLab/EdgeNode/internal/const" - "github.com/TeaOSLab/EdgeNode/internal/utils" + memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "io" ) @@ -15,7 +15,7 @@ func init() { return } - var maxSize = utils.SystemMemoryGB() * 256 + var maxSize = memutils.SystemMemoryGB() * 256 if maxSize == 0 { maxSize = 256 } diff --git a/internal/compressions/reader_pool_zstd.go b/internal/compressions/reader_pool_zstd.go index 375ef6a..c2931ca 100644 --- a/internal/compressions/reader_pool_zstd.go +++ b/internal/compressions/reader_pool_zstd.go @@ -4,7 +4,7 @@ package compressions import ( teaconst "github.com/TeaOSLab/EdgeNode/internal/const" - "github.com/TeaOSLab/EdgeNode/internal/utils" + memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "io" ) @@ -15,7 +15,7 @@ func init() { return } - var maxSize = utils.SystemMemoryGB() * 256 + var maxSize = memutils.SystemMemoryGB() * 256 if maxSize == 0 { maxSize = 256 } diff --git a/internal/compressions/writer_pool_brotli.go b/internal/compressions/writer_pool_brotli.go index 304486a..30de41f 100644 --- a/internal/compressions/writer_pool_brotli.go +++ b/internal/compressions/writer_pool_brotli.go @@ -4,7 +4,7 @@ package compressions import ( teaconst "github.com/TeaOSLab/EdgeNode/internal/const" - "github.com/TeaOSLab/EdgeNode/internal/utils" + memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "github.com/andybalholm/brotli" "io" ) @@ -16,7 +16,7 @@ func init() { return } - var maxSize = utils.SystemMemoryGB() * 256 + var maxSize = memutils.SystemMemoryGB() * 256 if maxSize == 0 { maxSize = 256 } diff --git a/internal/compressions/writer_pool_deflate.go b/internal/compressions/writer_pool_deflate.go index 11f4a78..c91181c 100644 --- a/internal/compressions/writer_pool_deflate.go +++ b/internal/compressions/writer_pool_deflate.go @@ -5,7 +5,7 @@ package compressions import ( "compress/flate" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" - "github.com/TeaOSLab/EdgeNode/internal/utils" + memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "io" ) @@ -16,7 +16,7 @@ func init() { return } - var maxSize = utils.SystemMemoryGB() * 256 + var maxSize = memutils.SystemMemoryGB() * 256 if maxSize == 0 { maxSize = 256 } diff --git a/internal/compressions/writer_pool_gzip.go b/internal/compressions/writer_pool_gzip.go index 0b15f5e..f1a8cef 100644 --- a/internal/compressions/writer_pool_gzip.go +++ b/internal/compressions/writer_pool_gzip.go @@ -5,7 +5,7 @@ package compressions import ( "compress/gzip" teaconst "github.com/TeaOSLab/EdgeNode/internal/const" - "github.com/TeaOSLab/EdgeNode/internal/utils" + memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "io" ) @@ -16,7 +16,7 @@ func init() { return } - var maxSize = utils.SystemMemoryGB() * 256 + var maxSize = memutils.SystemMemoryGB() * 256 if maxSize == 0 { maxSize = 256 } diff --git a/internal/compressions/writer_pool_zstd.go b/internal/compressions/writer_pool_zstd.go index 2a146b3..42f80b1 100644 --- a/internal/compressions/writer_pool_zstd.go +++ b/internal/compressions/writer_pool_zstd.go @@ -4,7 +4,7 @@ package compressions import ( teaconst "github.com/TeaOSLab/EdgeNode/internal/const" - "github.com/TeaOSLab/EdgeNode/internal/utils" + memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "github.com/klauspost/compress/zstd" "io" ) @@ -16,7 +16,7 @@ func init() { return } - var maxSize = utils.SystemMemoryGB() * 256 + var maxSize = memutils.SystemMemoryGB() * 256 if maxSize == 0 { maxSize = 256 } diff --git a/internal/nodes/http_access_log_queue.go b/internal/nodes/http_access_log_queue.go index fe0f0ae..29402f6 100644 --- a/internal/nodes/http_access_log_queue.go +++ b/internal/nodes/http_access_log_queue.go @@ -7,6 +7,7 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/remotelogs" "github.com/TeaOSLab/EdgeNode/internal/rpc" "github.com/TeaOSLab/EdgeNode/internal/utils" + memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "strings" @@ -26,7 +27,7 @@ type HTTPAccessLogQueue struct { // NewHTTPAccessLogQueue 获取新对象 func NewHTTPAccessLogQueue() *HTTPAccessLogQueue { // 队列中最大的值,超出此数量的访问日志会被丢弃 - var maxSize = 2_000 * (1 + utils.SystemMemoryGB()/2) + var maxSize = 2_000 * (1 + memutils.SystemMemoryGB()/2) if maxSize > 20_000 { maxSize = 20_000 } diff --git a/internal/nodes/node.go b/internal/nodes/node.go index 8111eb2..72ba53a 100644 --- a/internal/nodes/node.go +++ b/internal/nodes/node.go @@ -29,6 +29,7 @@ import ( _ "github.com/TeaOSLab/EdgeNode/internal/utils/agents" // 引入Agent管理器 _ "github.com/TeaOSLab/EdgeNode/internal/utils/clock" // 触发时钟更新 "github.com/TeaOSLab/EdgeNode/internal/utils/jsonutils" + memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "github.com/TeaOSLab/EdgeNode/internal/waf" "github.com/andybalholm/brotli" "github.com/iwind/TeaGo/Tea" @@ -1123,7 +1124,7 @@ func (this *Node) tuneSystemParameters() { } // vm - var systemMemory = utils.SystemMemoryGB() + var systemMemory = memutils.SystemMemoryGB() if systemMemory >= 128 { systemParameters = append(systemParameters, []variable{ {name: "vm.dirty_background_ratio", minValue: 40}, diff --git a/internal/stats/user_agent_parser.go b/internal/stats/user_agent_parser.go index 680e642..65ba3cf 100644 --- a/internal/stats/user_agent_parser.go +++ b/internal/stats/user_agent_parser.go @@ -4,8 +4,8 @@ package stats import ( "github.com/TeaOSLab/EdgeNode/internal/goman" - "github.com/TeaOSLab/EdgeNode/internal/utils" "github.com/TeaOSLab/EdgeNode/internal/utils/fnv" + memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" syncutils "github.com/TeaOSLab/EdgeNode/internal/utils/sync" "github.com/mssola/useragent" "sync" @@ -50,7 +50,7 @@ func NewUserAgentParser() *UserAgentParser { // 初始化 func (this *UserAgentParser) init() { var maxCacheItems = 10_000 - var systemMemory = utils.SystemMemoryGB() + var systemMemory = memutils.SystemMemoryGB() if systemMemory >= 16 { maxCacheItems = 40_000 } else if systemMemory >= 8 { diff --git a/internal/ttlcache/cache.go b/internal/ttlcache/cache.go index 8d5e073..89cd909 100644 --- a/internal/ttlcache/cache.go +++ b/internal/ttlcache/cache.go @@ -1,8 +1,8 @@ package ttlcache import ( - "github.com/TeaOSLab/EdgeNode/internal/utils" "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" + memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "runtime" ) @@ -25,7 +25,7 @@ type Cache[T any] struct { } func NewBigCache[T any]() *Cache[T] { - var delta = utils.SystemMemoryGB() / 2 + var delta = memutils.SystemMemoryGB() / 2 if delta <= 0 { delta = 1 } @@ -36,7 +36,7 @@ func NewCache[T any](opt ...OptionInterface) *Cache[T] { var countPieces = 256 var maxItems = 1_000_000 - var totalMemory = utils.SystemMemoryGB() + var totalMemory = memutils.SystemMemoryGB() if totalMemory < 2 { // 我们限制内存过小的服务能够使用的数量 maxItems = 500_000 diff --git a/internal/ttlcache/cache_test.go b/internal/ttlcache/cache_test.go index 200d6d6..ed0d0d7 100644 --- a/internal/ttlcache/cache_test.go +++ b/internal/ttlcache/cache_test.go @@ -1,8 +1,8 @@ package ttlcache import ( - "github.com/TeaOSLab/EdgeNode/internal/utils" "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" + memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "github.com/TeaOSLab/EdgeNode/internal/utils/testutils" "github.com/iwind/TeaGo/assert" "github.com/iwind/TeaGo/rands" @@ -60,7 +60,7 @@ func TestCache_Memory(t *testing.T) { }) var count = 1_000_000 - if utils.SystemMemoryGB() > 4 { + if memutils.SystemMemoryGB() > 4 { count = 20_000_000 } for i := 0; i < count; i++ { diff --git a/internal/utils/byte_pool.go b/internal/utils/byte_pool.go index 400ce83..285cec0 100644 --- a/internal/utils/byte_pool.go +++ b/internal/utils/byte_pool.go @@ -4,10 +4,10 @@ import ( "sync" ) -var BytePool1k = NewBytePool(1024) -var BytePool4k = NewBytePool(4 * 1024) -var BytePool16k = NewBytePool(16 * 1024) -var BytePool32k = NewBytePool(32 * 1024) +var BytePool1k = NewBytePool(1 << 10) +var BytePool4k = NewBytePool(4 << 10) +var BytePool16k = NewBytePool(16 << 10) +var BytePool32k = NewBytePool(32 << 10) // BytePool pool for get byte slice type BytePool struct { diff --git a/internal/utils/cachehits/stat.go b/internal/utils/cachehits/stat.go index c15b06a..464ff8a 100644 --- a/internal/utils/cachehits/stat.go +++ b/internal/utils/cachehits/stat.go @@ -4,8 +4,8 @@ package cachehits import ( "github.com/TeaOSLab/EdgeNode/internal/goman" - "github.com/TeaOSLab/EdgeNode/internal/utils" "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" + memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "github.com/iwind/TeaGo/Tea" "sync" "sync/atomic" @@ -38,7 +38,7 @@ func NewStat(goodRatio uint64) *Stat { goodRatio = 5 } - var maxItems = utils.SystemMemoryGB() * 10_000 + var maxItems = memutils.SystemMemoryGB() * 10_000 if maxItems <= 0 { maxItems = 100_000 } diff --git a/internal/utils/counters/counter.go b/internal/utils/counters/counter.go index d91b109..47dcd41 100644 --- a/internal/utils/counters/counter.go +++ b/internal/utils/counters/counter.go @@ -3,8 +3,8 @@ package counters import ( - "github.com/TeaOSLab/EdgeNode/internal/utils" "github.com/TeaOSLab/EdgeNode/internal/utils/fasttime" + memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" syncutils "github.com/TeaOSLab/EdgeNode/internal/utils/sync" "github.com/cespare/xxhash" "sync" @@ -31,7 +31,7 @@ type Counter[T SupportedUIntType] struct { // NewCounter create new counter func NewCounter[T SupportedUIntType]() *Counter[T] { - var count = utils.SystemMemoryGB() * 8 + var count = memutils.SystemMemoryGB() * 8 if count < 8 { count = 8 } diff --git a/internal/utils/kvstore/store.go b/internal/utils/kvstore/store.go index e6f7f40..fb879f4 100644 --- a/internal/utils/kvstore/store.go +++ b/internal/utils/kvstore/store.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" "github.com/TeaOSLab/EdgeNode/internal/events" - "github.com/TeaOSLab/EdgeNode/internal/utils" + memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem" "github.com/cockroachdb/pebble" "github.com/iwind/TeaGo/Tea" "io" @@ -90,7 +90,7 @@ func (this *Store) Open() error { Logger: NewLogger(), } - var memoryMB = utils.SystemMemoryGB() * 1 + var memoryMB = memutils.SystemMemoryGB() * 1 if memoryMB > 256 { memoryMB = 256 } diff --git a/internal/utils/system.go b/internal/utils/mem/system.go similarity index 98% rename from internal/utils/system.go rename to internal/utils/mem/system.go index 9d69967..0ab450b 100644 --- a/internal/utils/system.go +++ b/internal/utils/mem/system.go @@ -1,6 +1,6 @@ // Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved. -package utils +package memutils import ( teaconst "github.com/TeaOSLab/EdgeNode/internal/const" diff --git a/internal/utils/system_1.19.go b/internal/utils/mem/system_1.19.go similarity index 95% rename from internal/utils/system_1.19.go rename to internal/utils/mem/system_1.19.go index f51b4b3..4feef56 100644 --- a/internal/utils/system_1.19.go +++ b/internal/utils/mem/system_1.19.go @@ -1,7 +1,7 @@ // Copyright 2023 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn . //go:build go1.19 -package utils +package memutils import ( "runtime/debug" diff --git a/internal/utils/system_before_1.19.go b/internal/utils/mem/system_before_1.19.go similarity index 91% rename from internal/utils/system_before_1.19.go rename to internal/utils/mem/system_before_1.19.go index dc8e394..bccb2dc 100644 --- a/internal/utils/system_before_1.19.go +++ b/internal/utils/mem/system_before_1.19.go @@ -1,7 +1,7 @@ // Copyright 2023 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn . //go:build !go1.19 -package utils +package memutils // 设置软内存最大值 func setMaxMemory(memoryGB int) { diff --git a/internal/utils/system_test.go b/internal/utils/system_test.go deleted file mode 100644 index 7d81878..0000000 --- a/internal/utils/system_test.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved. - -package utils - -import "testing" - -func TestSystemMemoryGB(t *testing.T) { - t.Log(SystemMemoryGB()) - t.Log(SystemMemoryGB()) - t.Log(SystemMemoryGB()) - t.Log(SystemMemoryBytes()) - t.Log(SystemMemoryBytes()) - t.Log(SystemMemoryBytes()>>30, "GB") -}