memquota

package
v0.0.0-...-7f57e1f Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MemoryQuota = prometheus.NewGaugeVec(
	prometheus.GaugeOpts{
		Namespace: "ticdc",
		Subsystem: "sinkmanager",
		Name:      "memory_quota",
		Help:      "memory quota of the changefeed",
	},

	[]string{"namespace", "changefeed", "type", "component"})

MemoryQuota indicates memory usage of a changefeed.

Functions

func InitMetrics

func InitMetrics(registry *prometheus.Registry)

InitMetrics registers all metrics in this file.

Types

type MemConsumeRecord

type MemConsumeRecord struct {
	ResolvedTs model.ResolvedTs
	Size       uint64
}

MemConsumeRecord is used to trace memory usage.

type MemQuota

type MemQuota struct {
	// contains filtered or unexported fields
}

MemQuota is used to trace memory usage.

func NewMemQuota

func NewMemQuota(changefeedID model.ChangeFeedID, totalBytes uint64, comp string) *MemQuota

NewMemQuota creates a MemQuota instance.

func (*MemQuota) AddTable

func (m *MemQuota) AddTable(span tablepb.Span)

AddTable adds a table into the quota.

func (*MemQuota) BlockAcquire

func (m *MemQuota) BlockAcquire(nBytes uint64) error

BlockAcquire is used to block the request when the memory quota is not available.

func (*MemQuota) ClearTable

func (m *MemQuota) ClearTable(span tablepb.Span) uint64

ClearTable is like RemoveTable but only clear the memory usage records but doesn't remove the table.

func (*MemQuota) Close

func (m *MemQuota) Close()

Close the mem quota and notify the blocked acquire.

func (*MemQuota) ForceAcquire

func (m *MemQuota) ForceAcquire(nBytes uint64)

ForceAcquire is used to force acquire the memory quota.

func (*MemQuota) GetUsedBytes

func (m *MemQuota) GetUsedBytes() uint64

GetUsedBytes returns the used memory quota.

func (*MemQuota) Record

func (m *MemQuota) Record(span tablepb.Span, resolved model.ResolvedTs, nBytes uint64)

Record records the memory usage of a table.

func (*MemQuota) Refund

func (m *MemQuota) Refund(nBytes uint64)

Refund directly release the memory quota.

func (*MemQuota) Release

func (m *MemQuota) Release(span tablepb.Span, resolved model.ResolvedTs)

Release try to use resolvedTs to release the memory quota. Because we append records in order, we can use binary search to find the first record that is greater than resolvedTs, and release the memory quota of the records before it.

func (*MemQuota) RemoveTable

func (m *MemQuota) RemoveTable(span tablepb.Span) uint64

RemoveTable clears all records of the table and remove the table. Return the cleaned memory quota.

func (*MemQuota) TryAcquire

func (m *MemQuota) TryAcquire(nBytes uint64) bool

TryAcquire returns true if the memory quota is available, otherwise returns false.

Jump to

Keyboard shortcuts

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