ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
cache_bench.h
Go to the documentation of this file.
1
23#pragma once
24
25#include <stddef.h>
26#include <stdint.h>
27
28typedef struct cb_trace cb_trace_t;
29
31typedef struct {
32 uint32_t object_id;
33 uint32_t page;
34} cb_key_t;
35
37typedef struct {
39 bool live;
40 uint8_t meta[16];
42
57
59typedef struct {
60 uint8_t* data;
61 size_t capacity;
62 size_t required;
63 size_t high_water;
65
75typedef struct {
76 const char* name;
77 size_t meta_bytes;
81 int (*init)(cb_cache_t* c);
83 void (*deinit)(cb_cache_t* c);
85 void (*on_access)(cb_cache_t* c, uint32_t frame);
87 void (*on_insert)(cb_cache_t* c, uint32_t frame);
93 uint32_t (*pick_victim)(cb_cache_t* c, uint32_t* scanned);
95
97typedef struct {
98 uint64_t accesses;
99 uint64_t hits;
100 uint64_t evictions;
101 uint32_t worst_scan;
102 uint64_t total_scan;
104
132int cb_replay(const cache_policy_t* pol,
133 const cb_trace_t* trace,
134 uint32_t capacity,
135 cb_workspace_t* workspace,
136 cb_result_t* out);
137
154size_t cb_replay_workspace_required(const cache_policy_t* pol, uint32_t capacity);
155
165
175
177extern const cache_policy_t* const g_cb_policies[];
179extern const uint32_t g_cb_policy_count;
const cache_policy_t *const g_cb_policies[]
The registered policy table (defined in src/policies.c).
Definition policies.c:586
int cb_replay(const cache_policy_t *pol, const cb_trace_t *trace, uint32_t capacity, cb_workspace_t *workspace, cb_result_t *out)
Replay an access trace through one policy at a fixed capacity.
const cache_policy_t g_cb_policy_srrip
SRRIP: the 2-bit re-reference-interval candidate (src/policy_scanresist.c).
size_t cb_replay_workspace_required(const cache_policy_t *pol, uint32_t capacity)
Return the exact caller workspace required by one replay.
struct cb_trace cb_trace_t
Definition cache_bench.h:28
const cache_policy_t g_cb_policy_slru
Segmented-LRU: the scan-resistant candidate (src/policy_scanresist.c).
const uint32_t g_cb_policy_count
Number of entries in g_cb_policies.
Definition policies.c:594
The replacement-policy DIP seam (the eventual firmware Layer-2 seam).
Definition cache_bench.h:75
size_t meta_bytes
Per-frame metadata actually used (RAM cost).
Definition cache_bench.h:77
void(* on_access)(cb_cache_t *c, uint32_t frame)
A resident key was just hit at frame (update recency/freq).
Definition cache_bench.h:85
const char * name
Policy name for the report table.
Definition cache_bench.h:76
void(* on_insert)(cb_cache_t *c, uint32_t frame)
frame was just (re)populated with a freshly-loaded key.
Definition cache_bench.h:87
void(* deinit)(cb_cache_t *c)
Release policy state.
Definition cache_bench.h:83
size_t state_base_bytes
Fixed policy workspace bytes.
Definition cache_bench.h:78
size_t state_frame_bytes
Additional bytes per frame.
Definition cache_bench.h:79
uint32_t(* pick_victim)(cb_cache_t *c, uint32_t *scanned)
Choose a live frame to evict.
Definition cache_bench.h:93
int(* init)(cb_cache_t *c)
Allocate + init policy state for a cb_cache_t.
Definition cache_bench.h:81
The fixed-capacity frame cache a policy manages.
Definition cache_bench.h:50
cb_frame_t * frames
capacity frame slots.
Definition cache_bench.h:51
size_t policy_workspace_bytes
Bytes available at the storage.
Definition cache_bench.h:55
void * policy_data
Policy-private state (rings, stacks, sketch).
Definition cache_bench.h:53
uint32_t capacity
Number of frame slots (the RAM budget knob).
Definition cache_bench.h:52
void * policy_workspace
Caller-provided policy-state storage.
Definition cache_bench.h:54
One frame slot in the fixed page cache.
Definition cache_bench.h:37
cb_key_t key
Resident key, valid only when live is true.
Definition cache_bench.h:38
uint8_t meta[16]
Per-policy scratch (ref bits, RRPV, list links).
Definition cache_bench.h:40
bool live
true: slot holds a resident page.
Definition cache_bench.h:39
A cache key: one (object, page) the reader's vm_get touches.
Definition cache_bench.h:31
uint32_t object_id
Opaque object handle (book / archive / font).
Definition cache_bench.h:32
uint32_t page
Page index within the object (offset / page-size).
Definition cache_bench.h:33
Per-(policy, trace, size) result row.
Definition cache_bench.h:97
uint64_t hits
Resident-set hits.
Definition cache_bench.h:99
uint32_t worst_scan
Max frames scanned in any eviction.
uint64_t evictions
pick_victim calls.
uint64_t total_scan
Sum of frames scanned (avg proxy).
uint64_t accesses
Total accesses replayed.
Definition cache_bench.h:98
Named resettable trace; captured bytes remain owned by the caller.
Definition trace.h:42
Caller-owned replay workspace and exact capacity diagnostics.
Definition cache_bench.h:59
uint8_t * data
Aligned writable storage.
Definition cache_bench.h:60
size_t required
Exact bytes required by the latest request.
Definition cache_bench.h:62
size_t high_water
Largest successfully provisioned request.
Definition cache_bench.h:63
size_t capacity
Supplied bytes.
Definition cache_bench.h:61