mirror of
https://github.com/Gouryella/drip.git
synced 2026-02-26 14:21:17 +00:00
- Removed the manual performance optimization configuration in main.go and replaced it with a new tuning module. - Add patterned GC tuning in server.go and tunnel_runner.go - Updated yamux configuration to a unified optimized configuration to improve throughput. - Implement connection pool preheating function to eliminate cold start delay. - Optimize session selection using a min-heap, reducing the time complexity from O(n) to O(log n). - Add a bufio.Reader pool and a buffer pool to reduce memory allocation. - Implement a fragmented lock manager to improve performance under high concurrency. - Adjust heartbeat and timeout configurations to suit high-throughput scenarios BREAKING CHANGE: Manual GC tuning configuration has been removed; automatic tuning mode is now used.
29 lines
445 B
Go
29 lines
445 B
Go
//go:build darwin
|
|
|
|
package tuning
|
|
|
|
import (
|
|
"syscall"
|
|
"unsafe"
|
|
)
|
|
|
|
func getSystemTotalMemory() uint64 {
|
|
mib := [2]int32{6, 24} // CTL_HW, HW_MEMSIZE
|
|
var value uint64
|
|
size := unsafe.Sizeof(value)
|
|
|
|
_, _, errno := syscall.Syscall6(
|
|
syscall.SYS___SYSCTL,
|
|
uintptr(unsafe.Pointer(&mib[0])),
|
|
2,
|
|
uintptr(unsafe.Pointer(&value)),
|
|
uintptr(unsafe.Pointer(&size)),
|
|
0,
|
|
0,
|
|
)
|
|
if errno != 0 {
|
|
return 1024 * 1024 * 1024
|
|
}
|
|
return value
|
|
}
|