Repository navigation
defk-vcx.2: measure Elixir mode at small sizes; it is never the fast side - #79
Merged
Merged
Conversation
…side A bench (bench/elixir_mode.exs) times two read-only hash kernels, one kernel with writes and two no-loop kernels three ways: the native kernel, its Elixir mode and the example's optimised Elixir, at 1 B to 1 KiB. Elixir mode is 7-17x the kernel at 1 B and 12-15x on a kernel with no loop (its entry alone is ~230 ns), 1.6-3.4x the optimised Elixir on reads and 100-200x on writes. No size-based switch; no decision ticket. Recorded as docs/performance.md 5.14.
This was referenced Oct 22, 2026
DanielLuning
pushed a commit
that referenced
this pull request
Oct 22, 2026
…nd docs/performance.md 5.14. Elixir mode is 7-17x the kernel at 1 B, 12-15x on a no-loop kernel (entry ~230 ns), 1.6-3.4x the optimised Elixir on reads, 100-200x on writes. No size-based switch, no decision ticket filed; the ticket stays in progress until the merge."
DanielLuning
pushed a commit
that referenced
this pull request
Oct 22, 2026
…ters rank in declaration order, so base <= length(x) bounds base and base + idx[j] drops its overflow check; the table of checks and the numbers are docs/performance.md 6.45. Guarded gather loop 0.75 ns per term (was 0.9-1.1); compiler +0.5% work. Stays in progress until the merge."
DanielLuning
pushed a commit
that referenced
this pull request
Oct 22, 2026
…one countdown instead of two counters; fuzzy_search +30% -> +16%, Keccak unchanged (its 12 spills are the saves (8) and the resume dispatch (3), not the counters; 1.3x quiet). Variants V2 (charge on entry) and V3 (no bookkeeping register) measured, not adopted. Tick gap unchanged, mix ci green. docs/performance.md 6.46. Stays in progress until the merge."
DanielLuning
added a commit
that referenced
this pull request
Oct 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
A new bench,
bench/elixir_mode.exs, times each of five kernels three ways at 1 B to 1 KiB: the native kernel, its Elixir mode (__defk_elixir__/2) and the example's optimised Elixir. Two read-only hash kernels (xxh64, SipHash-2-4 fromhashes.exs), one kernel that allocates and writes (ws_mask), and two kernels with no loop (add,clamp). The result is recorded asdocs/performance.md5.14, with a row in the myths table.The question (defk-vcx.2): defk generates Elixir beside the C for each kernel, so could a call switch to that Elixir below the crossover size? Answer: no. Elixir mode's rule (test oracle, never production, never a baseline) stands; the entry says so.
Results
Two quiet runs (other CPU 0.3-0.9 cores), medians of 7 interleaved rounds of 20,000 calls, ns per call:
Elixir mode's entry alone costs ~230 ns (argument checks, the
__defk_stats__NIF call for the budget, the process-dictionary budget), 10x a kernel call. Its loops are 1.6-3.4x the optimised Elixir on reads (a helper call per element) and 100-200x on writes (a new binary per write).The ticket's threshold for a decision ticket (Elixir mode within ~2x of the optimised Elixir) is met by the two read-only hashes from 64 B up, but a switch would replace the kernel call, and the kernel is 7-17x faster than Elixir mode at 1 B and 12-15x on a kernel with no loop at all. There is no size where the generated Elixir is the fast side, so no decision ticket is filed. Owner's call if you read the threshold differently.
How it was checked
mix cion the M-series laptop: 2305 passed, 815 excluded. The bench checks agreement of the three sides on every input before timing. No test added: the bench is not undertest/.test/stability/? No.