|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Eviction-policy comparison harness for the #147 memory-hierarchy decision record: the DIP seam every replacement policy implements, the fixed-frame cache it drives, and the per-run metrics it reports. More...
#include <stddef.h>#include <stdint.h>Go to the source code of this file.
Data Structures | |
| struct | cb_key_t |
| A cache key: one (object, page) the reader's vm_get touches. More... | |
| struct | cb_frame_t |
| One frame slot in the fixed page cache. More... | |
| struct | cb_cache_t |
| The fixed-capacity frame cache a policy manages. More... | |
| struct | cb_workspace_t |
| Caller-owned replay workspace and exact capacity diagnostics. More... | |
| struct | cache_policy_t |
| The replacement-policy DIP seam (the eventual firmware Layer-2 seam). More... | |
| struct | cb_result_t |
| Per-(policy, trace, size) result row. More... | |
Typedefs | |
| typedef struct cb_trace | cb_trace_t |
Functions | |
| 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. | |
| size_t | cb_replay_workspace_required (const cache_policy_t *pol, uint32_t capacity) |
| Return the exact caller workspace required by one replay. | |
Variables | |
| const cache_policy_t | g_cb_policy_slru |
| Segmented-LRU: the scan-resistant candidate (src/policy_scanresist.c). | |
| const cache_policy_t | g_cb_policy_srrip |
| SRRIP: the 2-bit re-reference-interval candidate (src/policy_scanresist.c). | |
| const cache_policy_t *const | g_cb_policies [] |
| The registered policy table (defined in src/policies.c). | |
| const uint32_t | g_cb_policy_count |
| Number of entries in g_cb_policies. | |
Eviction-policy comparison harness for the #147 memory-hierarchy decision record: the DIP seam every replacement policy implements, the fixed-frame cache it drives, and the per-run metrics it reports.
This is a HOST tool (not firmware): it replays reader access traces through each candidate Layer-2 page-cache eviction policy at swept cache sizes and reports hit rate, per-eviction worst-case frames scanned (a WCET proxy), and per-frame metadata cost, so #147 can pick the knee of the hit-rate-vs-RAM curve that also clears the WCET / MC/DC bars. Policies plug in behind cache_policy_t exactly as the eventual firmware Layer 2 will (NASA Rule 9 allows the function-pointer vtable for this DIP seam).
[Ring 7 / Tooling] {World: NS}
Definition in file cache_bench.h.
| typedef struct cb_trace cb_trace_t |
Definition at line 28 of file cache_bench.h.
| 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.
Drives trace through an exact resident-set hash while delegating only eviction ordering to pol: hits update recency/frequency via the policy callbacks, misses evict the policy's victim and load the new key into that frame. Fills out with hit/miss and worst-case scan accounting for one (policy, trace, capacity) sweep point.
| [in] | pol | Policy to exercise. |
| [in] | trace | Resettable access stream. |
| [in] | capacity | Frame count (the swept RAM budget). |
| [in,out] | workspace | Caller-provided exact replay storage. |
| [out] | out | Receives the metrics for this run. |
| 0 | The replay completed and out holds the metrics. |
| 1 | A NULL/zero argument, policy bind, source, or workspace check failed. |
pol has pick_victim bound and trace is resettable. out is non-NULL and writable. workspace.Definition at line 523 of file cache_bench.c.
References cache_policy_t::deinit, cache_policy_t::init, internal_replay_close(), internal_replay_open(), internal_replay_stream(), cache_policy_t::state_base_bytes, and cache_policy_t::state_frame_bytes.
Referenced by internal_report_summary(), and internal_report_trace_row().
| size_t cb_replay_workspace_required | ( | const cache_policy_t * | pol, |
| uint32_t | capacity ) |
Return the exact caller workspace required by one replay.
Sums aligned frame, resident-index, link, and policy-state regions with overflow guards, without touching caller storage.
| [in] | pol | Policy whose private state is included. |
| [in] | capacity | Frame count. |
| 0 | A policy/capacity check or size calculation failed. |
| other | Exact aligned workspace bytes required by cb_replay. |
pol is NULL or points to readable policy geometry. capacity is an intended fixed cache-frame count. Definition at line 333 of file cache_bench.c.
References internal_align_size(), internal_pow2_ceil(), internal_size_multiply(), k_cb_max_hash_capacity, cache_policy_t::state_base_bytes, and cache_policy_t::state_frame_bytes.
Referenced by internal_replay_open().
|
extern |
The registered policy table (defined in src/policies.c).
Definition at line 586 of file policies.c.
Referenced by internal_report_summary(), and internal_report_trace().
|
extern |
Number of entries in g_cb_policies.
Definition at line 594 of file policies.c.
Referenced by internal_report_summary(), and internal_report_trace().
|
extern |
Segmented-LRU: the scan-resistant candidate (src/policy_scanresist.c).
A probationary + protected LRU pair; one-time scans churn only the probationary segment, so the re-referenced hot set survives.
Definition at line 312 of file policy_scanresist.c.
|
extern |
SRRIP: the 2-bit re-reference-interval candidate (src/policy_scanresist.c).
Inserts predict a distant re-reference so scanned-once pages are evicted before re-referenced ones; a hit predicts immediate reuse.
Definition at line 470 of file policy_scanresist.c.