39 if ((r ==
nullptr) || (r->
reads == 0U)) {
47 "sweep-block backend=%s leg=%s block=%u frames=%u reads=%llu hits=%llu "
48 "misses=%llu evictions=%llu backend_calls=%llu backend_bytes=%llu "
49 "src_bytes=%llu backing_bytes=%llu wall_us=%llu mib_s=%.1f ns_per_read=%.1f\n",
54 (
unsigned long long)r->
reads,
55 (
unsigned long long)r->
hits,
56 (
unsigned long long)r->
misses,
91 if ((out ==
nullptr) || (cap == 0U)) {
95 (void)snprintf(out, cap,
"%uK", block / (uint32_t)
k_cbs_kib);
97 (void)snprintf(out, cap,
"%uB", block);
109 if ((rows ==
nullptr) || (be ==
nullptr) || (leg ==
nullptr)) {
112 for (uint32_t i = 0U; i < n; ++i) {
113 if ((rows[i].block_bytes == block) && (
strcmp(rows[i].backend, be) == 0) &&
114 (
strcmp(rows[i].leg, leg) == 0)) {
145 if ((r ==
nullptr) || (r->
reads == 0U)) {
159 const uint32_t* blocks,
162 if ((
cb_sink_format(sink,
"\n### `%s` -- sequential whole-object scan (leg a)\n\n", be) !=
165 "| block | frames | MiB/s | ns/read | est us/miss | backend calls | "
166 "src MiB | backing MiB |\n") !=
k_cb_io_ok) ||
168 "|------:|-------:|------:|--------:|------------:|--------------:|"
169 "--------:|------------:|\n") !=
k_cb_io_ok)) {
172 for (uint32_t i = 0U; i < nblocks; ++i) {
175 if ((s ==
nullptr) || (h ==
nullptr) || (s->
reads == 0U) || (h->
reads == 0U)) {
178 const double hit_ns = (double)h->
wall_ns / (
double)h->
reads;
179 double miss_ns = (double)s->
wall_ns - (hit_ns * (
double)s->
reads);
180 miss_ns = (s->
misses == 0U) ? 0.0 : (miss_ns / (double)s->
misses);
187 "| %5s | %6u | %5.0f | %7.1f | %11.1f | %13llu | %7.2f | %11.2f |\n",
208 const uint32_t* blocks,
211 if ((
cb_sink_format(sink,
"\n### `%s` -- same-block re-read (leg b, pure hit path)\n\n", be) !=
217 for (uint32_t i = 0U; i < nblocks; ++i) {
219 if ((h ==
nullptr) || (h->
reads == 0U)) {
225 "| %5s | %7.1f | %llu | %6llu |\n",
228 (
unsigned long long)h->
hits,
280 const uint32_t* blocks,
284 if ((out ==
nullptr) || (blocks ==
nullptr)) {
288 for (uint32_t i = 0U; i < nblocks; ++i) {
302 for (uint32_t i = 0U; i < nblocks; ++i) {
336 const char* knee_label,
337 const char* default_label,
342 "The measured knee lands on the current %s `.rabook` chunk default "
343 "(#204): keep it.\n",
350 "The knee sits BELOW the current %s default: %s already reaches "
351 "%.1f%% of peak on this backend, at a smaller per-miss inflate "
352 "latency and less RAM per frame.\n",
360 "The knee sits ABOVE the current %s default: sequential throughput "
361 "is still climbing past it; consider a larger chunk if per-miss "
373 const uint32_t* blocks,
378 return (
cb_sink_format(sink,
"\n(no rbkc-z9 sequential rows; crossover not computed)\n") ==
384 char peak_l[16] = {};
385 char knee_l[16] = {};
392 "Peak %.0f MiB/s at %s; knee (first size within %u%% of peak) at %s "
393 "(%.0f MiB/s, %.1f%% of peak).\n",
406 "Caveat: these are host numbers -- per-request cost here is only the "
407 "chunk lookup + zlib stream setup. SD-over-SPI adds real per-command "
408 "overhead (CMD17 loops, #202), which pushes the knee toward larger "
409 "blocks; the hardware leg of #208 must re-run this sweep on the bench "
410 "before shrinking the chunk size below the default.\n") ==
k_cb_io_ok)
cb_io_status_t cb_sink_format(cb_sink_t *sink, const char *format,...)
Format one bounded record and publish it atomically to the sink seam.
@ k_cb_io_ok
Operation completed.
#define RA8_PRIV
Module-private helper: shared across TUs but only inside one library.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
int strcmp(const char *s1, const char *s2)
Compare two null-terminated strings.
The computed crossover of the chunked backend's sequential sweep.
double peak_mibs
Best sequential throughput seen.
uint32_t peak_block
Size achieving the peak.
double knee_mibs
Throughput at the knee.
uint32_t knee_block
Smallest size within the knee bar.
One measured (backend, leg, block size) result row.
uint64_t evictions
ra8_vmem evictions.
const char * leg
Workload leg: "seq" or "hot".
uint64_t reads
Reader requests issued.
uint64_t backing_bytes
On-medium backing size at this block size.
uint32_t frames
Cache frames at this size (budget / block).
uint64_t wall_ns
Wall-clock time of the timed loop, in ns.
uint64_t be_calls
Backend read calls (storage commands).
uint32_t block_bytes
Swept block / frame / chunk size in bytes.
uint64_t be_bytes
Bytes delivered to the cache by the backend.
uint64_t misses
ra8_vmem misses.
const char * backend
Backend name (cbs_backend_t.name).
uint64_t hits
ra8_vmem hits.
uint64_t src_bytes
Raw medium bytes moved (compressed for RBKC).
Module-private seams shared by the #208 sweep translation units.
@ k_cbs_ns_per_us
Nanoseconds per microsecond.
@ k_cbs_kib
Bytes per KiB (block-size labels).
@ k_cbs_knee_pct
%% of peak throughput that names the knee.
@ k_cbs_default_chunk
#204 .rabook chunk-size default.
@ k_cbs_req_bytes
Reader request grain (divides every size).
RA8_PRIV int priv_print_seq_table(cb_sink_t *sink, const cbs_row_t *rows, uint32_t nrows, const char *be, const uint32_t *blocks, uint32_t nblocks)
Implementation of priv_print_seq_table() – Ch 23.2 miss-cost split.
static const double s_cbs_ns_per_s_f
Nanoseconds per second as a double, for throughput maths.
static RA8_INTERNAL void internal_block_label(uint32_t block, char *out, size_t cap)
Format a block size as a short label ("512B", "64K") into out.
static const double s_cbs_mib_f
Bytes per MiB as a double, for throughput maths.
RA8_PRIV int priv_print_crossover(cb_sink_t *sink, const cbs_row_t *rows, uint32_t nrows, const uint32_t *blocks, uint32_t nblocks)
Implementation of priv_print_crossover() – knee verdict prose.
static RA8_INTERNAL double internal_row_mibs(const cbs_row_t *r)
Delivered-payload throughput of a row in MiB/s.
RA8_PRIV int priv_print_hot_table(cb_sink_t *sink, const cbs_row_t *rows, uint32_t nrows, const char *be, const uint32_t *blocks, uint32_t nblocks)
Implementation of priv_print_hot_table() – pure hit-path table.
static RA8_INTERNAL bool internal_find_knee(const cbs_row_t *rows, uint32_t nrows, const uint32_t *blocks, uint32_t nblocks, cbs_knee_t *out)
Locate the rbkc-z9 sequential throughput peak and knee.
RA8_PRIV int priv_print_row(cb_sink_t *sink, const cbs_row_t *r)
Implementation of priv_print_row() – one key=value line.
static RA8_INTERNAL int internal_print_verdict(cb_sink_t *sink, const cbs_knee_t *knee, const char *knee_label, const char *default_label, double knee_pct)
Publish the knee/default relationship as one bounded paragraph.
static const double s_cbs_ns_per_us_f
Nanoseconds per microsecond as a double, for latency maths.
static RA8_INTERNAL const cbs_row_t * internal_find_row(const cbs_row_t *rows, uint32_t n, const char *be, const char *leg, uint32_t block)
Find the row for (backend, leg, block), or NULL.
static const double s_cbs_pct_f
100.0 as a double, for percentage maths.