P3: a non-raising sprite lookup -- target 10 is a design target, not a speed one #23

Open
opened 2026-08-02 18:33:03 -04:00 by tachikoma · 0 comments
Collaborator

Source: TODO.md, "Performance" -> "The plan", item 3 (at bbb7b8f)

Target 10: a handled, routine condition costs no more than twice the path that
succeeds.
Today it is 616.5 ns against 68.4 ns -- 9x.

The answer is not a faster error context. It is that "this character has no
sprite for this state" is a question with a boolean answer, and reporting it
through AKERR_KEY costs nine times the update it replaces.

Give akgl_character_sprite_get (src/character.c:84-94) a companion that
returns NULL without raising, then convert the three sites that raise and handle
AKERR_KEY for a routine condition:

  • akgl_actor_update -- raise src/actor.c:165, handled :172
  • actor_visible -- raise :209, handled :212-216
  • akgl_actor_render -- raise :241, handled :245-249

While there, stop akgl_actor_render looking the sprite up twice on the success
path (:241, and again inside actor_visible at :242).

Budget to move: tests/perf.c:588.

Files: src/character.c:84-94, src/actor.c:165,209,241, tests/perf.c:588


Filed by Tachikoma (Claude Code, Opus 5, 1M context)

**Source:** TODO.md, "Performance" -> "The plan", item 3 (at bbb7b8f) Target 10: *a handled, routine condition costs no more than twice the path that succeeds.* Today it is **616.5 ns against 68.4 ns -- 9x**. **The answer is not a faster error context.** It is that "this character has no sprite for this state" is a question with a boolean answer, and reporting it through `AKERR_KEY` costs nine times the update it replaces. Give `akgl_character_sprite_get` (`src/character.c:84-94`) a companion that returns `NULL` without raising, then convert the three sites that raise and handle `AKERR_KEY` for a routine condition: - `akgl_actor_update` -- raise `src/actor.c:165`, handled `:172` - `actor_visible` -- raise `:209`, handled `:212-216` - `akgl_actor_render` -- raise `:241`, handled `:245-249` While there, stop `akgl_actor_render` looking the sprite up twice on the success path (`:241`, and again inside `actor_visible` at `:242`). Budget to move: `tests/perf.c:588`. **Files:** `src/character.c:84-94`, `src/actor.c:165,209,241`, `tests/perf.c:588` --- Filed by Tachikoma (Claude Code, Opus 5, 1M context)
tachikoma added this to the 0.10.0 milestone 2026-08-02 18:33:03 -04:00
tachikoma added the performanceapi-gapblast-radius:medium labels 2026-08-02 18:33:03 -04:00
tachikoma added the status::grooming label 2026-08-02 18:49:15 -04:00
Sign in to join this conversation.