Documentation ¶
Index ¶
- Constants
- Variables
- func HeatForecasterList() []string
- func HeatForecasterRegister(name string, creator HeatForecasterCreator)
- func MustParseBytes(s string) int64
- func ParseBytes(s string) (int64, error)
- func PidWatcherList() []string
- func PidWatcherRegister(name string, creator PidWatcherCreator)
- func PidfdCloseSyscall(pidfd int) error
- func PidfdOpenSyscall(pid int, flags uint) (int, error)
- func PolicyList() []string
- func PolicyRegister(name string, creator PolicyCreator)
- func ProcessMadviseSyscall(pidfd int, ranges []AddrRange, advise int, flags uint) (int, syscall.Errno, error)
- func RoutineList() []string
- func RoutineRegister(name string, creator RoutineCreator)
- func SetLogDebug(debug bool)
- func SetLogPrefix(prefix string)
- func SetLogger(l *stdlog.Logger)
- func TrackerList() []string
- func TrackerRegister(name string, creator TrackerCreator)
- type AddrData
- type AddrDatas
- type AddrRange
- type AddrRanges
- func (ar *AddrRanges) AddrRangesMatching(pageAttributes uint64) (*AddrRanges, error)
- func (ar *AddrRanges) Filter(accept func(ar AddrRange) bool) *AddrRanges
- func (ar *AddrRanges) Flatten() []*AddrRanges
- func (ar *AddrRanges) Intersection(intRanges []AddrRange)
- func (ar *AddrRanges) PageCount() uint64
- func (ar *AddrRanges) PagesMatching(pageAttributes uint64) (*Pages, error)
- func (ar *AddrRanges) Pid() int
- func (ar *AddrRanges) ProcessMadvise(advise int) error
- func (ar *AddrRanges) Ranges() []AddrRange
- func (ar *AddrRanges) SplitLength(maxLength uint64) *AddrRanges
- func (ar *AddrRanges) String() string
- func (ar *AddrRanges) SwapOut() error
- type Cmd
- type CommandStatus
- type DamonUserspaceInterface
- type FilteringPidListener
- type HeatForecaster
- type HeatForecasterChain
- func (hf *HeatForecasterChain) Dump(args []string) string
- func (hf *HeatForecasterChain) Forecast(heats *Heats) (*Heats, error)
- func (hf *HeatForecasterChain) GetConfigJSON() string
- func (hf *HeatForecasterChain) SetConfig(config *HeatForecasterChainConfig) error
- func (hf *HeatForecasterChain) SetConfigJSON(configJSON string) error
- type HeatForecasterChainConfig
- type HeatForecasterConfig
- type HeatForecasterCreator
- type HeatForecasterStdio
- func (hf *HeatForecasterStdio) Dump(args []string) string
- func (hf *HeatForecasterStdio) Forecast(heats *Heats) (*Heats, error)
- func (hf *HeatForecasterStdio) GetConfigJSON() string
- func (hf *HeatForecasterStdio) SetConfig(config *HeatForecasterStdioConfig) error
- func (hf *HeatForecasterStdio) SetConfigJSON(configJSON string) error
- type HeatForecasterStdioConfig
- type HeatForecasterStub
- type HeatForecasterTrace
- func (hf *HeatForecasterTrace) Dump(args []string) string
- func (hf *HeatForecasterTrace) Forecast(heats *Heats) (*Heats, error)
- func (hf *HeatForecasterTrace) GetConfigJSON() string
- func (hf *HeatForecasterTrace) SetConfig(config *HeatForecasterTraceConfig) error
- func (hf *HeatForecasterTrace) SetConfigJSON(configJSON string) error
- type HeatForecasterTraceConfig
- type HeatRange
- type HeatRanges
- type Heatmap
- func (h *Heatmap) Dump() string
- func (h *Heatmap) ForEachRange(pid int, handleRange func(*HeatRange) int)
- func (h *Heatmap) HeatClass(hr *HeatRange) int
- func (h *Heatmap) HeatRangeAt(pid int, addr uint64) *HeatRange
- func (h *Heatmap) Pids() []int
- func (h *Heatmap) SetConfig(config *HeatmapConfig) error
- func (h *Heatmap) SetConfigJSON(configJSON string) error
- func (h *Heatmap) Sorted(pid int, cmp func(*HeatRange, *HeatRange) bool) HeatRanges
- func (h *Heatmap) UpdateFromCounters(tcs *TrackerCounters, timestamp int64)
- type HeatmapConfig
- type Heats
- type Logger
- type Mover
- func (m *Mover) AddTask(task *MoverTask)
- func (m *Mover) Continue()
- func (m *Mover) GetConfigJSON() string
- func (m *Mover) Pause()
- func (m *Mover) RemoveTask(taskID int)
- func (m *Mover) SetConfig(config *MoverConfig) error
- func (m *Mover) SetConfigJSON(configJSON string) error
- func (m *Mover) Start() error
- func (m *Mover) Stop()
- func (m *Mover) TaskCount() int
- func (m *Mover) Tasks() []*MoverTask
- func (m *Mover) Wait(thss ...MoverTaskHandlerStatus) <-chan MoverTaskHandlerStatus
- type MoverConfig
- type MoverTask
- type MoverTaskHandlerStatus
- type Node
- type Page
- type Pages
- func (pp *Pages) AddrRanges(count int) *AddrRanges
- func (pp *Pages) InAddrRanges(addrRanges ...AddrRange) *Pages
- func (pp *Pages) MoveTo(node Node, count int) (int, error)
- func (pp *Pages) NodePageCount() map[Node]uint
- func (pp *Pages) Nodes() []Node
- func (pp *Pages) NotOnNode(node Node) *Pages
- func (pp *Pages) Offset(offset int) *Pages
- func (pp *Pages) OnNode(node Node) *Pages
- func (pp *Pages) Pages() []Page
- func (pp *Pages) Pid() int
- func (pp *Pages) SwapOut(count int) error
- type PidFilterConfig
- type PidListener
- type PidWatcher
- type PidWatcherCgroups
- func (w *PidWatcherCgroups) Dump([]string) string
- func (w *PidWatcherCgroups) GetConfigJSON() string
- func (w *PidWatcherCgroups) Poll() error
- func (w *PidWatcherCgroups) SetConfigJSON(configJSON string) error
- func (w *PidWatcherCgroups) SetPidListener(l PidListener)
- func (w *PidWatcherCgroups) Start() error
- func (w *PidWatcherCgroups) Stop()
- type PidWatcherCgroupsConfig
- type PidWatcherConfig
- type PidWatcherCreator
- type PidWatcherFilter
- func (w *PidWatcherFilter) Dump([]string) string
- func (w *PidWatcherFilter) GetConfigJSON() string
- func (w *PidWatcherFilter) Poll() error
- func (w *PidWatcherFilter) SetConfigJSON(configJSON string) error
- func (w *PidWatcherFilter) SetPidListener(l PidListener)
- func (w *PidWatcherFilter) Start() error
- func (w *PidWatcherFilter) Stop()
- type PidWatcherFilterConfig
- type PidWatcherPidlist
- func (w *PidWatcherPidlist) Dump([]string) string
- func (w *PidWatcherPidlist) GetConfigJSON() string
- func (w *PidWatcherPidlist) Poll() error
- func (w *PidWatcherPidlist) SetConfigJSON(configJSON string) error
- func (w *PidWatcherPidlist) SetPidListener(l PidListener)
- func (w *PidWatcherPidlist) Start() error
- func (w *PidWatcherPidlist) Stop()
- type PidWatcherPidlistConfig
- type PidWatcherProc
- func (w *PidWatcherProc) Dump([]string) string
- func (w *PidWatcherProc) GetConfigJSON() string
- func (w *PidWatcherProc) Poll() error
- func (w *PidWatcherProc) SetConfigJSON(configJSON string) error
- func (w *PidWatcherProc) SetPidListener(l PidListener)
- func (w *PidWatcherProc) Start() error
- func (w *PidWatcherProc) Stop()
- type PidWatcherProcConfig
- type PidWatcherStub
- func (w *PidWatcherStub) Dump([]string) string
- func (w *PidWatcherStub) GetConfigJSON() string
- func (w *PidWatcherStub) Poll() error
- func (w *PidWatcherStub) SetConfigJSON(configJSON string) error
- func (w *PidWatcherStub) SetPidListener(PidListener)
- func (w *PidWatcherStub) Start() error
- func (w *PidWatcherStub) Stop()
- type Policy
- type PolicyAge
- func (p *PolicyAge) Dump(args []string) string
- func (p *PolicyAge) GetConfigJSON() string
- func (p *PolicyAge) Mover() *Mover
- func (p *PolicyAge) PidWatcher() PidWatcher
- func (p *PolicyAge) SetConfig(config *PolicyAgeConfig) error
- func (p *PolicyAge) SetConfigJSON(configJSON string) error
- func (p *PolicyAge) Start() error
- func (p *PolicyAge) Stop()
- func (p *PolicyAge) Tracker() Tracker
- type PolicyAgeConfig
- type PolicyConfig
- type PolicyCreator
- type PolicyHeat
- func (p *PolicyHeat) Dump(args []string) string
- func (p *PolicyHeat) GetConfigJSON() string
- func (p *PolicyHeat) Mover() *Mover
- func (p *PolicyHeat) PidWatcher() PidWatcher
- func (p *PolicyHeat) SetConfig(config *PolicyHeatConfig) error
- func (p *PolicyHeat) SetConfigJSON(configJSON string) error
- func (p *PolicyHeat) Start() error
- func (p *PolicyHeat) Stop()
- func (p *PolicyHeat) Tracker() Tracker
- type PolicyHeatConfig
- type PolicyRatio
- func (p *PolicyRatio) Dump(args []string) string
- func (p *PolicyRatio) GetConfigJSON() string
- func (p *PolicyRatio) Mover() *Mover
- func (p *PolicyRatio) PidWatcher() PidWatcher
- func (p *PolicyRatio) SetConfig(config *PolicyRatioConfig) error
- func (p *PolicyRatio) SetConfigJSON(configJSON string) error
- func (p *PolicyRatio) Start() error
- func (p *PolicyRatio) Stop()
- func (p *PolicyRatio) Tracker() Tracker
- type PolicyRatioConfig
- type PolicyStub
- func (p *PolicyStub) Dump(args []string) string
- func (p *PolicyStub) GetConfigJSON() string
- func (p *PolicyStub) Mover() *Mover
- func (p *PolicyStub) PidWatcher() PidWatcher
- func (p *PolicyStub) SetConfigJSON(configJSON string) error
- func (p *PolicyStub) Start() error
- func (p *PolicyStub) Stop()
- func (p *PolicyStub) Tracker() Tracker
- type ProcKpageflagsFile
- type ProcMemFile
- type ProcPageIdleBitmapFile
- func (f *ProcPageIdleBitmapFile) Close()
- func (f *ProcPageIdleBitmapFile) GetIdle(pfn uint64) (bool, error)
- func (f *ProcPageIdleBitmapFile) ReadBits(pfn uint64) (uint64, error)
- func (f *ProcPageIdleBitmapFile) SetIdle(pfn uint64) error
- func (f *ProcPageIdleBitmapFile) SetIdleAll(pfn uint64) error
- func (f *ProcPageIdleBitmapFile) SetReadahead(chunks int)
- func (f *ProcPageIdleBitmapFile) WriteBits(pfn uint64, bits uint64) error
- type ProcPagemapFile
- type Process
- type Prompt
- func (p *Prompt) AddPids(pids []int)
- func (p *Prompt) Interact()
- func (p *Prompt) RemovePids(pids []int)
- func (p *Prompt) RunCmdSlice(cmdSlice []string) CommandStatus
- func (p *Prompt) RunCmdString(cmdString string) CommandStatus
- func (p *Prompt) SetEcho(newEcho bool)
- func (p *Prompt) SetInput(reader *bufio.Reader)
- func (p *Prompt) SetPolicy(policy Policy)
- func (p *Prompt) SetRoutines(routines []Routine)
- type RangeHeat
- type Routine
- type RoutineConfig
- type RoutineCreator
- type RoutineStatActions
- func (r *RoutineStatActions) Dump(args []string) string
- func (r *RoutineStatActions) GetConfigJSON() string
- func (r *RoutineStatActions) SetConfigJSON(configJSON string) error
- func (r *RoutineStatActions) SetPolicy(policy Policy) error
- func (r *RoutineStatActions) Start() error
- func (r *RoutineStatActions) Stop()
- type RoutineStatActionsConfig
- type RoutineStub
- type Stats
- func (s *Stats) Dump(args []string) string
- func (s *Stats) LastMove(pid int) *StatsMoved
- func (s *Stats) LastMoveWithError(pid int) *StatsMoved
- func (s *Stats) MadvisedPageCount(pid int, advise int) uint64
- func (s *Stats) Store(entry interface{})
- func (s *Stats) String() string
- func (s *Stats) Summarize(format string, tables ...string) string
- type StatsHeartbeat
- type StatsMadvised
- type StatsMoved
- type StatsPageScan
- type StatsPidMadvised
- type StatsPidMoved
- type StatsPidScanned
- type StatsPulse
- type Tracker
- type TrackerConfig
- type TrackerCounter
- type TrackerCounters
- func (tcs *TrackerCounters) Flattened(cut func(tc0 TrackerCounter, ar *AddrRange) TrackerCounter, ...) *TrackerCounters
- func (tcs *TrackerCounters) RangeHeat() []*RangeHeat
- func (tcs *TrackerCounters) RegionsMerged() *TrackerCounters
- func (tcs *TrackerCounters) SortByAccesses()
- func (tcs *TrackerCounters) SortByAddr()
- func (tcs *TrackerCounters) String() string
- type TrackerCreator
- type TrackerDamon
- func (t *TrackerDamon) AddPids(pids []int)
- func (t *TrackerDamon) Dump(args []string) string
- func (t *TrackerDamon) GetConfigJSON() string
- func (t *TrackerDamon) GetCounters() *TrackerCounters
- func (t *TrackerDamon) RemovePids(pids []int)
- func (t *TrackerDamon) ResetCounters()
- func (t *TrackerDamon) SetConfigJSON(configJSON string) error
- func (t *TrackerDamon) Start() error
- func (t *TrackerDamon) Stop()
- type TrackerDamonConfig
- type TrackerFinder
- func (t *TrackerFinder) AddPids(pids []int)
- func (t *TrackerFinder) Dump(args []string) string
- func (t *TrackerFinder) GetConfigJSON() string
- func (t *TrackerFinder) GetCounters() *TrackerCounters
- func (t *TrackerFinder) RemovePids(pids []int)
- func (t *TrackerFinder) ResetCounters()
- func (t *TrackerFinder) SetConfigJSON(configJSON string) error
- func (t *TrackerFinder) Start() error
- func (t *TrackerFinder) Stop()
- type TrackerFinderConfig
- type TrackerIdlePage
- func (t *TrackerIdlePage) AddPids(pids []int)
- func (t *TrackerIdlePage) Dump(args []string) string
- func (t *TrackerIdlePage) GetConfigJSON() string
- func (t *TrackerIdlePage) GetCounters() *TrackerCounters
- func (t *TrackerIdlePage) RemovePids(pids []int)
- func (t *TrackerIdlePage) ResetCounters()
- func (t *TrackerIdlePage) SetConfigJSON(configJSON string) error
- func (t *TrackerIdlePage) Start() error
- func (t *TrackerIdlePage) Stop()
- type TrackerIdlePageConfig
- type TrackerMulti
- func (t *TrackerMulti) AddPids(pids []int)
- func (t *TrackerMulti) Dump(args []string) string
- func (t *TrackerMulti) GetConfigJSON() string
- func (t *TrackerMulti) GetCounters() *TrackerCounters
- func (t *TrackerMulti) RemovePids(pids []int)
- func (t *TrackerMulti) ResetCounters()
- func (t *TrackerMulti) SetConfigJSON(configJSON string) error
- func (t *TrackerMulti) Start() error
- func (t *TrackerMulti) Stop()
- type TrackerMultiConfig
- type TrackerSoftDirty
- func (t *TrackerSoftDirty) AddPids(pids []int)
- func (t *TrackerSoftDirty) Dump(args []string) string
- func (t *TrackerSoftDirty) GetConfigJSON() string
- func (t *TrackerSoftDirty) GetCounters() *TrackerCounters
- func (t *TrackerSoftDirty) RemovePids(pids []int)
- func (t *TrackerSoftDirty) ResetCounters()
- func (t *TrackerSoftDirty) SetConfigJSON(configJSON string) error
- func (t *TrackerSoftDirty) Start() error
- func (t *TrackerSoftDirty) Stop()
- type TrackerSoftDirtyConfig
- type TrackerStub
- func (t *TrackerStub) AddPids(pids []int)
- func (t *TrackerStub) Dump([]string) string
- func (t *TrackerStub) GetConfigJSON() string
- func (t *TrackerStub) GetCounters() *TrackerCounters
- func (t *TrackerStub) RemovePids(pids []int)
- func (t *TrackerStub) ResetCounters()
- func (t *TrackerStub) SetConfigJSON(configJSON string) error
- func (t *TrackerStub) Start() error
- func (t *TrackerStub) Stop()
Constants ¶
const ( // Requirements for pagemap bits PMPresentSet uint64 = 1 << iota PMPresentCleared PMExclusiveSet PMExclusiveCleared PMFileSet PMFileCleared PMSwapSet PMSwapCleared PMDirtySet PMDirtyCleared // addressRangeAttributes RangeIsAnonymous = 1 << iota RangeIsHeap // move_pages syscall flags // MPOL_MF_MOVE - only move pages exclusive to this process. MPOL_MF_MOVE = 1 << 1 )
const ( // NodeUndefined is used when moving memory among numa nodes. NodeUndefined = Node(1 << 31) // NodeSwap is used when swapping in and out. NodeSwap = Node(-1) )
const ( // /proc/pid/pagemap bits // from fs/proc/task_mmu.c PMB_SOFT_DIRTY = 55 PMB_MMAP_EXCLUSIVE = 56 PMB_UFFD_WP = 57 PMB_FILE = 61 PMB_SWAP = 62 PMB_PRESENT = 63 // corresponding bitmasks PM_PFN = (uint64(0x1) << 55) - 1 PM_SOFT_DIRTY = uint64(0x1) << PMB_SOFT_DIRTY PM_MMAP_EXCLUSIVE = uint64(0x1) << PMB_MMAP_EXCLUSIVE PM_UFFD_WP = uint64(0x1) << PMB_UFFD_WP PM_FILE = uint64(0x1) << PMB_FILE PM_SWAP = uint64(0x1) << PMB_SWAP PM_PRESENT = uint64(0x1) << PMB_PRESENT // /proc/kpageflags bits // from include/uapi/linux/kernel-page-flags.h KPFB_LOCKED = 0 KPFB_ERROR = 1 KPFB_REFERENCED = 2 KPFB_UPTODATE = 3 KPFB_DIRTY = 4 KPFB_LRU = 5 KPFB_ACTIVE = 6 KPFB_SLAB = 7 KPFB_WRITEBACK = 8 KPFB_RECLAIM = 9 KPFB_BUDDY = 10 KPFB_MMAP = 11 KPFB_ANON = 12 KPFB_SWAPCACHE = 13 KPFB_SWAPBACKED = 14 KPFB_COMPOUND_HEAD = 15 KPFB_COMPOUND_TAIL = 16 KPFB_HUGE = 17 KPFB_UNEVICTABLE = 18 KPFB_HWPOISON = 19 KPFB_NOPAGE = 20 KPFB_KSM = 21 KPFB_THP = 22 KPFB_OFFLINE = 23 KPFB_ZERO_PAGE = 24 KPFB_IDLE = 25 KPFB_PGTABLE = 26 KPF_LOCKED = uint64(0x1) << 0 KPF_ERROR = uint64(0x1) << 1 KPF_REFERENCED = uint64(0x1) << 2 KPF_UPTODATE = uint64(0x1) << 3 KPF_DIRTY = uint64(0x1) << 4 KPF_LRU = uint64(0x1) << 5 KPF_ACTIVE = uint64(0x1) << 6 KPF_SLAB = uint64(0x1) << 7 KPF_WRITEBACK = uint64(0x1) << 8 KPF_RECLAIM = uint64(0x1) << 9 KPF_BUDDY = uint64(0x1) << 10 KPF_MMAP = uint64(0x1) << 11 KPF_ANON = uint64(0x1) << 12 KPF_SWAPCACHE = uint64(0x1) << 13 KPF_SWAPBACKED = uint64(0x1) << 14 KPF_COMPOUND_HEAD = uint64(0x1) << 15 KPF_COMPOUND_TAIL = uint64(0x1) << 16 KPF_HUGE = uint64(0x1) << 17 KPF_UNEVICTABLE = uint64(0x1) << 18 KPF_HWPOISON = uint64(0x1) << 19 KPF_NOPAGE = uint64(0x1) << 20 KPF_KSM = uint64(0x1) << 21 KPF_THP = uint64(0x1) << 22 KPF_OFFLINE = uint64(0x1) << 23 KPF_ZERO_PAGE = uint64(0x1) << 24 KPF_IDLE = uint64(0x1) << 25 KPF_PGTABLE = uint64(0x1) << 26 )
Variables ¶
var HeatmapConfigDefaults string = `{"HeatMax":1.0,"HeatRetention":0.9513,"HeatClasses":10}`
HeatmapConfigDefaults defines default configuration settings as JSON.
Functions ¶
func HeatForecasterList ¶
func HeatForecasterList() []string
HeatForecasterList returns a sorted list of registered heat forecaster names.
func HeatForecasterRegister ¶
func HeatForecasterRegister(name string, creator HeatForecasterCreator)
HeatForecasterRegister registers a new heat forecaster with its creator function.
func MustParseBytes ¶
MustParseBytes is a helper function that wraps ParseBytes and panics if an error occurs. It is useful in situations where the input string is expected to be valid.
func ParseBytes ¶
ParseBytes parses a string representation of bytes and returns the equivalent number of bytes. It supports units like k, M, G, T (kilo, mega, giga, tera) and expects the input string to be in the format of "<numeric part><unit>" (e.g., "10M" for 10 megabytes).
func PidWatcherList ¶
func PidWatcherList() []string
PidWatcherList returns a sorted list of available PID watcher names.
func PidWatcherRegister ¶
func PidWatcherRegister(name string, creator PidWatcherCreator)
PidWatcherRegister registers a new PID watcher with a given name and creator function.
func PidfdCloseSyscall ¶
PidfdCloseSyscall is a wrapper around the close system call for a process file descriptor (pidfd). It closes the specified process file descriptor.
func PidfdOpenSyscall ¶
PidfdOpenSyscall is a wrapper around the pidfd_open system call. It opens a process file descriptor (pidfd) for the specified process ID with the given flags.
func PolicyList ¶
func PolicyList() []string
PolicyList returns a sorted list of available policy names.
func PolicyRegister ¶
func PolicyRegister(name string, creator PolicyCreator)
PolicyRegister registers a new policy with its creator function.
func ProcessMadviseSyscall ¶
func ProcessMadviseSyscall(pidfd int, ranges []AddrRange, advise int, flags uint) (int, syscall.Errno, error)
ProcessMadviseSyscall is a wrapper around the process_madvise system call. It advises the kernel about memory usage patterns of the specified process address ranges.
func RoutineList ¶
func RoutineList() []string
RoutineList returns a sorted list of registered routine names.
func RoutineRegister ¶
func RoutineRegister(name string, creator RoutineCreator)
RoutineRegister registers a routine with its name and creator function.
func SetLogDebug ¶
func SetLogDebug(debug bool)
SetLogDebug controls whether debug messages are logged.
func TrackerList ¶
func TrackerList() []string
TrackerList returns a list of registered tracker names.
func TrackerRegister ¶
func TrackerRegister(name string, creator TrackerCreator)
TrackerRegister registers a new Tracker with a given name and creator function.
Types ¶
type AddrData ¶
type AddrData struct { AddrRange // contains filtered or unexported fields }
AddrData is a data structure for storing arbitrary data on memory addresses.
func NewAddrData ¶
NewAddrData returns new AddrData instance that associates data to an address range.
type AddrDatas ¶
type AddrDatas struct {
// contains filtered or unexported fields
}
AddrDatas slice is sorted by non-overlapping address ranges.
func NewAddrDatas ¶
func NewAddrDatas() *AddrDatas
NewAddrDatas returns a data structure that contains many address ranges with different data.
func (*AddrDatas) Data ¶
Data fetches data associated with an address. data, ok := ads.Data(addr) behaves similarly to value, ok := map[key]
func (*AddrDatas) ForEach ¶
ForEach iterates over addrdatas.
- handler(*AddrRange, data) is called for every entry in the ascending start address order. Handler return values: 0 (continue): ForEach continues iteration from the next element -1 (break): ForEach returns immediately.
type AddrRange ¶
type AddrRange struct {
// contains filtered or unexported fields
}
AddrRange represents a memory address range with a start address and length.
func NewAddrRange ¶
NewAddrRange creates a new AddrRange with given startAddr and stopAddr.
func NewAddrRangeFromString ¶
NewAddrRangeFromString converts a string representation to an AddrRange.
func (*AddrRange) Equals ¶
Equals returns true if the given AddrRange is the same as the current AddrRange.
type AddrRanges ¶
type AddrRanges struct {
// contains filtered or unexported fields
}
AddrRanges is a struct that holds a process ID and a collection of memory address ranges.
func NewAddrRanges ¶
func NewAddrRanges(pid int, arParams ...AddrRange) *AddrRanges
NewAddrRanges creates an AddrRanges instance with a given process ID and address ranges.
func (*AddrRanges) AddrRangesMatching ¶
func (ar *AddrRanges) AddrRangesMatching(pageAttributes uint64) (*AddrRanges, error)
AddrRangesMatching returns address ranges where every page has required attributes.
func (*AddrRanges) Filter ¶
func (ar *AddrRanges) Filter(accept func(ar AddrRange) bool) *AddrRanges
Filter returns a new AddrRanges instance with only the address ranges that meet a specified condition.
func (*AddrRanges) Flatten ¶
func (ar *AddrRanges) Flatten() []*AddrRanges
Flatten returns AddrRanges where each item includes only one address range.
func (*AddrRanges) Intersection ¶
func (ar *AddrRanges) Intersection(intRanges []AddrRange)
Intersection modifies AddrRanges by keeping only the overlapping parts with another set of address ranges.
func (*AddrRanges) PageCount ¶
func (ar *AddrRanges) PageCount() uint64
PageCount calculates the total number of pages in the address ranges.
func (*AddrRanges) PagesMatching ¶
func (ar *AddrRanges) PagesMatching(pageAttributes uint64) (*Pages, error)
PagesMatching returns pages with pagetable attributes.
func (*AddrRanges) Pid ¶
func (ar *AddrRanges) Pid() int
Pid returns the process ID from AddrRanges.
func (*AddrRanges) ProcessMadvise ¶
func (ar *AddrRanges) ProcessMadvise(advise int) error
ProcessMadvise performs madvise operation on the given address ranges.
func (*AddrRanges) Ranges ¶
func (ar *AddrRanges) Ranges() []AddrRange
Ranges returns all the AddrRanges from AddrRanges.
func (*AddrRanges) SplitLength ¶
func (ar *AddrRanges) SplitLength(maxLength uint64) *AddrRanges
SplitLength divides address ranges in AddrRanges to fit a maximum length.
func (*AddrRanges) String ¶
func (ar *AddrRanges) String() string
String returns a string representation of AddrRanges.
func (*AddrRanges) SwapOut ¶
func (ar *AddrRanges) SwapOut() error
SwapOut performs memory management operation on the given address ranges using madvise.
type Cmd ¶
type Cmd struct { Run func([]string) CommandStatus // contains filtered or unexported fields }
Cmd represents a command with a description and a function to execute.
type CommandStatus ¶
type CommandStatus int
CommandStatus represents the status of a command execution.
type DamonUserspaceInterface ¶
type DamonUserspaceInterface interface { // ApplyAttrs (re)configures DAMON with TrackerDamonConfig parameters. ApplyAttrs(config *TrackerDamonConfig) error // ApplyTargetIds replaces PIDs to be tracked in the DAMON interface. ApplyTargetIds(pids []int) error // ApplyState switches DAMON state on/off. ApplyState(value string) error // AggregatedPid returns the PID of the tracked workload on an aggregation line. AggregatedPid(kdamondPid int, targetID uint64) int KdamondPids() []int }
DamonUserspaceInterface represents the interface for DAMON interactions.
type FilteringPidListener ¶
type FilteringPidListener struct {
// contains filtered or unexported fields
}
FilteringPidListener is a listener for PidWatcherFilter that filters and forwards PID changes.
func (*FilteringPidListener) AddPids ¶
func (f *FilteringPidListener) AddPids(pids []int)
AddPids is a method of FilteringPidListener that filters and forwards new PIDs.
func (*FilteringPidListener) RemovePids ¶
func (f *FilteringPidListener) RemovePids(pids []int)
RemovePids is a method of FilteringPidListener that filters and forwards disappeared PIDs.
type HeatForecaster ¶
type HeatForecaster interface { SetConfigJSON(string) error // Set new configuration. GetConfigJSON() string // Get current configuration. Forecast(*Heats) (*Heats, error) Dump(args []string) string }
HeatForecaster is an interface that defines the methods for a heat forecaster.
func NewHeatForecaster ¶
func NewHeatForecaster(name string) (HeatForecaster, error)
NewHeatForecaster creates a new instance of HeatForecaster based on the provided name. It returns an error if the specified heat forecaster name is invalid.
func NewHeatForecasterChain ¶
func NewHeatForecasterChain() (HeatForecaster, error)
NewHeatForecasterChain creates a new instance of HeatForecasterChain.
func NewHeatForecasterStdio ¶
func NewHeatForecasterStdio() (HeatForecaster, error)
NewHeatForecasterStdio creates a new instance of HeatForecasterStdio.
func NewHeatForecasterStub ¶
func NewHeatForecasterStub() (HeatForecaster, error)
NewHeatForecasterStub creates a new instance of HeatForecasterStub with default configuration.
func NewHeatForecasterTrace ¶
func NewHeatForecasterTrace() (HeatForecaster, error)
NewHeatForecasterTrace creates a new instance of HeatForecasterTrace.
type HeatForecasterChain ¶
type HeatForecasterChain struct {
// contains filtered or unexported fields
}
HeatForecasterChain represents a chain of heat forecasters.
func (*HeatForecasterChain) Dump ¶
func (hf *HeatForecasterChain) Dump(args []string) string
Dump returns a string representation of the HeatForecasterChain for debugging purposes.
func (*HeatForecasterChain) Forecast ¶
func (hf *HeatForecasterChain) Forecast(heats *Heats) (*Heats, error)
Forecast performs heat forecasting using the chain of forecasters.
func (*HeatForecasterChain) GetConfigJSON ¶
func (hf *HeatForecasterChain) GetConfigJSON() string
GetConfigJSON returns the JSON representation of the HeatForecasterChain's configuration.
func (*HeatForecasterChain) SetConfig ¶
func (hf *HeatForecasterChain) SetConfig(config *HeatForecasterChainConfig) error
SetConfig sets the configuration for the HeatForecasterChain.
func (*HeatForecasterChain) SetConfigJSON ¶
func (hf *HeatForecasterChain) SetConfigJSON(configJSON string) error
SetConfigJSON sets the configuration for the HeatForecasterChain from a JSON string.
type HeatForecasterChainConfig ¶
type HeatForecasterChainConfig struct {
Forecasters []HeatForecasterConfig
}
HeatForecasterChainConfig represents the configuration for the HeatForecasterChain.
type HeatForecasterConfig ¶
HeatForecasterConfig represents the configuration for a heat forecaster.
type HeatForecasterCreator ¶
type HeatForecasterCreator func() (HeatForecaster, error)
HeatForecasterCreator is a function type that creates a new instance of HeatForecaster.
type HeatForecasterStdio ¶
type HeatForecasterStdio struct {
// contains filtered or unexported fields
}
HeatForecasterStdio is a heat forecaster that communicates with an external process through standard I/O.
func (*HeatForecasterStdio) Dump ¶
func (hf *HeatForecasterStdio) Dump(args []string) string
Dump returns a string representation of the HeatForecasterStdio for debugging purposes.
func (*HeatForecasterStdio) Forecast ¶
func (hf *HeatForecasterStdio) Forecast(heats *Heats) (*Heats, error)
Forecast sends the current heats to the external process and receives forecasted heats in return.
func (*HeatForecasterStdio) GetConfigJSON ¶
func (hf *HeatForecasterStdio) GetConfigJSON() string
GetConfigJSON returns the JSON representation of the HeatForecasterStdio's configuration.
func (*HeatForecasterStdio) SetConfig ¶
func (hf *HeatForecasterStdio) SetConfig(config *HeatForecasterStdioConfig) error
SetConfig sets the configuration for HeatForecasterStdio.
func (*HeatForecasterStdio) SetConfigJSON ¶
func (hf *HeatForecasterStdio) SetConfigJSON(configJSON string) error
SetConfigJSON sets the configuration for HeatForecasterStdio from a JSON string.
type HeatForecasterStdioConfig ¶
HeatForecasterStdioConfig represents the configuration for HeatForecasterStdio, containing the command to execute, stderr configuration, and retry count.
type HeatForecasterStub ¶
type HeatForecasterStub struct { }
HeatForecasterStub defines empty struct for the scenarios that there is no heat forecaster.
func (*HeatForecasterStub) Dump ¶
func (hf *HeatForecasterStub) Dump(args []string) string
Dump is a method of HeatForecasterStub, returns "<HeatForecasterStub>".
func (*HeatForecasterStub) Forecast ¶
func (hf *HeatForecasterStub) Forecast(*Heats) (*Heats, error)
Forecast is a method of HeatForecasterStub, returns nil for the heats.
func (*HeatForecasterStub) GetConfigJSON ¶
func (hf *HeatForecasterStub) GetConfigJSON() string
GetConfigJSON is a method of HeatForecasterStub, returns "".
func (*HeatForecasterStub) SetConfigJSON ¶
func (hf *HeatForecasterStub) SetConfigJSON(configJSON string) error
SetConfigJSON is a method of HeatForecasterStub, returns nil.
type HeatForecasterTrace ¶
type HeatForecasterTrace struct {
// contains filtered or unexported fields
}
HeatForecasterTrace is a heat forecaster that writes heat data to a trace file.
func (*HeatForecasterTrace) Dump ¶
func (hf *HeatForecasterTrace) Dump(args []string) string
Dump returns a string representation of the HeatForecasterTrace for debugging purposes.
func (*HeatForecasterTrace) Forecast ¶
func (hf *HeatForecasterTrace) Forecast(heats *Heats) (*Heats, error)
Forecast writes heat data to a trace file based on the configured settings.
func (*HeatForecasterTrace) GetConfigJSON ¶
func (hf *HeatForecasterTrace) GetConfigJSON() string
GetConfigJSON returns the JSON representation of the HeatForecasterTrace's configuration.
func (*HeatForecasterTrace) SetConfig ¶
func (hf *HeatForecasterTrace) SetConfig(config *HeatForecasterTraceConfig) error
SetConfig sets the configuration for the HeatForecasterTrace.
func (*HeatForecasterTrace) SetConfigJSON ¶
func (hf *HeatForecasterTrace) SetConfigJSON(configJSON string) error
SetConfigJSON sets the configuration for the HeatForecasterTrace from a JSON string.
type HeatForecasterTraceConfig ¶
HeatForecasterTraceConfig represents the configuration for the HeatForecasterTrace.
type HeatRange ¶
type HeatRange struct {
// contains filtered or unexported fields
}
HeatRange stores memory addresses, length, heat information and timestamps.
func (*HeatRange) MarshalJSON ¶
MarshalJSON converts HeatRange to JSON.
func (*HeatRange) UnmarshalJSON ¶
UnmarshalJSON converts JSON to HeatRange.
type HeatRanges ¶
type HeatRanges []*HeatRange
HeatRanges is a slice of HeatRange pointers.
func (*HeatRanges) Overlapping ¶
func (hrs *HeatRanges) Overlapping(hr0 *HeatRange) *HeatRanges
Overlapping returns a subset of heatRanges that overlap with a given HeatRange.
type Heatmap ¶
type Heatmap struct {
// contains filtered or unexported fields
}
Heatmap stores heatmap configuration and heat information for the pid.
func NewCounterHeatmap ¶
func NewCounterHeatmap() *Heatmap
NewCounterHeatmap creates a new Heatmap instance.
func (*Heatmap) ForEachRange ¶
ForEachRange iterates over heatranges of a pid in ascending address order.
- handleRange(*HeatRange) is called for every range. 0 (continue): ForEachRange continues iteration from the next range -1 (break): ForEachRange returns immediately.
func (*Heatmap) HeatRangeAt ¶
HeatRangeAt returns a HeatRange at address.
func (*Heatmap) SetConfig ¶
func (h *Heatmap) SetConfig(config *HeatmapConfig) error
SetConfig sets the heatmap configuration.
func (*Heatmap) SetConfigJSON ¶
SetConfigJSON sets the heatmap configuration from a JSON string.
func (*Heatmap) UpdateFromCounters ¶
func (h *Heatmap) UpdateFromCounters(tcs *TrackerCounters, timestamp int64)
UpdateFromCounters updates the heatmap based on TrackerCounters data.
type HeatmapConfig ¶
type HeatmapConfig struct { // HeatMax is the maximum heat of a range HeatMax float64 // HeatRetention is the portion of the remaining heat in a region // after one second of complete inactivity. // - 1.0: heat never cools down // - 0.0: all heat cools down immediately // - If you want that 5 % of the heat remains after 60 seconds of inactivity, // HeatRetention = 0.05 ** (1.0/60) = 0.9513 HeatRetention float64 // HeatClasses is the number of discrete heat classes. The default is 10, // which means that address ranges are classified: // heat class 0: heat [HeatMax*0/10, HeatMax*1/10) // heat class 1: heat [HeatMax*1/10, HeatMax*2/10) // ... // heat class 9: heat [HeatMax*9/10, HeatMax*10/10] HeatClasses int }
HeatmapConfig represents the configuration for a heatmap.
type Logger ¶
type Logger interface { Debugf(format string, v ...interface{}) Infof(format string, v ...interface{}) Warnf(format string, v ...interface{}) Errorf(format string, v ...interface{}) Panicf(format string, v ...interface{}) Fatalf(format string, v ...interface{}) }
Logger interface defines methods for logging at different severity levels.
func NewLoggerWrapper ¶
NewLoggerWrapper creates a new Logger instance that wraps the provided standard logger.
type Mover ¶
type Mover struct {
// contains filtered or unexported fields
}
Mover represents the memory mover, which manages and executes memory movement tasks.
func (*Mover) GetConfigJSON ¶
GetConfigJSON gets the current configuration of the Mover as a JSON string.
func (*Mover) RemoveTask ¶
RemoveTask removes a memory movement task from the Mover.
func (*Mover) SetConfig ¶
func (m *Mover) SetConfig(config *MoverConfig) error
SetConfig sets the configuration of the Mover.
func (*Mover) SetConfigJSON ¶
SetConfigJSON sets the configuration of the Mover from a JSON string.
func (*Mover) Wait ¶
func (m *Mover) Wait(thss ...MoverTaskHandlerStatus) <-chan MoverTaskHandlerStatus
Wait returns a channel from which mover's task handler status change can be read. Only listed statuses are reported through the channel, and the channel gets closed immediately after reporting the first status change.
type MoverConfig ¶
type MoverConfig struct { // IntervalMs is the minimum interval between subsequent moves // in milliseconds IntervalMs int // Bandwidth is the maximum memory bandwidth in MB/s Bandwidth int }
MoverConfig represents the configuration for memory movement tasks.
type MoverTask ¶
type MoverTask struct {
// contains filtered or unexported fields
}
MoverTask represents a single memory movement task.
func NewMoverTask ¶
NewMoverTask creates a new memory movement task.
type MoverTaskHandlerStatus ¶
type MoverTaskHandlerStatus int
MoverTaskHandlerStatus represents the status of the task handler.
func (MoverTaskHandlerStatus) String ¶
func (ths MoverTaskHandlerStatus) String() string
String returns a string representation of the MoverTaskHandlerStatus
type Page ¶
type Page struct {
// contains filtered or unexported fields
}
Page represents an individual memory page with an address.
type Pages ¶
type Pages struct {
// contains filtered or unexported fields
}
Pages represents a collection of memory pages associated with a process.
func (*Pages) AddrRanges ¶
func (pp *Pages) AddrRanges(count int) *AddrRanges
AddrRanges returns up to count Pages as AddrRanges. If count is -1, all pages are returned.
func (*Pages) InAddrRanges ¶
InAddrRanges returns process pages that are in any of given address ranges.
func (*Pages) NodePageCount ¶
NodePageCount returns map: numanode -> number of pages on the node.
type PidFilterConfig ¶
type PidFilterConfig struct { ProcExeRegexp string MinVmSizeKb int MinVmRSSKb int MinPrivateDirtyKb int And []*PidFilterConfig Or []*PidFilterConfig Not *PidFilterConfig // contains filtered or unexported fields }
PidFilterConfig holds the configuration for a PidWatcherFilter filter.
type PidListener ¶
PidListener is an interface for handling PID events.
type PidWatcher ¶
type PidWatcher interface { SetConfigJSON(string) error // Set new configuration. GetConfigJSON() string // Get current configuration. SetPidListener(PidListener) Poll() error Start() error Stop() Dump([]string) string }
PidWatcher is an interface for managing PID watchers.
func NewPidWatcher ¶
func NewPidWatcher(name string) (PidWatcher, error)
NewPidWatcher creates a new PID watcher instance based on the provided name.
func NewPidWatcherCgroups ¶
func NewPidWatcherCgroups() (PidWatcher, error)
NewPidWatcherCgroups creates a new instance of the Cgroups-based PID watcher.
func NewPidWatcherFilter ¶
func NewPidWatcherFilter() (PidWatcher, error)
NewPidWatcherFilter creates a new instance of PidWatcherFilter.
func NewPidWatcherPidlist ¶
func NewPidWatcherPidlist() (PidWatcher, error)
NewPidWatcherPidlist creates a new instance of PidWatcherPidlist.
func NewPidWatcherProc ¶
func NewPidWatcherProc() (PidWatcher, error)
NewPidWatcherProc creates a new instance of PidWatcherProc with default configuration.
func NewPidWatcherStub ¶
func NewPidWatcherStub() (PidWatcher, error)
NewPidWatcherStub creates a new instance of PidWatcherStub with default configuration.
type PidWatcherCgroups ¶
type PidWatcherCgroups struct {
// contains filtered or unexported fields
}
PidWatcherCgroups is a type implementing the PidWatcher interface for Cgroups-based PID watching.
func (*PidWatcherCgroups) Dump ¶
func (w *PidWatcherCgroups) Dump([]string) string
Dump generates a string representation of the Cgroups-based PID watcher for debugging purposes.
func (*PidWatcherCgroups) GetConfigJSON ¶
func (w *PidWatcherCgroups) GetConfigJSON() string
GetConfigJSON gets the configuration for the Cgroups-based PID watcher in JSON format.
func (*PidWatcherCgroups) Poll ¶
func (w *PidWatcherCgroups) Poll() error
Poll initiates a single polling operation for PID changes.
func (*PidWatcherCgroups) SetConfigJSON ¶
func (w *PidWatcherCgroups) SetConfigJSON(configJSON string) error
SetConfigJSON sets the configuration for the Cgroups-based PID watcher.
func (*PidWatcherCgroups) SetPidListener ¶
func (w *PidWatcherCgroups) SetPidListener(l PidListener)
SetPidListener sets the listener for PID changes.
func (*PidWatcherCgroups) Start ¶
func (w *PidWatcherCgroups) Start() error
Start starts the PID watcher with periodic polling.
type PidWatcherCgroupsConfig ¶
type PidWatcherCgroupsConfig struct { IntervalMs int Cgroups []string // list of absolute cgroup directory paths }
PidWatcherCgroupsConfig holds the configuration for the Cgroups-based PID watcher.
type PidWatcherConfig ¶
PidWatcherConfig represents the configuration for a PID watcher.
type PidWatcherCreator ¶
type PidWatcherCreator func() (PidWatcher, error)
PidWatcherCreator is a function type for creating a new PID watcher instance.
type PidWatcherFilter ¶
type PidWatcherFilter struct {
// contains filtered or unexported fields
}
PidWatcherFilter is an implementation of PidWatcher that filters PIDs based on configured rules.
func (*PidWatcherFilter) Dump ¶
func (w *PidWatcherFilter) Dump([]string) string
Dump is a method of PidWatcherFilter that returns a string representation of the current instance.
func (*PidWatcherFilter) GetConfigJSON ¶
func (w *PidWatcherFilter) GetConfigJSON() string
GetConfigJSON is a method of PidWatcherFilter that returns the current configuration as a JSON string.
func (*PidWatcherFilter) Poll ¶
func (w *PidWatcherFilter) Poll() error
Poll is a method of PidWatcherFilter that triggers the polling process of the source PidWatcher.
func (*PidWatcherFilter) SetConfigJSON ¶
func (w *PidWatcherFilter) SetConfigJSON(configJSON string) error
SetConfigJSON is a method of PidWatcherFilter that sets the configuration from JSON. It creates a new source PidWatcher based on the provided configuration.
func (*PidWatcherFilter) SetPidListener ¶
func (w *PidWatcherFilter) SetPidListener(l PidListener)
SetPidListener is a method of PidWatcherFilter that sets the PidListener.
func (*PidWatcherFilter) Start ¶
func (w *PidWatcherFilter) Start() error
Start is a method of PidWatcherFilter that starts the source PidWatcher.
func (*PidWatcherFilter) Stop ¶
func (w *PidWatcherFilter) Stop()
Stop is a method of PidWatcherFilter that stops the source PidWatcher.
type PidWatcherFilterConfig ¶
type PidWatcherFilterConfig struct { Source PidWatcherConfig Filters []*PidFilterConfig }
PidWatcherFilterConfig holds the configuration for PidWatcherFilter.
type PidWatcherPidlist ¶
type PidWatcherPidlist struct {
// contains filtered or unexported fields
}
PidWatcherPidlist is an implementation of PidWatcher that watches a predefined list of PIDs.
func (*PidWatcherPidlist) Dump ¶
func (w *PidWatcherPidlist) Dump([]string) string
Dump is a method of PidWatcherPidlist that returns a string representation of the current instance.
func (*PidWatcherPidlist) GetConfigJSON ¶
func (w *PidWatcherPidlist) GetConfigJSON() string
GetConfigJSON is a method of PidWatcherPidlist that returns the current configuration as a JSON string.
func (*PidWatcherPidlist) Poll ¶
func (w *PidWatcherPidlist) Poll() error
Poll is a method of PidWatcherPidlist that simulates polling for PIDs. It adds the configured PIDs to the PidListener, if available.
func (*PidWatcherPidlist) SetConfigJSON ¶
func (w *PidWatcherPidlist) SetConfigJSON(configJSON string) error
SetConfigJSON is a method of PidWatcherPidlist that sets the configuration from JSON. It unmarshals the input JSON string into the PidWatcherPidlistConfig structure.
func (*PidWatcherPidlist) SetPidListener ¶
func (w *PidWatcherPidlist) SetPidListener(l PidListener)
SetPidListener is a method of PidWatcherPidlist that sets the PidListener.
func (*PidWatcherPidlist) Start ¶
func (w *PidWatcherPidlist) Start() error
Start is a method of PidWatcherPidlist that simulates starting the PidWatcher. It adds the configured PIDs to the PidListener, if available.
type PidWatcherPidlistConfig ¶
type PidWatcherPidlistConfig struct {
Pids []int // list of absolute cgroup directory paths
}
PidWatcherPidlistConfig holds the configuration for PidWatcherPidlist.
type PidWatcherProc ¶
type PidWatcherProc struct {
// contains filtered or unexported fields
}
PidWatcherProc is an implementation of PidWatcher that watches for new processes under /proc.
func (*PidWatcherProc) Dump ¶
func (w *PidWatcherProc) Dump([]string) string
Dump is a method of PidWatcherProc that returns a string representation of the current instance.
func (*PidWatcherProc) GetConfigJSON ¶
func (w *PidWatcherProc) GetConfigJSON() string
GetConfigJSON is a method of PidWatcherProc that returns the current configuration as a JSON string.
func (*PidWatcherProc) Poll ¶
func (w *PidWatcherProc) Poll() error
Poll is a method of PidWatcherProc that triggers the polling process. It locks the mutex, starts the polling loop, and unlocks the mutex.
func (*PidWatcherProc) SetConfigJSON ¶
func (w *PidWatcherProc) SetConfigJSON(configJSON string) error
SetConfigJSON is a method of PidWatcherProc that sets the configuration from JSON. It unmarshals the input JSON string into the PidWatcherProcConfig structure.
func (*PidWatcherProc) SetPidListener ¶
func (w *PidWatcherProc) SetPidListener(l PidListener)
SetPidListener is a method of PidWatcherProc that sets the PidListener.
func (*PidWatcherProc) Start ¶
func (w *PidWatcherProc) Start() error
Start is a method of PidWatcherProc that starts the polling process in a goroutine. It locks the mutex, starts the polling loop in a separate goroutine, and unlocks the mutex.
func (*PidWatcherProc) Stop ¶
func (w *PidWatcherProc) Stop()
Stop is a method of PidWatcherProc that stops the polling process by setting the stop flag.
type PidWatcherProcConfig ¶
type PidWatcherProcConfig struct {
IntervalMs int // poll interval
}
PidWatcherProcConfig holds the configuration for PidWatcherProc.
type PidWatcherStub ¶
type PidWatcherStub struct { }
PidWatcherStub defines empty struct for the scenarios without PidWatcher configured.
func (*PidWatcherStub) Dump ¶
func (w *PidWatcherStub) Dump([]string) string
Dump is a method of PidWatcherStub, returns "".
func (*PidWatcherStub) GetConfigJSON ¶
func (w *PidWatcherStub) GetConfigJSON() string
GetConfigJSON is a method of PidWatcherStub, returns "".
func (*PidWatcherStub) Poll ¶
func (w *PidWatcherStub) Poll() error
Poll is a method of PidWatcherStub that doing nothing here.
func (*PidWatcherStub) SetConfigJSON ¶
func (w *PidWatcherStub) SetConfigJSON(configJSON string) error
SetConfigJSON is a method of PidWatcherStub, returns nil.
func (*PidWatcherStub) SetPidListener ¶
func (w *PidWatcherStub) SetPidListener(PidListener)
SetPidListener is a method of PidWatcherStub that doing nothing here.
func (*PidWatcherStub) Start ¶
func (w *PidWatcherStub) Start() error
Start is a method of PidWatcherStub, returns nil.
func (*PidWatcherStub) Stop ¶
func (w *PidWatcherStub) Stop()
Stop is a method of PidWatcherStub that doing nothing here.
type Policy ¶
type Policy interface { SetConfigJSON(string) error // Set new configuration. GetConfigJSON() string // Get current configuration. Start() error Stop() // PidWatcher, Mover and Tracker are mostly for debugging in interactive prompt... PidWatcher() PidWatcher Mover() *Mover Tracker() Tracker Dump(args []string) string }
Policy interface defines the methods that a memory management policy should implement.
func NewPolicyAge ¶
NewPolicyAge creates a new instance of the age policy.
func NewPolicyHeat ¶
NewPolicyHeat creates a new instance of PolicyHeat.
func NewPolicyRatio ¶
NewPolicyRatio creates a new instance of PolicyRatio.
func NewPolicyStub ¶
NewPolicyStub creates a new instance of PolicyStub with default configuration.
type PolicyAge ¶
type PolicyAge struct {
// contains filtered or unexported fields
}
PolicyAge is a type implementing the Policy interface for the age policy.
func (*PolicyAge) Dump ¶
Dump generates a string representation of the policy based on specified arguments.
func (*PolicyAge) GetConfigJSON ¶
GetConfigJSON gets the policy configuration in JSON format.
func (*PolicyAge) PidWatcher ¶
func (p *PolicyAge) PidWatcher() PidWatcher
PidWatcher returns the associated PidWatcher.
func (*PolicyAge) SetConfig ¶
func (p *PolicyAge) SetConfig(config *PolicyAgeConfig) error
SetConfig checks the validity of the configuration and sets the policy configuration.
func (*PolicyAge) SetConfigJSON ¶
SetConfigJSON sets the policy configuration based on JSON input.
type PolicyAgeConfig ¶
type PolicyAgeConfig struct { PidWatcher PidWatcherConfig Tracker TrackerConfig Mover MoverConfig // Cgroups is a list of cgroup paths in the filesystem. The // policy manages processes in listed cgroups and recursively // in their subgroups. // DEPRECATED, use PidWatcher "cgroup" instead. Cgroups []string // Pids is a list of process id's to be tracked. // DEPRECATED, use PidWatcher "pid" instead. Pids []int // IntervalMs is the length of the period in milliseconds in // which new ages are calculated based on gathered tracker // values, and page move and swap tasks are triggered. IntervalMs int // SwapOutMs is the number of milliseconds. If a tracker // has not seen activity in a set of pages during this time, // the pages will be swapped out. SwapOutMs int // IdleDurationMs is the number of milliseconds. If a tracker // has not seen activity in a set of pages during this time, // the pages are considered idle and good to move to IdleNumas. IdleDurationMs int // IdleNumas is the list of NUMA nodes where idle pages should // be located or moved to. IdleNumas []int // ActiveDurationMs is the number of milliseconds. If a // tracker has seen a set of pages being active on every check // during this time, the pages are considered active and good // to move to ActiveNumas. ActiveDurationMs int // ActiveNumas is the list of NUMA nodes where active pages // should be located or moved to. ActiveNumas []int }
PolicyAgeConfig holds the configuration for the age policy.
type PolicyConfig ¶
PolicyConfig represents the configuration for a policy.
type PolicyCreator ¶
PolicyCreator is a function that creates an instance of a Policy.
type PolicyHeat ¶
type PolicyHeat struct {
// contains filtered or unexported fields
}
PolicyHeat represents all the elements involved in the heat policy, including the configuration, pid watchers, heat map information, pid and the address ranges, mover, heat forecaster information and so on.
func (*PolicyHeat) Dump ¶
func (p *PolicyHeat) Dump(args []string) string
Dump provides information about the policy based on the specified arguments.
func (*PolicyHeat) GetConfigJSON ¶
func (p *PolicyHeat) GetConfigJSON() string
GetConfigJSON gets the JSON representation of the current configuration.
func (*PolicyHeat) Mover ¶
func (p *PolicyHeat) Mover() *Mover
Mover returns the Mover associated with the policy.
func (*PolicyHeat) PidWatcher ¶
func (p *PolicyHeat) PidWatcher() PidWatcher
PidWatcher returns the PidWatcher associated with the policy.
func (*PolicyHeat) SetConfig ¶
func (p *PolicyHeat) SetConfig(config *PolicyHeatConfig) error
SetConfig sets the configuration of the heat policy.
func (*PolicyHeat) SetConfigJSON ¶
func (p *PolicyHeat) SetConfigJSON(configJSON string) error
SetConfigJSON sets the configuration of the heat policy using JSON input.
func (*PolicyHeat) Start ¶
func (p *PolicyHeat) Start() error
Start starts the policy, including the main loop for periodic actions.
func (*PolicyHeat) Stop ¶
func (p *PolicyHeat) Stop()
Stop stops the policy and associated components.
func (*PolicyHeat) Tracker ¶
func (p *PolicyHeat) Tracker() Tracker
Tracker returns the Tracker associated with the policy.
type PolicyHeatConfig ¶
type PolicyHeatConfig struct { PidWatcher PidWatcherConfig Tracker TrackerConfig Heatmap HeatmapConfig Forecaster *HeatForecasterConfig Mover MoverConfig // Cgroups is a list of cgroup paths in the filesystem. The // policy manages processes in listed cgroups and recursively // in their subgroups. // DEPRECATED, use PidWatcher "cgroup" instead. Cgroups []string // Pids is a list of process id's to be tracked. // DEPRECATED, use PidWatcher "pid" instead. Pids []int // IntervalMs is the length of the period in milliseconds // in which new heats are calculated for pages based on gathered // tracker values, and page move tasks are triggered. IntervalMs int // HeatNumas maps heat class values into NUMA node lists where // pages of each heat class should be located. If a heat class // is missing, the NUMA node is "don't care". HeatNumas map[int][]int // NumaSize sets the amount of memory that is usable on each // NUMA node. If a node is missing from the map, it's memory // use is not limited. The size is expressed in syntax: // <NUM>(k|M|G|%). If all the memory in a heat class exceeds // NumaSize of the NUMA nodes of that heat, the remaining // pages are moved to NUMA nodes of lower heats if there is // free capacity. NumaSize map[int]string }
PolicyHeatConfig represents the configuration for the heat policy.
type PolicyRatio ¶
type PolicyRatio struct {
// contains filtered or unexported fields
}
PolicyRatio is the main struct for the ratio policy, implementing the policy interface. the configuration, pid watchers, mover, pid and the addressc ranges, and so on, are included.
func (*PolicyRatio) Dump ¶
func (p *PolicyRatio) Dump(args []string) string
Dump is not implemented for ratio policy yet.
func (*PolicyRatio) GetConfigJSON ¶
func (p *PolicyRatio) GetConfigJSON() string
GetConfigJSON gets the policy configuration.
func (*PolicyRatio) Mover ¶
func (p *PolicyRatio) Mover() *Mover
Mover returns mover for ratio policy.
func (*PolicyRatio) PidWatcher ¶
func (p *PolicyRatio) PidWatcher() PidWatcher
PidWatcher returns pidwatcher for ratio policy.
func (*PolicyRatio) SetConfig ¶
func (p *PolicyRatio) SetConfig(config *PolicyRatioConfig) error
SetConfig checks the validity of the configuration and sets the policy configuration.
func (*PolicyRatio) SetConfigJSON ¶
func (p *PolicyRatio) SetConfigJSON(configJSON string) error
SetConfigJSON sets the policy configuration.
func (*PolicyRatio) Start ¶
func (p *PolicyRatio) Start() error
Start starts ratio policy with given policy configuration.
func (*PolicyRatio) Tracker ¶
func (p *PolicyRatio) Tracker() Tracker
Tracker returns tracker for ratio policy.
type PolicyRatioConfig ¶
type PolicyRatioConfig struct { PidWatcher PidWatcherConfig // mandantory Tracker TrackerConfig // optional Mover MoverConfig // optional IntervalMs int // optional Ratio float32 // mandantory RatioTargets []int // optional Cgroups []string // DEPRECATED, use PidWatcher "cgroup" instead Pids []int // DEPRECATED, use PidWatcher "pid" instead }
PolicyRatioConfig represents the configuration for ratio policy, among which Ratio means the the portion of the least recently used memory, which should be swapped out when RatioTargets is missing or [-1], or moved to the target nodes according to RatioTargets
type PolicyStub ¶
type PolicyStub struct { }
PolicyStub defines empty struct for the scenarios without policy configured.
func (*PolicyStub) Dump ¶
func (p *PolicyStub) Dump(args []string) string
Dump is a method of PolicyStub, returns "".
func (*PolicyStub) GetConfigJSON ¶
func (p *PolicyStub) GetConfigJSON() string
GetConfigJSON is a method of PolicyStub, returns "".
func (*PolicyStub) Mover ¶
func (p *PolicyStub) Mover() *Mover
Mover is a method of PolicyStub, returns nil. As when there is no policy, mover does not make sense.
func (*PolicyStub) PidWatcher ¶
func (p *PolicyStub) PidWatcher() PidWatcher
PidWatcher is a method of PolicyStub, returns nil. As when there is no policy, pidwatcher does not make sense.
func (*PolicyStub) SetConfigJSON ¶
func (p *PolicyStub) SetConfigJSON(configJSON string) error
SetConfigJSON is a method of PolicyStub, returns nil.
func (*PolicyStub) Start ¶
func (p *PolicyStub) Start() error
Start is a method of PolicyStub, returns nil.
func (*PolicyStub) Stop ¶
func (p *PolicyStub) Stop()
Stop is a method of TrackerStub that doing nothing here.
func (*PolicyStub) Tracker ¶
func (p *PolicyStub) Tracker() Tracker
Tracker is a method of PolicyStub, returns nil. As when there is no policy, tracker does not make sense.
type ProcKpageflagsFile ¶
type ProcKpageflagsFile struct {
// contains filtered or unexported fields
}
ProcKpageflagsFile represents a structure for managing a file associated with kpage flags.
func ProcKpageflagsOpen ¶
func ProcKpageflagsOpen() (*ProcKpageflagsFile, error)
func (*ProcKpageflagsFile) Close ¶
func (f *ProcKpageflagsFile) Close()
func (*ProcKpageflagsFile) ReadFlags ¶
func (f *ProcKpageflagsFile) ReadFlags(pfn uint64) (uint64, error)
ReadFlags returns 64-bit set of flags from /proc/kpageflags for a page indexed by page frame number (PFN).
func (*ProcKpageflagsFile) SetReadahead ¶
func (f *ProcKpageflagsFile) SetReadahead(pages int)
type ProcMemFile ¶
type ProcMemFile struct {
// contains filtered or unexported fields
}
ProcMemFile represents a structure for managing a file associated with process memory.
func ProcMemOpen ¶
func ProcMemOpen(pid int) (*ProcMemFile, error)
func (*ProcMemFile) Close ¶
func (f *ProcMemFile) Close() error
func (*ProcMemFile) ReadNoData ¶
func (f *ProcMemFile) ReadNoData(startAddr, endAddr uint64) error
ReadNoData reads one byte from every page in the address range to force each page in memory.
type ProcPageIdleBitmapFile ¶
type ProcPageIdleBitmapFile struct {
// contains filtered or unexported fields
}
ProcPageIdleBitmapFile represents a structure for managing a file associated with proc page idle bitmaps.
func ProcPageIdleBitmapOpen ¶
func ProcPageIdleBitmapOpen() (*ProcPageIdleBitmapFile, error)
ProcPageIdleBitmapOpen returns opened page_idle/bitmap file
func (*ProcPageIdleBitmapFile) Close ¶
func (f *ProcPageIdleBitmapFile) Close()
func (*ProcPageIdleBitmapFile) GetIdle ¶
func (f *ProcPageIdleBitmapFile) GetIdle(pfn uint64) (bool, error)
func (*ProcPageIdleBitmapFile) ReadBits ¶
func (f *ProcPageIdleBitmapFile) ReadBits(pfn uint64) (uint64, error)
func (*ProcPageIdleBitmapFile) SetIdle ¶
func (f *ProcPageIdleBitmapFile) SetIdle(pfn uint64) error
func (*ProcPageIdleBitmapFile) SetIdleAll ¶
func (f *ProcPageIdleBitmapFile) SetIdleAll(pfn uint64) error
func (*ProcPageIdleBitmapFile) SetReadahead ¶
func (f *ProcPageIdleBitmapFile) SetReadahead(chunks int)
type ProcPagemapFile ¶
type ProcPagemapFile struct {
// contains filtered or unexported fields
}
ProcPagemapFile represents a structure for managing a file associated with proc pagemap.
func ProcPagemapOpen ¶
func ProcPagemapOpen(pid int) (*ProcPagemapFile, error)
ProcPagemapOpen returns opened pagemap file for a process
func (*ProcPagemapFile) Close ¶
func (f *ProcPagemapFile) Close()
func (*ProcPagemapFile) ForEachPage ¶
func (f *ProcPagemapFile) ForEachPage(addressRanges []AddrRange, pageAttributes uint64, handlePage func(uint64, uint64) int) error
ForEachPage calls handlePage with pagemap bytes and page's address for every matching page in the address range.
Parameters:
- addressRanges includes the address ranges from which pages are searched from.
- pageAttributes defines attributes that found pages must or must not have. Value 0 matches all pages.
- handlePage(pagemapBits, pageAddr) is called for matching pages. It returns an integer: 0 (continue): ForEachPage continues reading the next page attributes. -1 (break): ForEachPage returns immediately. n > 0 (skip): ForEachPage will skip reading next n pages.
func (*ProcPagemapFile) SetReadahead ¶
func (f *ProcPagemapFile) SetReadahead(pages int)
type Process ¶
type Process struct {
// contains filtered or unexported fields
}
Process represents a process with a unique process ID (pid).
func NewProcess ¶
NewProcess creates a new Process instance with the specified process ID (pid).
func (*Process) AddressRanges ¶
func (p *Process) AddressRanges() (*AddrRanges, error)
AddressRanges returns address ranges of the process.
type Prompt ¶
type Prompt struct {
// contains filtered or unexported fields
}
Prompt represents an interactive prompt with associated functionality.
func NewPrompt ¶
NewPrompt creates a new interactive prompt with the given prompt string and I/O readers/writers.
func (*Prompt) AddPids ¶
AddPids adds the specified process IDs (pids) to the Prompt's watch list. It prints a log message indicating the added PIDs.
func (*Prompt) RemovePids ¶
RemovePids removes the specified process IDs (pids) from the Prompt's watch list. It prints a log message indicating the removed PIDs.
func (*Prompt) RunCmdSlice ¶
func (p *Prompt) RunCmdSlice(cmdSlice []string) CommandStatus
RunCmdSlice executes a command specified by a slice of strings.
func (*Prompt) RunCmdString ¶
func (p *Prompt) RunCmdString(cmdString string) CommandStatus
RunCmdString executes a command specified by a string.
func (*Prompt) SetRoutines ¶
SetRoutines sets the routines for the prompt.
type Routine ¶
type Routine interface { SetConfigJSON(string) error // Set new configuration. GetConfigJSON() string // Get current configuration. SetPolicy(Policy) error // Set a policy. Start() error Stop() Dump(args []string) string }
Routine is an interface for routines, which defines all the methods.
func NewRoutine ¶
NewRoutine creates a new instance of a routine based on its name.
func NewRoutineStatActions ¶
NewRoutineStatActions creates a new instance of RoutineStatActions.
func NewRoutineStub ¶
NewRoutineStub creates a new instance of RoutineStub with default configuration.
type RoutineConfig ¶
RoutineConfig holds the configuration for a routine.
type RoutineCreator ¶
RoutineCreator is a function type that creates a new instance of a routine.
type RoutineStatActions ¶
type RoutineStatActions struct {
// contains filtered or unexported fields
}
RoutineStatActions represents the StatActions routine.
func (*RoutineStatActions) Dump ¶
func (r *RoutineStatActions) Dump(args []string) string
Dump returns a string representation of the StatActions routine's status.
func (*RoutineStatActions) GetConfigJSON ¶
func (r *RoutineStatActions) GetConfigJSON() string
GetConfigJSON returns the configuration of the StatActions routine as a JSON string.
func (*RoutineStatActions) SetConfigJSON ¶
func (r *RoutineStatActions) SetConfigJSON(configJSON string) error
SetConfigJSON sets the configuration for the StatActions routine from a JSON string.
func (*RoutineStatActions) SetPolicy ¶
func (r *RoutineStatActions) SetPolicy(policy Policy) error
SetPolicy sets the policy for the StatActions routine.
func (*RoutineStatActions) Start ¶
func (r *RoutineStatActions) Start() error
Start starts the StatActions routine.
func (*RoutineStatActions) Stop ¶
func (r *RoutineStatActions) Stop()
Stop stops the StatActions routine.
type RoutineStatActionsConfig ¶
type RoutineStatActionsConfig struct { // IntervalMs is the length of the period in milliseconds in // which StatActions routine checks process_statactions call // statistics. IntervalMs int // IntervalCommand is the command to be executed in specified // intervals. IntervalCommand []string // IntervalCommandRunner executes the IntervalCommand. // "exec" forks and executes the command in a child process. // "memtier" runs memtier command. // "memtier-prompt" runs a single-string memtier-prompt // command that is allowed to contain pipe to shell. IntervalCommandRunner string // PageOutMB is the total size of memory in megabytes that // has been process_statactions. If advised memory exceeds the // interval, the shell command will be executed. PageOutMB int // PageOutCommand is executed when new PageOutMB is reached. PageOutCommand []string // PageOutCommandRunner executes the PageOutCommand. // See IntervalCommandRunner for options. PageOutCommandRunner string // Timestamp defines the format of a timestamp that is printed // before running a command. The default is empty: no // timestamp. Use lowercase definitions in golang Time.Format // (for instance "rfc3339nano" or "rfc822z") or use "unix", // "unix.milli", "unix.micro". Timestamp string // TimestampAfter is like timestamp but printed after // running a command. TimestampAfter string }
RoutineStatActionsConfig holds the configuration for the StatActions routine.
type RoutineStub ¶
type RoutineStub struct { }
RoutineStub defines empty struct for the scenarios without routines configured.
func (*RoutineStub) Dump ¶
func (r *RoutineStub) Dump(args []string) string
Dump is a method of RoutineStub, returns "".
func (*RoutineStub) GetConfigJSON ¶
func (r *RoutineStub) GetConfigJSON() string
GetConfigJSON is a method of RoutineStub, returns "".
func (*RoutineStub) SetConfigJSON ¶
func (r *RoutineStub) SetConfigJSON(configJSON string) error
SetConfigJSON is a method of RoutineStub, returns nil.
func (*RoutineStub) SetPolicy ¶
func (r *RoutineStub) SetPolicy(Policy) error
SetPolicy is a method of RoutineStub, returns "".
func (*RoutineStub) Start ¶
func (r *RoutineStub) Start() error
Start is a method of RoutineStub, returns nil.
func (*RoutineStub) Stop ¶
func (r *RoutineStub) Stop()
Stop is a method of RoutineStub that doing nothing here.
type Stats ¶
Stats represents various statistics related to memory moving.
func (*Stats) LastMove ¶
func (s *Stats) LastMove(pid int) *StatsMoved
LastMove returns the last move statistics for a specific process.
func (*Stats) LastMoveWithError ¶
func (s *Stats) LastMoveWithError(pid int) *StatsMoved
LastMoveWithError returns the last move statistics with an error for a specific process.
func (*Stats) MadvisedPageCount ¶
MadvisedPageCount returns the number of pages on which process_madvise(pid, advise) has been called. If pid==-1 or advise==-1, then return the sum of pages of all pids and advises.
func (*Stats) Store ¶
func (s *Stats) Store(entry interface{})
Store stores various statistics based on the type of entry provided.
func (*Stats) String ¶
String returns a string representation of the Stats object. It includes move statistics for each PID.
func (*Stats) Summarize ¶
Summarize generates a formatted string summary of various statistics based on the specified tables and format. It supports different tables, including events, process_madvise, move_pages, move_pages_errors, and memory_scans. Args:
- format: "txt" or "csv".
- tables: Names of tables to include in the summary (e.g., "events", "move_pages").
Returns: A formatted string containing the summary or an error message for invalid parameters.
type StatsHeartbeat ¶
type StatsHeartbeat struct {
// contains filtered or unexported fields
}
StatsHeartbeat represents a heartbeat for a specific name.
type StatsMadvised ¶
type StatsMadvised struct {
// contains filtered or unexported fields
}
StatsMadvised represents statistics related to process_madvise system calls for a specific process.
type StatsMoved ¶
type StatsMoved struct {
// contains filtered or unexported fields
}
StatsMoved represents statistics related to move_pages system calls for a specific process.
func (*StatsMoved) String ¶
func (sm *StatsMoved) String() string
String returns a string representation of the StatsMoved object. It includes details of the move_pages syscall, including inputs and results.
type StatsPageScan ¶
type StatsPageScan struct {
// contains filtered or unexported fields
}
StatsPageScan represents statistics related to memory scans for a specific process.
type StatsPidMadvised ¶
type StatsPidMadvised struct {
// contains filtered or unexported fields
}
StatsPidMadvised contains the summarized statistics related to process_madvise system calls for a specific process.
type StatsPidMoved ¶
type StatsPidMoved struct {
// contains filtered or unexported fields
}
StatsPidMoved contains the summarized statistics related to move_pages system calls for a specific process.
type StatsPidScanned ¶
type StatsPidScanned struct {
// contains filtered or unexported fields
}
StatsPidScanned contains the summarized statistics related to memory scans for a specific process.
type StatsPulse ¶
type StatsPulse struct {
// contains filtered or unexported fields
}
StatsPulse represents heartbeat statistics for a specific name.
type Tracker ¶
type Tracker interface { SetConfigJSON(string) error // Set new configuration. GetConfigJSON() string // Get current configuration. AddPids([]int) // Add pids to be tracked. RemovePids([]int) // Remove pids, RemovePids(nil) clears all. Start() error // Start tracking. Stop() // Stop tracking. Dump([]string) string // Peek at tracker internals. ResetCounters() GetCounters() *TrackerCounters }
Tracker is an interface for memory tracking.
func NewTracker ¶
NewTracker creates a new Tracker instance based on the provided name.
func NewTrackerDamon ¶
NewTrackerDamon creates a new TrackerDamon instance.
func NewTrackerFinder ¶
NewTrackerFinder creates a new instance of TrackerFinder.
func NewTrackerIdlePage ¶
NewTrackerIdlePage creates a new instance of TrackerIdlePage.
func NewTrackerMulti ¶
NewTrackerMulti creates a new instance of TrackerMulti.
func NewTrackerSoftDirty ¶
NewTrackerSoftDirty creates a new instance of TrackerSoftDirty.
func NewTrackerStub ¶
NewTrackerStub creates a new instance of TrackerStub with default configuration.
type TrackerConfig ¶
TrackerConfig holds the configuration for the memory tracker.
type TrackerCounter ¶
type TrackerCounter struct { Accesses uint64 Reads uint64 Writes uint64 AR *AddrRanges }
TrackerCounter holds counters for memory tracking.
type TrackerCounters ¶
type TrackerCounters []TrackerCounter
TrackerCounters is a slice of TrackerCounter instances.
func (*TrackerCounters) Flattened ¶
func (tcs *TrackerCounters) Flattened(cut func(tc0 TrackerCounter, ar *AddrRange) TrackerCounter, union func(tc0, tc1 TrackerCounter) TrackerCounter) *TrackerCounters
Flattened returns tracker counters with overlapping parts squashed. Parameters:
cut - returns new tc that is a cut from the address range part of tc0. union - returns new tc that represents union of tc0 and tc1.
func (*TrackerCounters) RangeHeat ¶
func (tcs *TrackerCounters) RangeHeat() []*RangeHeat
RangeHeat returns RangeHeat data for TrackerCounters.
func (*TrackerCounters) RegionsMerged ¶
func (tcs *TrackerCounters) RegionsMerged() *TrackerCounters
RegionsMerged returns TrackerCounters with merged memory regions.
func (*TrackerCounters) SortByAccesses ¶
func (tcs *TrackerCounters) SortByAccesses()
SortByAccesses sorts TrackerCounters by the number of accesses.
func (*TrackerCounters) SortByAddr ¶
func (tcs *TrackerCounters) SortByAddr()
SortByAddr sorts TrackerCounters by memory address.
func (*TrackerCounters) String ¶
func (tcs *TrackerCounters) String() string
String converts TrackerCounters to a string representation.
type TrackerCreator ¶
TrackerCreator is a function type to create a new Tracker instance.
type TrackerDamon ¶
type TrackerDamon struct {
// contains filtered or unexported fields
}
TrackerDamon represents the main DAMON tracker structure.
func (*TrackerDamon) AddPids ¶
func (t *TrackerDamon) AddPids(pids []int)
AddPids adds process IDs to be tracked by DAMON.
func (*TrackerDamon) Dump ¶
func (t *TrackerDamon) Dump(args []string) string
Dump generates a dump based on the provided arguments. It supports different dump types, such as "raw". The method delegates the actual dump generation to the appropriate sub-method based on the dump type.
func (*TrackerDamon) GetConfigJSON ¶
func (t *TrackerDamon) GetConfigJSON() string
GetConfigJSON returns the DAMON configuration as a JSON string.
func (*TrackerDamon) GetCounters ¶
func (t *TrackerDamon) GetCounters() *TrackerCounters
GetCounters returns a new TrackerCounters instance containing counters for tracked accesses. It uses the current state of the TrackerDamon and aggregates access counts based on process ID, start address, and length. The function acquires a lock on the TrackerDamon's mutex to ensure safe access to shared data.
func (*TrackerDamon) RemovePids ¶
func (t *TrackerDamon) RemovePids(pids []int)
RemovePids removes process IDs from being tracked by DAMON.
func (*TrackerDamon) ResetCounters ¶
func (t *TrackerDamon) ResetCounters()
ResetCounters resets the DAMON counters.
func (*TrackerDamon) SetConfigJSON ¶
func (t *TrackerDamon) SetConfigJSON(configJSON string) error
SetConfigJSON sets the DAMON configuration from a JSON string.
type TrackerDamonConfig ¶
type TrackerDamonConfig struct { // Connection specifies how to connect to the damon. "perf" // connects by tracing damon:aggregated using perf. Options // can be appended to the perf trace command. For example, // trace only address ranges where accesses have been detected // by adding a filter: "perf --filter nr_accesses>0". // The default is "bpftrace". Connection string // SamplingUs is the sampling interval in debugfs/damon attrs // (microseconds). SamplingUs uint64 // AggregationUs is the aggregation interval in debugfs/damon // attrs (microseconds). AggregationUs uint64 // RegionsUpdateUs is the regions update interval in // debugfs/damon attrs (microseconds). RegionsUpdateUs uint64 // MinTargetRegions is the minimum number of monitoring target // regions in debugfs/damon attrs. MinTargetRegions uint64 // MaxTargetRegions is the maximum number of monitoring target // regions in debugfs/damon attrs. MaxTargetRegions uint64 // FilterAddressRangeSizeMax sets the maximum size for address // ranges reported by DAMON. The DAMON aggregations may report // start and end addresses from different memory mappings, or // they may be from the same memory mapping but so large that // the information is not very reliable. // The default is 33554432 (32 MB). // -1 is unlimited. FilterAddressRangeSizeMax int64 // Interface: 0 is autodetect, 1 is sysfs, 2 is debugfs Interface int // SysfsRegionsManager: 0 is DAMON, 1 is memtierd (write targets/TID/regions/RID/{start,stop}) SysfsRegionsManager int // KdamondsList contains kdamond instances available for this // tracker instance. The default is to use any kdamond that // has 0 contexts. KdamondsList []int // KdamondsNr is the number of kdamonds to initialize in the // system if none exists when the tracker is configured. NrKdamonds int }
TrackerDamonConfig holds configuration parameters for connecting to DAMON.
type TrackerFinder ¶
type TrackerFinder struct {
// contains filtered or unexported fields
}
TrackerFinder is a memory tracker that reports address ranges without any accesses on them.
func (*TrackerFinder) AddPids ¶
func (t *TrackerFinder) AddPids(pids []int)
AddPids adds PIDs to the TrackerFinder's regions map.
func (*TrackerFinder) Dump ¶
func (t *TrackerFinder) Dump(args []string) string
Dump generates a dump based on the provided arguments.
func (*TrackerFinder) GetConfigJSON ¶
func (t *TrackerFinder) GetConfigJSON() string
GetConfigJSON returns the JSON representation of the TrackerFinder's configuration.
func (*TrackerFinder) GetCounters ¶
func (t *TrackerFinder) GetCounters() *TrackerCounters
GetCounters returns the counters tracked by TrackerFinder.
func (*TrackerFinder) RemovePids ¶
func (t *TrackerFinder) RemovePids(pids []int)
RemovePids removes PIDs from the TrackerFinder's regions map.
func (*TrackerFinder) ResetCounters ¶
func (t *TrackerFinder) ResetCounters()
ResetCounters does nothing as TrackerFinder tracks no memory accesses.
func (*TrackerFinder) SetConfigJSON ¶
func (t *TrackerFinder) SetConfigJSON(configJSON string) error
SetConfigJSON sets the configuration for TrackerFinder from a JSON string.
func (*TrackerFinder) Start ¶
func (t *TrackerFinder) Start() error
Start starts the TrackerFinder's sampler.
type TrackerFinderConfig ¶
type TrackerFinderConfig struct { // RegionsUpdateMs defines process memory region update // interval in milliseconds. Regions are updated just before // scanning pages if the interval has passed. Value 0 means // that regions are updated before every scan. RegionsUpdateMs uint64 // ReportAccesses is the number of accesses the tracker // reports on every address range it has found. ReportAccesses uint64 // PagemapBitBIT filters in pages with only given values // of pagemap bits. If nil, there is no filtering. // If all PagemapBitBITs are nil, finding memory regions // is much faster because any pagemap bits are not checked. // For more information on pagemap bits, refer to: // https://www.kernel.org/doc/Documentation/vm/pagemap.txt PagemapBitExclusive *bool PagemapBitPresent *bool PagemapBitSoftDirty *bool }
TrackerFinderConfig represents the configuration for TrackerFinder.
type TrackerIdlePage ¶
type TrackerIdlePage struct {
// contains filtered or unexported fields
}
TrackerIdlePage is a tracker implementation for monitoring idle pages.
func (*TrackerIdlePage) AddPids ¶
func (t *TrackerIdlePage) AddPids(pids []int)
AddPids adds process IDs to be tracked by TrackerIdlePage.
func (*TrackerIdlePage) Dump ¶
func (t *TrackerIdlePage) Dump(args []string) string
Dump provides a mechanism for dumping raw access data.
func (*TrackerIdlePage) GetConfigJSON ¶
func (t *TrackerIdlePage) GetConfigJSON() string
GetConfigJSON returns the current configuration of TrackerIdlePage as a JSON string.
func (*TrackerIdlePage) GetCounters ¶
func (t *TrackerIdlePage) GetCounters() *TrackerCounters
GetCounters returns the access counters of TrackerIdlePage.
func (*TrackerIdlePage) RemovePids ¶
func (t *TrackerIdlePage) RemovePids(pids []int)
RemovePids removes process IDs from being tracked by TrackerIdlePage.
func (*TrackerIdlePage) ResetCounters ¶
func (t *TrackerIdlePage) ResetCounters()
ResetCounters resets the access counters of TrackerIdlePage.
func (*TrackerIdlePage) SetConfigJSON ¶
func (t *TrackerIdlePage) SetConfigJSON(configJSON string) error
SetConfigJSON sets the configuration for TrackerIdlePage from a JSON string.
func (*TrackerIdlePage) Start ¶
func (t *TrackerIdlePage) Start() error
Start begins tracking idle pages.
func (*TrackerIdlePage) Stop ¶
func (t *TrackerIdlePage) Stop()
Stop halts the tracking of idle pages.
type TrackerIdlePageConfig ¶
type TrackerIdlePageConfig struct { // PagesInRegion is the number of pages in every address range // that is being watched and moved from a NUMA node to another. PagesInRegion uint64 // MaxCountPerRegion is the maximum number of pages that are // reported to be accessed. When the maximum number is reached // during scanning a region, the rest of the pages in the // region are skipped. Value 0 means unlimited (that is, the // maximum number will be at most the same as PagesInRegion). MaxCountPerRegion uint64 // ScanIntervalMs defines page scan interval in milliseconds. ScanIntervalMs uint64 // RegionsUpdateMs defines process memory region update // interval in milliseconds. Regions are updated just before // scanning pages if the interval has passed. Value 0 means // that regions are updated before every scan. RegionsUpdateMs uint64 // PagemapReadahead is the number of pages to be read ahead // from /proc/PID/pagemap. Every page information is 16 B. If // 0 (undefined) use a default, if -1, disable readahead. PagemapReadahead int // KpageflagsReadahead is the number of pages to be read ahead // from /proc/kpageflags. Every page information is 16 B. If 0 // (undefined) use a default, if -1, disable readahead. KpageflagsReadahead int // BitmapReadahead is the number of chunks of 64 pages to be // read ahead from /sys/kernel/mm/page_idle/bitmap. If 0 // (undefined) use a default, if -1, disable readahead. BitmapReadahead int }
TrackerIdlePageConfig represents the configuration for the TrackerIdlePage. It defines parameters such as the number of pages in a region, scan intervals, etc.
type TrackerMulti ¶
type TrackerMulti struct {
// contains filtered or unexported fields
}
TrackerMulti is a tracker that aggregates multiple trackers, each configured independently.
func (*TrackerMulti) AddPids ¶
func (t *TrackerMulti) AddPids(pids []int)
AddPids adds the specified process IDs (pids) to all the trackers in the TrackerMulti.
func (*TrackerMulti) Dump ¶
func (t *TrackerMulti) Dump(args []string) string
Dump returns a string representation of all the trackers.
func (*TrackerMulti) GetConfigJSON ¶
func (t *TrackerMulti) GetConfigJSON() string
GetConfigJSON returns the JSON representation of the multiple trackers' configuration.
func (*TrackerMulti) GetCounters ¶
func (t *TrackerMulti) GetCounters() *TrackerCounters
GetCounters aggregates counters from all the trackers in the TrackerMulti.
func (*TrackerMulti) RemovePids ¶
func (t *TrackerMulti) RemovePids(pids []int)
RemovePids removes the specified process IDs (pids) from all the trackers in the TrackerMulti.
func (*TrackerMulti) ResetCounters ¶
func (t *TrackerMulti) ResetCounters()
ResetCounters resets counters for all the trackers in the TrackerMulti.
func (*TrackerMulti) SetConfigJSON ¶
func (t *TrackerMulti) SetConfigJSON(configJSON string) error
SetConfigJSON sets the configuration for multiple trackers from a JSON string.
func (*TrackerMulti) Start ¶
func (t *TrackerMulti) Start() error
Start starts all the trackers in the TrackerMulti.
func (*TrackerMulti) Stop ¶
func (t *TrackerMulti) Stop()
Stop stops all the trackers in the TrackerMulti.
type TrackerMultiConfig ¶
type TrackerMultiConfig struct {
Trackers []TrackerConfig
}
TrackerMultiConfig represents the configuration for multiple trackers, it containing a list of TrackerConfig.
type TrackerSoftDirty ¶
type TrackerSoftDirty struct {
// contains filtered or unexported fields
}
TrackerSoftDirty is a memory tracker that detects memory writes.
func (*TrackerSoftDirty) AddPids ¶
func (t *TrackerSoftDirty) AddPids(pids []int)
AddPids adds PIDs to the TrackerSoftDirty's regions map.
func (*TrackerSoftDirty) Dump ¶
func (t *TrackerSoftDirty) Dump(args []string) string
Dump generates a dump based on the provided arguments.
func (*TrackerSoftDirty) GetConfigJSON ¶
func (t *TrackerSoftDirty) GetConfigJSON() string
GetConfigJSON returns the JSON representation of the TrackerSoftDirty's configuration.
func (*TrackerSoftDirty) GetCounters ¶
func (t *TrackerSoftDirty) GetCounters() *TrackerCounters
GetCounters returns the counters tracked by TrackerSoftDirty.
func (*TrackerSoftDirty) RemovePids ¶
func (t *TrackerSoftDirty) RemovePids(pids []int)
RemovePids removes PIDs from the TrackerSoftDirty's regions map.
func (*TrackerSoftDirty) ResetCounters ¶
func (t *TrackerSoftDirty) ResetCounters()
ResetCounters resets the counters that TrackerSoftDirty uses to track memory accesses.
func (*TrackerSoftDirty) SetConfigJSON ¶
func (t *TrackerSoftDirty) SetConfigJSON(configJSON string) error
SetConfigJSON sets the configuration for TrackerSoftDirty from a JSON string.
func (*TrackerSoftDirty) Start ¶
func (t *TrackerSoftDirty) Start() error
Start starts the TrackerSoftDirty's sampler.
func (*TrackerSoftDirty) Stop ¶
func (t *TrackerSoftDirty) Stop()
Stop stops the TrackerSoftDirty's sampler.
type TrackerSoftDirtyConfig ¶
type TrackerSoftDirtyConfig struct { // PagesInRegion is the number of pages in every address range // that is being watched and moved from a NUMA node to another. PagesInRegion uint64 // MaxCountPerRegion is the maximum number of pages that are // reported to be written. When the maximum number is reached // during scanning a region, the rest of the pages in the // region are skipped. Value 0 means unlimited (that is, the // maximum number will be at most the same as PagesInRegion). MaxCountPerRegion uint64 // ScanIntervalMs defines page scan interval in milliseconds. ScanIntervalMs uint64 // RegionsUpdateMs defines process memory region update // interval in milliseconds. Regions are updated just before // scanning pages if the interval has passed. Value 0 means // that regions are updated before every scan. RegionsUpdateMs uint64 // SkipPageProb enables sampling instead of reading through // pages in a region. Value 0 reads all pages as far as // MaxCountPerRegion is not reached. Value 1000 skips the next // page with probability 1.0, resulting in reading only the // first pages of every address range. SkipPageProb int // PagemapReadahead optimizes performance for the platform, if // 0 (undefined) use a default, if -1, disable readahead. PagemapReadahead int // EXPERIMENTAL (does not work): TrackReferenced bool // Track /proc/kpageflags PKF_REFERENCED bit. }
TrackerSoftDirtyConfig represents the configuration for TrackerSoftDirty.
type TrackerStub ¶
type TrackerStub struct { }
TrackerStub defines empty struct for the scenarios without tracker configured.
func (*TrackerStub) AddPids ¶
func (t *TrackerStub) AddPids(pids []int)
AddPids is a method of TrackerStub that doing nothing here.
func (*TrackerStub) Dump ¶
func (t *TrackerStub) Dump([]string) string
Dump is a method of TrackerStub, returns "".
func (*TrackerStub) GetConfigJSON ¶
func (t *TrackerStub) GetConfigJSON() string
GetConfigJSON is a method of TrackerStub, returns "".
func (*TrackerStub) GetCounters ¶
func (t *TrackerStub) GetCounters() *TrackerCounters
GetCounters is a method of TrackerStub, returns nil.
func (*TrackerStub) RemovePids ¶
func (t *TrackerStub) RemovePids(pids []int)
RemovePids is a method of TrackerStub that doing nothing here.
func (*TrackerStub) ResetCounters ¶
func (t *TrackerStub) ResetCounters()
ResetCounters is a method of TrackerStub that doing nothing here.
func (*TrackerStub) SetConfigJSON ¶
func (t *TrackerStub) SetConfigJSON(configJSON string) error
SetConfigJSON is a method of TrackerStub, returns nil.
func (*TrackerStub) Start ¶
func (t *TrackerStub) Start() error
Start is a method of TrackerStub, returns nil.
func (*TrackerStub) Stop ¶
func (t *TrackerStub) Stop()
Stop is a method of TrackerStub that doing nothing here.
Source Files ¶
- addrdata.go
- addrrange.go
- consts.go
- counters_heatmap.go
- deprecated.go
- doc.go
- heatforecaster.go
- heatforecaster_chain.go
- heatforecaster_stdio.go
- heatforecaster_stub.go
- heatforecaster_trace.go
- log.go
- madvise_linux.go
- move_linux.go
- mover.go
- node.go
- page.go
- parse.go
- pidwatcher.go
- pidwatcher_cgroups.go
- pidwatcher_filter.go
- pidwatcher_pidlist.go
- pidwatcher_proc.go
- pidwatcher_stub.go
- policy.go
- policy_age.go
- policy_heat.go
- policy_ratio.go
- policy_stub.go
- proc.go
- process.go
- prompt.go
- routine.go
- routine_statactions.go
- routine_stub.go
- setmember.go
- stats.go
- tracker.go
- tracker_damon.go
- tracker_finder.go
- tracker_idlepage.go
- tracker_multi.go
- tracker_softdirty.go
- tracker_stub.go
- unmarshal.go
- utils.go