Documentation
¶
Index ¶
- Constants
- Variables
- func AppendFixed[T any](mp *MPool, p *PtrLen, v T) error
- func AppendFixedList[T comparable](mp *MPool, p *PtrLen, vs []T, distinct bool) error
- func DeleteMPool(mp *MPool)
- func DisableDebugPoisonOnFree()
- func DisableProfiling()
- func EnableDebugPoisonOnFree()
- func EnableProfiling()
- func FreeSlice[T any](mp *MPool, bs []T)
- func GlobalCap() int64
- func InitCap(cap int64)
- func MPoolControl(tag string, cmd string) string
- func MakeSlice[T any](n int, mp *MPool, offHeap bool) ([]T, error)
- func MakeSliceArgs[T any](mp *MPool, offHeap bool, args ...T) ([]T, error)
- func ProfileTrackedCount() int
- func ProfilingEnabled() bool
- func PtrLenFindFixed[T comparable](p *PtrLen, v T) int
- func PtrLenFromSlice[T any](p *PtrLen, slice []T)
- func PtrLenToSlice[T any](p *PtrLen) []T
- func ReportMemUsage(tag string) string
- type MPool
- func (mp *MPool) Alloc(sz int, offHeap bool) ([]byte, error)
- func (mp *MPool) Cap() int64
- func (mp *MPool) CurrNB() int64
- func (mp *MPool) DisableDetailRecording()
- func (mp *MPool) EnableDetailRecording()
- func (mp *MPool) Free(bs []byte)
- func (mp *MPool) Grow(old []byte, sz int, offHeap bool) ([]byte, error)
- func (mp *MPool) Grow2(old []byte, old2 []byte, sz int, offHeap bool) ([]byte, error)
- func (mp *MPool) ReallocZero(old []byte, sz int, offHeap bool) ([]byte, error)
- func (mp *MPool) ReportJson() string
- func (mp *MPool) Stats() *MPoolStats
- type MPoolStats
- func (s *MPoolStats) Init()
- func (s *MPoolStats) RecordAlloc(tag string, sz int64) int64
- func (s *MPoolStats) RecordFree(tag string, sz int64) int64
- func (s *MPoolStats) RecordManyFrees(tag string, nfree, sz int64) int64
- func (s *MPoolStats) RecordXPoolFree(detail string, nb int64)
- func (s *MPoolStats) Report(tab string) string
- func (s *MPoolStats) ReportJson() string
- type PtrLen
- func (p *PtrLen) AppendBytes(mp *MPool, bs []byte) error
- func (p *PtrLen) AppendBytesList(mp *MPool, other *PtrLen, distinct bool) error
- func (p *PtrLen) AppendRawBytes(mp *MPool, bs []byte) error
- func (p *PtrLen) FindBytes(bs []byte) int
- func (p *PtrLen) Free(mp *MPool)
- func (p *PtrLen) FromByteSlice(bs []byte)
- func (p *PtrLen) Len() int
- func (p *PtrLen) NumberOfVarlenElements() int
- func (p *PtrLen) Ptr() unsafe.Pointer
- func (p *PtrLen) Replace(mp *MPool, bs []byte) error
- func (p *PtrLen) ToByteSlice() []byte
Constants ¶
View Source
const ( B = 1 KB = 1024 MB = 1024 * KB GB = 1024 * MB TB = 1024 * GB PB = 1024 * TB )
View Source
const ( NoFixed = 1 << iota NoLock )
View Source
const PtrLenSize = int(unsafe.Sizeof(PtrLen{}))
Variables ¶
View Source
var CapLimit = math.MaxInt32 // 2GB - 1
Functions ¶
func AppendFixedList ¶
func AppendFixedList[T comparable](mp *MPool, p *PtrLen, vs []T, distinct bool) error
func DeleteMPool ¶
func DeleteMPool(mp *MPool)
func DisableDebugPoisonOnFree ¶
func DisableDebugPoisonOnFree()
func DisableProfiling ¶
func DisableProfiling()
DisableProfiling turns off per-allocation stack tracking.
func EnableDebugPoisonOnFree ¶
func EnableDebugPoisonOnFree()
func EnableProfiling ¶
func EnableProfiling()
EnableProfiling turns on per-allocation stack tracking for off-heap mpool allocations. Tracked allocations appear in the malloc profiler output.
func MPoolControl ¶
func ProfileTrackedCount ¶
func ProfileTrackedCount() int
ProfileTrackedCount returns the total number of tracked pointers across all shards.
func ProfilingEnabled ¶
func ProfilingEnabled() bool
ProfilingEnabled reports whether mpool profiling is active.
func PtrLenFindFixed ¶
func PtrLenFindFixed[T comparable](p *PtrLen, v T) int
func PtrLenFromSlice ¶
func PtrLenToSlice ¶
Types ¶
type MPool ¶
type MPool struct {
// contains filtered or unexported fields
}
The memory pool.
func MustNewNoFixed ¶ added in v0.8.0
func MustNewNoFixed() *MPool
func MustNewNoLock ¶
func MustNewZero ¶
func MustNewZero() *MPool
func MustNewZeroNoFixed ¶ added in v0.8.0
func MustNewZeroNoFixed() *MPool
func (*MPool) DisableDetailRecording ¶
func (mp *MPool) DisableDetailRecording()
func (*MPool) EnableDetailRecording ¶
func (mp *MPool) EnableDetailRecording()
func (*MPool) ReallocZero ¶
ReallocZero is like Realloc, but it clears the memory.
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
NumAllocBytes atomic.Int64 // number of bytes allocated
NumFreeBytes atomic.Int64 // number of bytes freed
NumCurrBytes atomic.Int64 // current number of bytes
NumCrossPoolFree atomic.Int64 // number of cross pool free
HighWaterMark atomic.Int64 // high water mark
// contains filtered or unexported fields
}
Mo's extremely simple memory pool. Stats
func GlobalStats ¶
func GlobalStats() *MPoolStats
func (*MPoolStats) Init ¶
func (s *MPoolStats) Init()
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) RecordXPoolFree ¶
func (s *MPoolStats) RecordXPoolFree(detail string, nb int64)
func (*MPoolStats) Report ¶
func (s *MPoolStats) Report(tab string) string
func (*MPoolStats) ReportJson ¶
func (s *MPoolStats) ReportJson() string
type PtrLen ¶
type PtrLen struct {
// contains filtered or unexported fields
}
PtrLen is a known size slice.
func (*PtrLen) AppendBytesList ¶
func (*PtrLen) FromByteSlice ¶
func (*PtrLen) NumberOfVarlenElements ¶
func (*PtrLen) ToByteSlice ¶
Click to show internal directories.
Click to hide internal directories.