topo

package
v0.0.0-...-b44688a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Thread

type Thread interface {
	ID() int
	Core() int
	Socket() int
	Equals(Thread) bool
}

Thread represents a hyperthread, typically presented by the operating system as a logical CPU.

func NewThread

func NewThread(id int, core int, socket int) Thread

NewThread returns a new thread with the supplied thread, core, and socket IDs.

func NewThreadFromID

func NewThreadFromID(id int) (thread Thread, err error)

NewThreadFromID returns new Thread from ThreadID

type ThreadSet

type ThreadSet []Thread

ThreadSet represents a subset of the available hyperthreads on a system.

func Discover

func Discover() (ThreadSet, error)

Discover CPU and basic NUMA topology.

func GetSiblingThreadsOfThread

func GetSiblingThreadsOfThread(reservedThread Thread) ThreadSet

GetSiblingThreadsOfThread returns sibling HyperThread for supplied Thread.

func GetSiblingThreadsOfThreadSet

func GetSiblingThreadsOfThreadSet(threads ThreadSet) (results ThreadSet)

GetSiblingThreadsOfThreadSet returns sibling HyperThreads for supplied ThreadSet.

func NewThreadSet

func NewThreadSet() ThreadSet

NewThreadSet returns a newly allocated thread set.

func NewThreadSetFromIntSet

func NewThreadSetFromIntSet(threads isolation.IntSet) (threadSet ThreadSet, err error)

NewThreadSetFromIntSet returns newly allocated thread set from IntSet with Thread IDs.

func ReadTopology

func ReadTopology(lscpuOutput []byte) (ThreadSet, error)

ReadTopology attempts to create a ThreadSet that corresponds to the supplied output from `lscpu -p`.

func SharedCacheThreads

func SharedCacheThreads() ThreadSet

SharedCacheThreads returns threads from one socket that share a last-level cache. To avoid placing workloads on both hyperthreads for any physical core, only one thread from each is included in the result.

func (ThreadSet) AvailableCores

func (s ThreadSet) AvailableCores() isolation.IntSet

AvailableCores returns the set of core ids for threads in this thread set.

func (ThreadSet) AvailableSockets

func (s ThreadSet) AvailableSockets() isolation.IntSet

AvailableSockets returns the set of socket ids for threads in this thread set.

func (ThreadSet) AvailableThreads

func (s ThreadSet) AvailableThreads() isolation.IntSet

AvailableThreads returns the set of thread ids for threads in this thread set.

func (ThreadSet) Contains

func (s ThreadSet) Contains(t Thread) bool

Contains returns true iff this set contains the supplied thread.

func (ThreadSet) Cores

func (s ThreadSet) Cores(n int) (ThreadSet, error)

Cores returns a newly allocated thread set containing all threads from `n` distinct cores. If there are fewer than `n` available, returns an error.

func (ThreadSet) Difference

func (s ThreadSet) Difference(ts ThreadSet) ThreadSet

Difference returns a newly allocated thread set containing all threads from this set except those contained in the supplied set.

func (ThreadSet) Filter

func (s ThreadSet) Filter(by func(Thread) bool) ThreadSet

Filter returns a newly allocated thread set containing all elements from this set that match the supplied predicate.

func (ThreadSet) FromCores

func (s ThreadSet) FromCores(coreIDs ...int) (ThreadSet, error)

FromCores returns a newly allocated thread set containing all threads from the supplied cores. If any of the supplied cores are invalid, returns an error.

func (ThreadSet) FromSockets

func (s ThreadSet) FromSockets(socketIDs ...int) (ThreadSet, error)

FromSockets returns a newly allocated thread set containing all threads from the supplied sockets. If any of the supplied sockets are invalid, returns an error.

func (ThreadSet) FromThreads

func (s ThreadSet) FromThreads(threadIDs ...int) (ThreadSet, error)

FromThreads returns a newly allocated thread set containing all threads with the supplied IDs. If any of the supplied thread IDs are invalid, returns an error.

func (ThreadSet) Partition

func (s ThreadSet) Partition(by func(Thread) bool) (ThreadSet, ThreadSet)

Partition returns two newly allocated thread sets: the first contains threads from this set that match the supplied predicate and the second contains threads that do not.

func (ThreadSet) Remove

func (s ThreadSet) Remove(t Thread) ThreadSet

Remove returns a newly allocated thread set containing all threads from this set except the supplied thread.

func (ThreadSet) RemoveThreadSet

func (s ThreadSet) RemoveThreadSet(ts ThreadSet) (result ThreadSet)

RemoveThreadSet Remove returns a newly allocated thread set containing all threads from this set except the supplied threads.

func (ThreadSet) Sockets

func (s ThreadSet) Sockets(n int) (ThreadSet, error)

Sockets returns a newly allocated thread set containing all threads from `n` distinct sockets. If there are fewer than `n` available, returns an error.

func (ThreadSet) Threads

func (s ThreadSet) Threads(n int) (ThreadSet, error)

Threads returns a newly allocated thread set containing `n` distinct threads from this thread set. If there are fewer than `n` available, returns an error.

func (ThreadSet) ToCPUSetNotation

func (s ThreadSet) ToCPUSetNotation() string

ToCPUSetNotation returns thread IDs in cpuset notation. Example return: 0,1,2,3,4 (...)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL