Documentation
¶
Overview ¶
Package workload records the logical operations a Volume's storage engine serves, as runtime/trace log events, so the workload captured from a running app can be extracted from its execution trace and replayed against another engine.
Recording costs one trace.IsEnabled check per operation when no trace is running. Keys are recorded verbatim and values only by length, so a trace carries key material: capture traces from test data only.
Index ¶
Constants ¶
const Category = "hydra/volume-workload"
Category is the runtime/trace log category of every workload record.
Variables ¶
This section is empty.
Functions ¶
func AppendRecords ¶
AppendRecords appends records in their text form, one per line.
Types ¶
type Event ¶
type Event struct {
// Time is the trace timestamp in nanoseconds.
Time int64
// Goroutine is the emitting goroutine. GoScript reports one goroutine for
// every event, so replay orders by Time and correlates by Record IDs.
Goroutine int64
// Record is the logical operation.
Record Record
}
Event is a Record with the trace time and goroutine that emitted it.
type Op ¶
type Op string
Op names one logical storage operation.
const ( // OpTxRead opens a read-only transaction. OpTxRead Op = "tx-read" // OpTxWrite opens a read-write transaction. OpTxWrite Op = "tx-write" // OpGet reads Key; Size is the value length, or -1 when absent. OpGet Op = "get" // OpExists checks Key; Size is 1 when present and 0 when absent. OpExists Op = "exists" // OpSet writes a value of Size bytes to Key. OpSet Op = "set" // OpDelete deletes Key. OpDelete Op = "delete" // OpIterate opens an iterator over the Key prefix; Size is 1 when reverse. OpIterate Op = "iterate" // OpSeek positions an iterator at Key. OpSeek Op = "seek" // OpIterEnd closes an iterator that visited Size entries. OpIterEnd Op = "iter-end" // OpCommit commits a transaction with Size pending mutations. OpCommit Op = "commit" // OpDiscard discards a transaction. OpDiscard Op = "discard" )
Key-value transaction operations. ID is the transaction, except for iterator operations, where ID is the iterator and Parent its transaction.
const ( // OpPut writes a block of Size bytes. OpPut Op = "put" // OpTombstone writes a deletion marker within a batch. OpTombstone Op = "tombstone" // OpPutBatch opens batch ID of Size entries; its entries follow. OpPutBatch Op = "put-batch" // OpRm removes a block. OpRm Op = "rm" // OpGetBlock reads a block; Size is its length, or -1 when absent. OpGetBlock Op = "get-block" // OpStatBlock stats a block; Size is its length, or -1 when absent. OpStatBlock Op = "stat-block" // OpBlockExists checks a block; Size is 1 when present and 0 when absent. OpBlockExists Op = "block-exists" // OpExistsBatch checks Size blocks in read scope ID; its checks follow. OpExistsBatch Op = "exists-batch" // OpReadBegin opens read scope ID over one consistent block view. OpReadBegin Op = "read-begin" // OpReadEnd releases read scope ID. OpReadEnd Op = "read-end" // OpSync makes every earlier block write durable. OpSync Op = "sync" )
Block store operations. Key is the binary block reference. ID is the read scope or batch the operation belongs to, or 0 for a direct store call.
type Record ¶
type Record struct {
// Op names the operation.
Op Op
// ID identifies the transaction, iterator, read scope, or batch.
ID uint64
// Parent identifies the transaction that owns an iterator.
Parent uint64
// Size is the operation's length, count, or result, as its Op documents.
Size int64
// Key is the key, key prefix, or binary block reference.
Key []byte
}
Record is one logical storage operation.
func ParseRecord ¶
ParseRecord decodes a record from the text AppendText produced.
func ParseRecords ¶
ParseRecords decodes the lines AppendRecords produced.
func ReadTraceRecords ¶
ReadTraceRecords reads the workload records of the Go execution trace file at path.
func (Record) AppendText ¶
AppendText appends the record's single-line text form, which ParseRecord decodes: op, id, parent, size, and the hexadecimal key.
type Replay ¶
type Replay struct {
// Ordered commits every key-value commit that writes no shared object head
// with write ordering only, so only block Sync and head commits flush.
Ordered bool
// contains filtered or unexported fields
}
Replay replays a recorded workload against a Target. Values and block payloads are regenerated from their recorded lengths; a block keeps one deterministic payload, so its replay reference is stable across operations even though it differs from the recorded one.
func NewReplay ¶
NewReplay prepares a replay of records, regenerating every block payload and finding the state the workload reads before writing it.
type Result ¶
type Result struct {
// Ops is the number of records replayed.
Ops int
// Wall is the replay's elapsed time.
Wall time.Duration
// Latency holds each timed operation's latencies in replay order: commit,
// sync, put, put-batch, and get-block.
Latency map[Op][]time.Duration
// CommitErrors counts commits the target rejected. A replay that commits
// transactions the recording interleaved may conflict where it did not.
CommitErrors int
// OrderedCommits counts commits made with write ordering only.
OrderedCommits int
// BlockBytes is the payload written by block puts.
BlockBytes int64
// ValueBytes is the payload written by key-value sets.
ValueBytes int64
}
Result reports one replay.