Documentation ¶
Overview ¶
Package memsys provides memory management and slab/SGL allocation with io.Reader and io.Writer interfaces on top of scatter-gather lists of reusable buffers.
- Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
Package memsys provides memory management and slab/SGL allocation with io.Reader and io.Writer interfaces on top of scatter-gather lists of reusable buffers.
- Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
Package memsys provides memory management and slab/SGL allocation with io.Reader and io.Writer interfaces on top of scatter-gather lists of reusable buffers.
- Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
Package memsys provides memory management and slab/SGL allocation with io.Reader and io.Writer interfaces on top of scatter-gather lists of reusable buffers.
- Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
Package memsys provides memory management and slab/SGL allocation with io.Reader and io.Writer interfaces on top of scatter-gather lists of reusable buffers.
- Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
Package memsys provides memory management and slab/SGL allocation with io.Reader and io.Writer interfaces on top of scatter-gather lists of reusable buffers.
- Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
Package memsys provides memory management and slab/SGL allocation with io.Reader and io.Writer interfaces on top of scatter-gather lists of reusable buffers.
- Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
Index ¶
- Constants
- func Init(gmmName, smmName string, config *cmn.Config)
- type FreeSpec
- type MMSA
- func (r *MMSA) Alloc() (buf []byte, slab *Slab)
- func (r *MMSA) AllocSize(size int64) (buf []byte, slab *Slab)
- func (r *MMSA) Append(buf []byte, bytes string) (nbuf []byte)
- func (r *MMSA) Free(buf []byte)
- func (r *MMSA) FreeSpec(spec FreeSpec)
- func (r *MMSA) GetSlab(bufSize int64) (s *Slab, err error)
- func (r *MMSA) GetStats() (stats *Stats)
- func (r *MMSA) Init(maxUse int64) (err error)
- func (r *MMSA) NewSGL(immediateSize int64, sbufSize ...int64) *SGL
- func (r *MMSA) Pressure(mems ...*sys.MemStat) (pressure int)
- func (r *MMSA) RegWithHK()
- func (r *MMSA) SelectMemAndSlab(size int64) (mmsa *MMSA, slab *Slab)
- func (r *MMSA) Str(mem *sys.MemStat) string
- func (r *MMSA) String() string
- func (r *MMSA) Terminate(unregHK bool)
- type Reader
- type SGL
- func (z *SGL) Bytes() (b []byte)
- func (z *SGL) Cap() int64
- func (*SGL) Close() error
- func (z *SGL) ErrDumpAt()
- func (z *SGL) Free()
- func (z *SGL) IsNil() bool
- func (z *SGL) Len() int64
- func (z *SGL) NextLine(lin []byte, advanceRoff bool) (lout []byte, err error)
- func (z *SGL) Open() (cos.ReadOpenCloser, error)
- func (z *SGL) Read(b []byte) (n int, err error)
- func (z *SGL) ReadAll() (b []byte)
- func (z *SGL) ReadByte() (byte, error)
- func (z *SGL) ReadFrom(r io.Reader) (n int64, _ error)
- func (z *SGL) Reset()
- func (z *SGL) Rewind()
- func (z *SGL) Roff() int64
- func (z *SGL) Size() int64
- func (z *SGL) Slab() *Slab
- func (z *SGL) UnreadByte() error
- func (z *SGL) Write(p []byte) (n int, err error)
- func (z *SGL) WriteAt(p []byte, off int64) (n int, err error)
- func (z *SGL) WriteByte(c byte) error
- func (z *SGL) WriteTo(dst io.Writer) (n int64, _ error)
- func (z *SGL) WriteTo2(dst io.Writer) error
- type Slab
- type Stats
Constants ¶
const ( PageSize = cos.KiB * 4 DefaultBufSize = PageSize * 8 DefaultBuf2Size = PageSize * 16 DefaultSmallBufSize = cos.KiB )
const ( MaxPageSlabSize = 128 * cos.KiB PageSlabIncStep = PageSize NumPageSlabs = MaxPageSlabSize / PageSlabIncStep // = 32 )
page slabs: pagesize increments up to MaxPageSlabSize
const ( MaxSmallSlabSize = PageSize SmallSlabIncStep = 128 NumSmallSlabs = MaxSmallSlabSize / SmallSlabIncStep // = 32 )
small slabs: 128 byte increments up to MaxSmallSlabSize
const ( PressureLow = iota PressureModerate PressureHigh PressureExtreme OOM )
const NumStats = NumPageSlabs // NOTE: must be >= NumSmallSlabs
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FreeSpec ¶
type FreeSpec struct { IdleDuration time.Duration // reduce only the slabs that are idling for at least as much time MinSize int64 // minimum freed size that'd warrant calling GC (default = sizetoGC) Totally bool // true: free all slabs regardless of their idle-ness and size ToOS bool // GC and then return the memory to the operating system }
type MMSA ¶
type MMSA struct { // public MinFree uint64 // memory that must be available at all times TimeIval time.Duration // interval of time to watch for low memory and make steps MinPctTotal int // same, via percentage of total MinPctFree int // ditto, as % of free at init time Name string // contains filtered or unexported fields }
func (*MMSA) GetSlab ¶
gets Slab for a given fixed buffer size that must be within expected range of sizes - the range supported by _this_ MMSA (compare w/ SelectMemAndSlab())
func (*MMSA) NewSGL ¶
allocate SGL
- immediateSize: known size, OR minimum expected size, OR size to preallocate immediateSize == 0 translates as DefaultBufSize - for page MMSA, and DefaultSmallBufSize - for small-size MMSA
- sbufSize: slab buffer size (optional)
func (*MMSA) Pressure ¶
returns an estimate for the current memory pressure expressed as enumerated values also, tracks swapping stateful vars
func (*MMSA) SelectMemAndSlab ¶
Given a known, expected or minimum size to allocate, selects MMSA (page or small, if initialized) and its Slab
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
uses the underlying SGL to implement io.ReadWriteCloser + io.Seeker
type SGL ¶
type SGL struct {
// contains filtered or unexported fields
}
implements io.ReadWriteCloser + Reset
func (*SGL) Bytes ¶
NOTE assert and use with caution: heap allocation (via ReadAll) is intended for tests (and only tests)
func (*SGL) ReadAll ¶
ReadAll is a strictly _convenience_ method as it performs heap allocation. Still, it's an optimized alternative to the generic cos.ReadAll which normally returns err == nil (and not io.EOF) upon successful reading until EOF. ReadAll always returns err == nil.
func (*SGL) ReadFrom ¶
usage via io.Copy(z, source), whereby `z` reads from the `source` until EOF see also: WriteTo