Documentation
¶
Index ¶
- Constants
- Variables
- func DeleteMPool(mp *MPool)
- func GlobalCap() int64
- func InitCap(cap int64)
- func MPoolControl(tag string, cmd string) string
- func MakeSlice[T any](n int, mp *MPool) ([]T, error)
- func MakeSliceArgs[T any](mp *MPool, args ...T) ([]T, error)
- func MakeSliceWithCap[T any](n, cap int, mp *MPool) ([]T, error)
- func ReportMemUsage(tag string) string
- type MPool
- func (mp *MPool) Alloc(sz int) ([]byte, error)
- func (mp *MPool) Cap() int64
- func (mp *MPool) CurrNB() int64
- func (mp *MPool) Decrease(nb int64)
- func (mp *MPool) DisableDetailRecording()
- func (mp *MPool) EnableDetailRecording()
- func (mp *MPool) FixedPoolStats(i int) *MPoolStats
- func (mp *MPool) Free(bs []byte)
- func (mp *MPool) GetSels() []int64
- func (mp *MPool) Grow(old []byte, sz int) ([]byte, error)
- func (mp *MPool) Grow2(old []byte, old2 []byte, sz int) ([]byte, error)
- func (mp *MPool) Increase(nb int64) error
- func (mp *MPool) PutSels(sels []int64)
- func (mp *MPool) Realloc(old []byte, sz int) ([]byte, error)
- func (mp *MPool) Report() string
- func (mp *MPool) ReportJson() string
- func (mp *MPool) Stats() *MPoolStats
- type MPoolStats
Constants ¶
View Source
const ( NumFixedPool = 7 B = 1 KB = 1024 MB = 1024 * KB GB = 1024 * MB TB = 1024 * GB PB = 1024 * TB )
Variables ¶
View Source
var Large = []int{32 * 1024, 16 * 1024, 8 * 1024, 4 * 1024, 1024, 1024, 1024}
View Source
var Mid = []int{4096, 4096, 1024, 1024, 1024, 512, 512}
View Source
var NoFixed = []int{0, 0, 0, 0, 0, 0, 0}
Fixed pool configurations. Number of entries in fixed pool.
Small: esp, 0 is a valid value.
View Source
var PoolElemSize = []int{64, 128, 256, 512, 1024, 2048, 4096}
Pool emement size
View Source
var Small = []int{1024, 1024, 1024, 1024, 512, 0, 0}
View Source
var ZeroSlice = make([]byte, 4096)
Zeros, enough for largest pool element
Functions ¶
func DeleteMPool ¶
func DeleteMPool(mp *MPool)
func MPoolControl ¶
func MakeSliceArgs ¶
Types ¶
type MPool ¶
type MPool struct {
// contains filtered or unexported fields
}
The memory pool.
func MustNewZeroWithTag ¶
func (*MPool) DisableDetailRecording ¶
func (mp *MPool) DisableDetailRecording()
func (*MPool) EnableDetailRecording ¶
func (mp *MPool) EnableDetailRecording()
func (*MPool) FixedPoolStats ¶
func (mp *MPool) FixedPoolStats(i int) *MPoolStats
func (*MPool) Grow ¶
Grow is like Realloc but we try to be a little bit more aggressive on growing the slice.
func (*MPool) ReportJson ¶
func (*MPool) Stats ¶
func (mp *MPool) Stats() *MPoolStats
type MPoolStats ¶
type MPoolStats struct { NumAlloc atomic.Int64 // number of allocations NumFree atomic.Int64 // number of frees NumGoAlloc atomic.Int64 // number of go runtime alloc NumAllocBytes atomic.Int64 // number of bytes allocated NumFreeBytes atomic.Int64 // number of bytes freed NumCurrBytes atomic.Int64 // current number of bytes HighWaterMark atomic.Int64 // high water mark }
Stats
func GlobalStats ¶
func GlobalStats() *MPoolStats
func (*MPoolStats) RecordAlloc ¶
func (s *MPoolStats) RecordAlloc(tag string, sz int64) int64
Update alloc stats, return curr bytes
func (*MPoolStats) RecordFree ¶
func (s *MPoolStats) RecordFree(tag string, sz int64) int64
Update free stats, return curr bytes.
func (*MPoolStats) RecordManyFrees ¶
func (s *MPoolStats) RecordManyFrees(tag string, nfree, sz int64) int64
func (*MPoolStats) Report ¶
func (s *MPoolStats) Report(tab string) string
func (*MPoolStats) ReportJson ¶
func (s *MPoolStats) ReportJson() string
Click to show internal directories.
Click to hide internal directories.