bytes: document null termination - #4
Open
timbertson wants to merge 4 commits into
Open
Conversation
TimWhiting
added a commit
that referenced
this pull request
Sep 8, 2026
A process-lifetime static has a stuck refcount (RC_STUCK == INT32_MIN), on which dup and drop are semantically no-ops. But both are negative, so kk_block_dup/kk_block_drop sent them down the `rc <= 0` path into the out-of-line kk_block_check_dup/kk_block_check_drop -- every dup and every drop of a static cost a real call to do nothing. Those two helpers were #2 and #4 by self time (7.0% and 4.2%) in a profile of interface parsing. Test the sticky range inline before the call. Ordinary blocks pay nothing: with rc > 0 neither branch is taken, so the new test is only ever reached on the already-slow path. The hot static is the EMPTY EVIDENCE VECTOR: @open-none0/1/2 wraps every effect operation in `evv-swap-create0(); ..; evv-set(w)`, dupping and dropping that static twice per operation. The fix is general though -- every nullary constructor and shared singleton pays the same toll. Measured: C microbench, dup+drop of a static 3.4ns -> 1.6ns C microbench, dup+drop of a normal block 2.5ns -> 2.5ns (unchanged) tail-resumptive effect operation 13.7ns -> 10.2ns (-26%) parsing 209 interfaces 56.2s -> 50.2s (-10.7%) 425 examples 0 failures; koka-community port sweep 423/17/2/0 and multimodule gate green. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Pieced together from what I learnt in koka-community/uv#4 (comment)