calc

package
v1.44.2 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ClassSize     = int64(5_800)
	ClassOverhead = int64(14_000_000)
)
View Source
const (
	Unknown Provenance = iota
	Default
	UserConfigured
	Calculated

	Kibi = int64(1_024)
	Mebi = 1_024 * Kibi
	Gibi = 1_024 * Mebi
	Tebi = 1_024 * Gibi

	SizePattern = "([\\d]+)([kmgtKMGT]?)"
)

Variables

View Source
var (
	DefaultDirectMemory = DirectMemory{Value: 10 * Mebi, Provenance: Default}
	DirectMemoryRE      = regexp.MustCompile(fmt.Sprintf("^-XX:MaxDirectMemorySize=(%s)$", SizePattern))
)
View Source
var (
	DefaultReservedCodeCache = ReservedCodeCache{Value: 240 * Mebi, Provenance: Default}
	ReservedCodeCacheRE      = regexp.MustCompile(fmt.Sprintf("^-XX:ReservedCodeCacheSize=(%s)$", SizePattern))
)
View Source
var (
	DefaultStack = Stack{Value: 1 * Mebi, Provenance: Default}
	StackRE      = regexp.MustCompile(fmt.Sprintf("^-Xss(%s)$", SizePattern))
)
View Source
var HeapRE = regexp.MustCompile(fmt.Sprintf("^-Xmx(%s)$", SizePattern))
View Source
var MetaspaceRE = regexp.MustCompile(fmt.Sprintf("^-XX:MaxMetaspaceSize=(%s)$", SizePattern))

Functions

func MatchDirectMemory

func MatchDirectMemory(s string) bool

func MatchHeap

func MatchHeap(s string) bool

func MatchMetaspace

func MatchMetaspace(s string) bool

func MatchReservedCodeCache

func MatchReservedCodeCache(s string) bool

func MatchStack

func MatchStack(s string) bool

func ParseUnit added in v1.25.0

func ParseUnit(u string) (int64, error)

ParseUnit parses a unit string and returns the number of bytes in the given unit. It assumes all units are binary units.

Types

type Calculator

type Calculator struct {
	HeadRoom         int
	LoadedClassCount int
	ThreadCount      int
	TotalMemory      Size
}

func (Calculator) Calculate

func (c Calculator) Calculate(flags string) (MemoryRegions, error)

type DirectMemory

type DirectMemory Size

func ParseDirectMemory

func ParseDirectMemory(s string) (DirectMemory, error)

func (DirectMemory) String

func (d DirectMemory) String() string

type HeadRoom

type HeadRoom Size

func (HeadRoom) String

func (h HeadRoom) String() string

type Heap

type Heap Size

func ParseHeap

func ParseHeap(s string) (*Heap, error)

func (Heap) String

func (h Heap) String() string

type MemoryRegions

type MemoryRegions struct {
	DirectMemory      DirectMemory
	HeadRoom          *HeadRoom
	Heap              *Heap
	Metaspace         *Metaspace
	ReservedCodeCache ReservedCodeCache
	Stack             Stack
}

func NewMemoryRegionsFromFlags

func NewMemoryRegionsFromFlags(flags string) (MemoryRegions, error)

func (MemoryRegions) AllRegionsSize

func (m MemoryRegions) AllRegionsSize(threadCount int) (Size, error)

func (MemoryRegions) AllRegionsString

func (m MemoryRegions) AllRegionsString(threadCount int) string

func (MemoryRegions) FixedRegionsSize

func (m MemoryRegions) FixedRegionsSize(threadCount int) (Size, error)

func (MemoryRegions) FixedRegionsString

func (m MemoryRegions) FixedRegionsString(threadCount int) string

func (MemoryRegions) NonHeapRegionsSize

func (m MemoryRegions) NonHeapRegionsSize(threadCount int) (Size, error)

func (MemoryRegions) NonHeapRegionsString

func (m MemoryRegions) NonHeapRegionsString(threadCount int) string

type Metaspace

type Metaspace Size

func ParseMetaspace

func ParseMetaspace(s string) (*Metaspace, error)

func (Metaspace) String

func (m Metaspace) String() string

type Provenance

type Provenance uint8

type ReservedCodeCache

type ReservedCodeCache Size

func ParseReservedCodeCache

func ParseReservedCodeCache(s string) (ReservedCodeCache, error)

func (ReservedCodeCache) String

func (r ReservedCodeCache) String() string

type Size

type Size struct {
	Value      int64
	Provenance Provenance
}

func ParseSize

func ParseSize(s string) (Size, error)

ParseSize parses a memory size in bytes from the given string. Size my include a K, M, G, or T suffix which indicates kibibytes, mebibytes, gibibytes or tebibytes respectively.

func (Size) String

func (s Size) String() string

type Stack

type Stack Size

func ParseStack

func ParseStack(s string) (Stack, error)

func (Stack) String

func (s Stack) String() string

Jump to

Keyboard shortcuts

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