22typedef enum : uint32_t {
42typedef enum : uint8_t {
50typedef enum : uint64_t {
76 uint64_t value = *state;
103 return (span == 0U) ? 0U : (uint32_t)(
internal_rng(state) % (uint64_t)span);
124 const uint8_t bytes[
sizeof(key)] = {
130 (uint8_t)(key.
page >> 8U),
131 (uint8_t)(key.
page >> 16U),
134 for (
size_t i = 0U; i <
sizeof(bytes); ++i) {
166 .footprint = footprints[i],
199 const size_t request =
206 if ((status !=
k_cb_io_ok) || (count == 0U) || (count > request)) {
241 const unsigned long object = strtoul(line, &end, (
int)
k_cb_base_dec);
242 if ((end == line) || (errno != 0)) {
245#if ULONG_MAX > UINT32_MAX
246 if (
object > (
unsigned long)UINT32_MAX) {
250 const char* second = end;
252 const unsigned long page_value = strtoul(second, &end, (
int)
k_cb_base_dec);
253 if ((end == second) || (errno != 0)) {
256#if ULONG_MAX > UINT32_MAX
257 if (page_value > (
unsigned long)UINT32_MAX) {
261 *object_id = (uint32_t)
object;
262 *page = (uint32_t)page_value;
290 while ((length + 1U) <
sizeof(cursor->
line)) {
299 cursor->
line[length] = (char)value;
301 if (value == (uint8_t)
'\n') {
305 if ((length == 0U) && eof) {
309 cursor->
line[length] =
'\0';
340 const uint64_t hot_span = (uint64_t)hot * (uint64_t)passes;
341 const uint64_t cycle = hot_span + (uint64_t)scan;
342 const uint64_t round = index / cycle;
343 const uint64_t pos = index % cycle;
344 const uint32_t page = (pos < hot_span)
345 ? (uint32_t)(pos % hot)
346 : hot + (uint32_t)(((uint64_t)hot + (round * scan) + (pos - hot_span)) %
347 (uint64_t)(footprint - hot));
368 const uint64_t index = cursor->
index;
402 }
else if (phase == 1U) {
404 }
else if (phase == 2U) {
420 if ((trace ==
nullptr) || (cursor ==
nullptr)) {
440 if ((cursor ==
nullptr) || (cursor->
trace ==
nullptr) || (key ==
nullptr) || (done ==
nullptr)) {
461 if ((cursor ==
nullptr) || (cursor->
trace ==
nullptr)) {
475 if ((source ==
nullptr) || (source->
read ==
nullptr) || (name ==
nullptr) || (out ==
nullptr) ||
struct cb_trace cb_trace_t
cb_io_status_t
Status returned by tool-local injected I/O callbacks.
@ k_cb_io_ok
Operation completed.
@ k_cb_io_fault
Backing device or sink failed.
@ k_cb_io_mutated
A replay source changed between passes.
@ k_cb_io_capacity
Caller-owned storage was too small.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
void * memcpy(void *dst, const void *src, size_t n)
Copy memory area between non-overlapping regions.
A cache key: one (object, page) the reader's vm_get touches.
uint32_t object_id
Opaque object handle (book / archive / font).
uint32_t page
Page index within the object (offset / page-size).
Immutable injected byte source with a snapshotted length.
void * ctx
Caller-owned binding.
uint64_t size
Size observed when bound.
cb_source_read_fn read
Read-at implementation.
Caller-owned state for one independent trace pass.
uint32_t page
Stateful generator page.
uint64_t source_offset
Next source byte offset.
size_t read_count
Valid read-ahead bytes.
uint64_t fingerprint
Captured pass fingerprint.
char line[k_cb_trace_line_capacity]
Bounded line assembly.
const cb_trace_t * trace
Bound immutable descriptor.
uint64_t rng
Generator state.
size_t read_at
Read-ahead cursor.
uint32_t hot
Stateful hot-window base.
uint8_t read_buffer[k_cb_trace_read_capacity]
Bounded read-ahead.
uint64_t index
Accesses emitted.
const char * name
Stable display name.
cb_trace_kind_t kind
Generator/parser selection.
cb_source_t source
Captured source binding, when selected.
uint64_t fingerprint
Bound captured-content fingerprint.
char name_storage[k_cb_trace_name_capacity]
Captured-name copy.
uint64_t n
Valid access count.
static bool internal_parse_trace_line(const char *line, uint32_t *object_id, uint32_t *page)
Parse one captured decimal object/page record.
static uint64_t internal_rng(uint64_t *state)
Advance a deterministic trace pseudo-random generator.
cb_io_status_t cb_trace_cursor_next(cb_trace_cursor_t *cursor, cb_key_t *key, bool *done)
Emit the next key.
@ k_rng_seed_mixed_a
Mixed hot-phase seed.
@ k_rng_seed_mixed_b
Mixed scan-phase seed.
@ k_rng_seed_toc
Jump workload seed.
@ k_rng_seed_reread
Reread workload seed.
@ k_rng_seed_random
Random workload seed.
@ k_cb_hash_prime
FNV-1a multiplication.
@ k_cb_hash_offset
FNV-1a offset basis.
static uint32_t internal_rand_below(uint64_t *state, uint32_t span)
Select a deterministic pseudo-random value below a bound.
cb_io_status_t cb_trace_cursor_finish(const cb_trace_cursor_t *cursor)
Validate a captured pass against its bound count and fingerprint.
static cb_io_status_t internal_trace_captured_next(cb_trace_cursor_t *cursor, cb_key_t *key, bool *done)
Emit the next key from a captured decimal trace.
static cb_io_status_t internal_trace_read_byte(cb_trace_cursor_t *cursor, uint8_t *out, bool *eof)
Pull one byte through the captured-source read-ahead buffer.
cb_io_status_t cb_trace_cursor_open(const cb_trace_t *trace, cb_trace_cursor_t *cursor)
Reset a cursor for an independent pass over a trace.
static cb_key_t internal_trace_synthetic_next(cb_trace_cursor_t *cursor)
Emit one key from the selected synthetic workload generator.
static cb_key_t internal_trace_scan_key(uint64_t index, bool huge)
Generate one scan-resistant hot-set-plus-scan workload key.
@ k_cb_mixed_phase
Accesses per mixed phase.
@ k_cb_obj_book
Synthetic book object key.
@ k_cb_tile_span
Scroll workload page span.
@ k_cb_pct_full
Complete percentage denominator.
@ k_cb_sr_hot_pass
Hot passes per scan-resistant run.
@ k_cb_footprint
Ordinary working-set pages.
@ k_cb_huge_hot_pass
Huge workload hot passes.
@ k_cb_huge_scan
Huge workload scan pages.
@ k_cb_huge_footprint
Huge workload working-set pages.
@ k_cb_accesses
Ordinary workload access count.
@ k_cb_obj_comic
Synthetic comic object key.
@ k_cb_reread_pct
Reread hot-set percentage.
@ k_cb_sr_scan
Scan pages per resistant run.
@ k_cb_hot_pages
Ordinary reread hot-set pages.
@ k_cb_jump_pct
Random-jump percentage.
@ k_cb_sr_hot
Scan-resistant hot-set pages.
@ k_cb_huge_hot
Huge workload hot-set pages.
@ k_rng_shift_a
First xorshift distance.
@ k_cb_key_high_shift
Object-key high-word shift.
@ k_cb_base_dec
Captured decimal parser radix.
@ k_rng_shift_b
Middle xorshift distance.
@ k_rng_shift_c
Final xorshift distance.
static uint64_t internal_trace_hash(uint64_t hash, cb_key_t key)
Fold one cache key into the captured-trace fingerprint.
cb_io_status_t cb_trace_bind(const cb_source_t *source, const char *name, size_t name_length, cb_trace_t *out)
Validate and bind one captured decimal <object> <page> source.
void cb_traces_synthetic(cb_trace_t out[k_cb_synthetic_trace_count])
Populate the fixed built-in corpus without acquiring storage.
Resettable, allocation-free access streams for cache_bench.
@ k_cb_trace_name_capacity
Captured trace display-name bound.
@ k_cb_synthetic_trace_count
Fixed corpus size.
cb_trace_kind_t
Workload implementation selected by a trace descriptor.
@ k_cb_trace_seq
Sequential page walk.
@ k_cb_trace_mixed
Alternating access phases.
@ k_cb_trace_reread
Hot-set reread workload.
@ k_cb_trace_scroll
Repeated scrolling window.
@ k_cb_trace_huge
Oversized hot-set and scan.
@ k_cb_trace_captured
Caller-injected captured accesses.
@ k_cb_trace_scan
Hot-set plus streaming scan.
@ k_cb_trace_jumps
Mostly sequential with jumps.
@ k_cb_trace_random
Uniform pseudo-random accesses.