46typedef enum : uint32_t {
70typedef enum : uint32_t {
82typedef enum : uint64_t {
88 {16U, 32U, 48U, 64U, 96U, 128U, 192U, 256U};
95 817U, 150U, 278U, 425U, 1270U, 223U, 202U, 609U, 697U,
96 15U, 77U, 403U, 241U, 675U, 751U, 193U, 10U, 599U,
97 633U, 906U, 276U, 98U, 236U, 15U, 197U, 7U};
100typedef enum : uint32_t {
142 for (
size_t i = 0U; i < count; ++i) {
187 struct sigaction action = {.sa_handler = SIG_IGN};
188 if ((sigemptyset(&action.sa_mask) != 0) || (sigaction(SIGPIPE, &action,
nullptr) != 0)) {
259 return (span == 0U) ? 0U : (uint32_t)(
internal_gb_rng(s) % (uint64_t)span);
298static const uint32_t
s_gb_punct[] = {
' ',
'.',
',',
';',
':',
'\'',
'"',
'-',
'!',
'?'};
378 (void)
memset(cell, 0, (
size_t)cell_bytes);
463 uint64_t session_rng = (uint64_t)
k_gb_seed;
464 for (uint32_t page = 0U; page < (uint32_t)
k_gb_pages; ++page) {
465 const uint64_t page_start = session_rng;
466 uint64_t next_page = page_start;
468 uint64_t page_rng = page_start;
474 next_page = page_rng;
477 session_rng = next_page;
505 .cell_count = budget,
512 .render_ctx =
nullptr};
544 uint32_t digits = 1U;
548 for (uint32_t i = digits; i < width; ++i) {
573 const char*
const prefix[] = {
"# #147/#164 glyph-cache budget sweep\n\nWorkload: "};
599 " glyph gets\n(English letter frequencies + caps/punct/digits; body ");
613 "px)\n\n| cells | RAM @36KiB/cell | hit rate % | rasterisations |\n|------:|----------------:|-----------:|---------------:|\n");
637 const uint64_t scaled =
700 for (
size_t i = 0U; (i < count) && (error ==
k_ra8_ok); ++i) {
702 uint32_t rasters = 0U;
710 "\nWithout a cache the renderer rasterises once per glyph get (");
728 const char*
const parts[] = {
"glyph_bench: workload or output failed\n"};
static ra8_err_t internal_replay_page_glyphs(ra8_glyph_atlas_t *atlas, uint64_t *page_rng)
Replay one page's fixed glyph-access sequence against a running RNG.
gb_freq_t
Sum of s_gb_letter_freq (the selection range).
@ k_gb_freq_total
Sum of the 26 letter weights above.
static void internal_log_byte(void *context, uint8_t byte)
Forward one logger byte into the bound diagnostic stream.
static uint32_t internal_gb_pick_letter(uint64_t *s)
Pick a lowercase letter codepoint weighted by English frequency.
static ra8_err_t internal_submit_access(ra8_glyph_atlas_t *atlas, uint64_t *rng)
Generate and submit one deterministic glyph access.
static uint64_t internal_gb_rng(uint64_t *s)
Advance a fixed-seed xorshift64 generator and return the new state.
static ra8_err_t internal_report_header(void)
Write the fixed report preamble and workload dimensions.
static ra8_io_stream_t s_gb_diagnostic
static ra8_err_t internal_output_init(void)
Bind process output descriptors and make broken pipes observable.
static const uint64_t s_gb_access_total
Total glyph accesses in the deterministic session.
static ra8_err_t internal_report_row(uint32_t budget, uint32_t hits, uint32_t rasters)
Write one exact table row from integer hit/miss evidence.
static uint32_t internal_gb_below(uint64_t *s, uint32_t span)
Draw a uniform pseudo-random integer in [0, span).
static ra8_io_stream_t s_gb_output
Borrowed stdout/stderr portable stream handles.
static const uint32_t s_gb_budgets[]
Swept cache budgets (cell counts).
static ra8_err_t internal_put_padded_u64(ra8_io_stream_t *stream, uint64_t value, uint32_t width)
Write one unsigned value left-padded to a fixed field width.
static const uint32_t s_gb_punct[]
A small punctuation/space repertoire (codepoints).
int main(void)
The application entry point Reset_Handler hands control to.
static ra8_err_t internal_gb_render(void *ctx, const ra8_glyph_key_t *key, uint8_t *cell, uint32_t cell_bytes, uint16_t *out_w, uint16_t *out_h)
Atlas render-on-miss callback: stand in for one rasterisation.
static uint32_t internal_gb_pick_codepoint(uint64_t *s)
Choose one codepoint for the glyph stream from the weighted mix.
gb_dim_t
Workload model dimensions (no bare literals).
@ k_gb_dec_radix
Decimal renderer radix.
@ k_gb_buckets
Hash buckets for the atlas.
@ k_gb_decimal_scale
Two decimal digits for percentages.
@ k_gb_heading_pct
% of glyphs drawn at the heading size.
@ k_gb_punct_pct
% of glyphs drawn as punctuation.
@ k_gb_hit_width
Whole-part width before .NN.
@ k_gb_cell_bytes
Bench cell size (content-irrelevant).
@ k_gb_reread_pages
Re-render each page this many times (turns).
@ k_gb_ram_width
RAM report field width.
@ k_gb_page_glyphs
Glyph draws per page (a dense page).
@ k_gb_max_budget
Largest swept atlas capacity.
@ k_gb_digit_pct
% of glyphs drawn as digits.
@ k_gb_prod_cell_kib
Production cell cost (192x192 alpha8) KiB.
@ k_gb_pct_base
Percentage base.
@ k_gb_body_px
Body text font size.
@ k_gb_heading_px
Heading font size.
@ k_gb_raster_width
Rasterization report field width.
@ k_gb_budget_width
Budget report field width.
@ k_gb_cap_pct
% of letters drawn as capitals.
@ k_gb_pages
Pages rendered in the session.
static ra8_io_stream_posix_state_t s_gb_diagnostic_posix
gb_seed_t
Deterministic xorshift64 seed.
static ra8_err_t internal_run_report(void)
Run the complete deterministic cache-budget report.
static ra8_err_t internal_write_parts(ra8_io_stream_t *stream, const char *const *parts, size_t count)
Write a fixed sequence of NUL-terminated fragments exactly.
static ra8_err_t internal_replay_workload(ra8_glyph_atlas_t *atlas)
Regenerate and replay the exact legacy session without a trace buffer.
static ra8_err_t internal_run_budget(uint32_t budget, uint32_t *out_hits, uint32_t *out_rasters)
Execute one budget against the caller-visible fixed atlas backing.
gb_const_t
xorshift64 + fill constants.
@ k_gb_ascii_az_a
ASCII 'a'.
@ k_gb_case_delta
'a' - 'A'.
@ k_gb_xs_c
xorshift shift 3.
@ k_gb_xs_b
xorshift shift 2.
@ k_gb_ascii_az_z
Letters in a-z.
@ k_gb_digits
Digit count.
@ k_gb_xs_a
xorshift shift 1.
static ra8_io_stream_posix_state_t s_gb_output_posix
Raw-descriptor adapter states for the borrowed process streams.
static gb_workspace_t s_gb_workspace
Process-lifetime semantic backing for one measured atlas.
static const uint16_t s_gb_letter_freq[26]
English letter relative frequencies, scaled to a per-mille-ish table indexed by letter (a....
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Error Code Definitions for ra8-firmware.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_comm_error
Generic communication error (use a more specific code when possible).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
void * memset(void *dst, int value, size_t n)
Fill memory with a constant byte value.
Fixed-RAM-budget glyph cache with LRU eviction (Layer 3, #147).
ra8_err_t ra8_glyph_atlas_put(ra8_glyph_atlas_t *atlas, const uint8_t *bitmap)
Release one pin on a glyph previously returned by ra8_glyph_atlas_get.
ra8_err_t ra8_glyph_atlas_stats(const ra8_glyph_atlas_t *atlas, uint32_t *out_hits, uint32_t *out_misses, uint32_t *out_evictions)
Report the atlas hit / miss / eviction counters.
ra8_err_t ra8_glyph_atlas_get(ra8_glyph_atlas_t *atlas, const ra8_glyph_key_t *key, ra8_glyph_t *out_glyph)
Get (and pin) the rendered glyph for key.
ra8_err_t ra8_glyph_atlas_init(ra8_glyph_atlas_t *atlas, const ra8_glyph_atlas_cfg_t *cfg)
Initialise a glyph atlas over caller-supplied storage.
ra8_io targetable byte-stream facade – one writer, many destinations.
ra8_err_t ra8_io_stream_puts(ra8_io_stream_t *s, const char *str)
Write a NUL-terminated string (without the NUL) to the bound sink.
ra8_err_t ra8_io_stream_put_u32(ra8_io_stream_t *s, uint32_t value)
Write value as unsigned decimal ASCII (no leading zeros).
ra8_err_t ra8_io_stream_put_u64(ra8_io_stream_t *s, uint64_t value)
Write value as unsigned 64-bit decimal ASCII without leading zeros.
ra8_err_t ra8_io_stream_putc(ra8_io_stream_t *s, char c)
Write a single byte to the bound sink.
Borrowed raw-descriptor backend for the portable byte-stream facade.
ra8_err_t ra8_io_stream_posix_init(ra8_io_stream_t *stream, ra8_io_stream_posix_state_t *state, int fd)
Bind a borrowed writable descriptor as a byte-stream sink.
The one reusable hash + pin + evict cache engine (#147, #345).
Lightweight Logging Interface for ra8-firmware.
void ra8_log_init(void)
Initialise the logging backend.
void ra8_log_set_byte_sink(ra8_log_byte_sink_fn_t fn, void *ctx)
Install (or clear) an optional byte sink for log output.
Exact caller-owned backing for the largest measured atlas.
ra8_glyph_dims_t dims[k_gb_max_budget]
Cell geometry.
uint8_t cells[k_gb_max_budget *k_gb_cell_bytes]
Bitmap cells.
ra8_keycache_cell_t meta[k_gb_max_budget]
LRU metadata.
int32_t buckets[k_gb_buckets]
Hash buckets.
ra8_glyph_key_t keys[k_gb_max_budget]
Cell keys.
Caller-supplied storage + renderer for ra8_glyph_atlas_init.
Glyph-cache state (caller-owned; treat as private).
Per-cell user descriptor: the rendered glyph dimensions.
Identifies one rendered glyph.
A pinned view of a cached glyph bitmap returned by ra8_glyph_atlas_get.
const uint8_t * bitmap
Glyph coverage bitmap (width*height bytes).
Caller-owned state retained by one POSIX stream binding.
Caller-allocated byte-stream handle binding a sink to its context.
Per-cell link metadata (one caller-owned array entry per cell).