performance

package
v0.0.0-...-c0d7cef Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package performance provides high-performance primitives for audit logging.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchReader

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

BatchReader reads multiple events at once for efficiency

func NewBatchReader

func NewBatchReader(buffer *RingBuffer, maxBatch int) *BatchReader

NewBatchReader creates a batch reader

func (*BatchReader) ReadBatch

func (br *BatchReader) ReadBatch() []*core.LogEvent

ReadBatch reads up to maxBatch events

type GroupCommitStats

type GroupCommitStats struct {
	EventCount   int64
	BatchCount   int64
	FlushCount   int64
	TimerFlushes int64
	SizeFlushes  int64
	AvgBatchSize float64
	AvgLatency   time.Duration
	MaxBatchSize int
	MaxDelay     time.Duration
}

GroupCommitStats contains group commit statistics

type GroupCommitter

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

GroupCommitter batches events for efficient writes

func NewGroupCommitter

func NewGroupCommitter(w *wal.WAL, batchSize int, maxDelay time.Duration) *GroupCommitter

NewGroupCommitter creates a new group committer

func (*GroupCommitter) Add

func (gc *GroupCommitter) Add(event *core.LogEvent) error

Add adds an event to the batch

func (*GroupCommitter) AddBatch

func (gc *GroupCommitter) AddBatch(events []*core.LogEvent) error

AddBatch adds multiple events efficiently

func (*GroupCommitter) Close

func (gc *GroupCommitter) Close() error

Close closes the group committer

func (*GroupCommitter) GetStats

func (gc *GroupCommitter) GetStats() GroupCommitStats

GetStats returns statistics

type MultiProducerRingBuffer

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

MultiProducerRingBuffer supports multiple concurrent writers

func NewMultiProducerRingBuffer

func NewMultiProducerRingBuffer(size int) *MultiProducerRingBuffer

NewMultiProducerRingBuffer creates a multi-producer ring buffer

func (*MultiProducerRingBuffer) Read

Read reads from the multi-producer buffer

func (*MultiProducerRingBuffer) Write

func (mp *MultiProducerRingBuffer) Write(event *core.LogEvent) bool

Write writes to the multi-producer buffer

type OptimizedGroupCommitter

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

OptimizedGroupCommitter uses lock-free techniques for higher throughput

func NewOptimizedGroupCommitter

func NewOptimizedGroupCommitter(w *wal.WAL, bufferSize, batchSize int, maxDelay time.Duration) *OptimizedGroupCommitter

NewOptimizedGroupCommitter creates an optimized group committer

func (*OptimizedGroupCommitter) Add

func (ogc *OptimizedGroupCommitter) Add(event *core.LogEvent) error

Add adds an event using lock-free operations

func (*OptimizedGroupCommitter) Close

func (ogc *OptimizedGroupCommitter) Close() error

Close closes the optimized committer

type RingBuffer

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

RingBuffer is a lock-free ring buffer for high throughput

func NewRingBuffer

func NewRingBuffer(size int) *RingBuffer

NewRingBuffer creates a new ring buffer Size must be a power of 2

func (*RingBuffer) Capacity

func (rb *RingBuffer) Capacity() uint64

Capacity returns the capacity of the ring buffer

func (*RingBuffer) Clear

func (rb *RingBuffer) Clear()

Clear clears the ring buffer

func (*RingBuffer) IsEmpty

func (rb *RingBuffer) IsEmpty() bool

IsEmpty returns true if the buffer is empty

func (*RingBuffer) IsFull

func (rb *RingBuffer) IsFull() bool

IsFull returns true if the buffer is full

func (*RingBuffer) Read

func (rb *RingBuffer) Read() *core.LogEvent

Read reads an event from the ring buffer (lock-free)

func (*RingBuffer) Size

func (rb *RingBuffer) Size() uint64

Size returns the current number of items in the buffer

func (*RingBuffer) TryRead

func (rb *RingBuffer) TryRead() *core.LogEvent

TryRead attempts to read without blocking

func (*RingBuffer) TryWrite

func (rb *RingBuffer) TryWrite(event *core.LogEvent) bool

TryWrite attempts to write without blocking

func (*RingBuffer) Write

func (rb *RingBuffer) Write(event *core.LogEvent) bool

Write writes an event to the ring buffer (lock-free)

Jump to

Keyboard shortcuts

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