Files
turso/macros
Claude 0d0fa52eae macros: evaluate turso_debug_assert conditions only in debug builds
turso_debug_assert! bound its condition to a local before handing it to
debug_assert!, so release builds still evaluated every condition and
only skipped the check. Conditions that call something fallible, like
`matches!(self.page_type(), Ok(PageType::TableLeaf))` in the cell
readers, cannot be optimized away because the error path builds a
LimboError, so every rowid read and every interior-cell probe of a
b-tree descent paid for a page type conversion it never used.

Put the condition inside debug_assert!, where it sits under
`if cfg!(debug_assertions)` and disappears from release code. The
antithesis build keeps the bound local, which it needs for its own
report.

Measured with callgrind, instructions per execution:
  SELECT * FROM t WHERE id = 12345:            7,878 -> 7,532 (-4.4%)
  SELECT id FROM t WHERE value = 500 LIMIT 1: 13,527 -> 13,605 (+0.6%)
  SELECT 1:                                    1,801 -> 1,813 (+0.7%)
and per row of SELECT * FROM t, the rowid read no longer converts the
page type: BTreeCursor functions 109,832,094 -> 106,632,094 over 400k
rows (-8 per row). The other two statements and the whole-scan totals
move by +-1% with the changed inlining inside Program::step, which this
change does not touch.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Feji9LAGhf6W4U2BBE6aWs
2026-09-07 10:35:29 -07:00
..