debug: which IN path fires for nsfwLevel (temporary)#199
Merged
Conversation
Traces show nsfwLevel IN takes 900ms with 41-bit accumulator — the complement path should make this instant. Adding diagnostic logging to determine whether complement or original path fires, and why. Temporary — remove after diagnosis. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
JustMaier
added a commit
that referenced
this pull request
Apr 13, 2026
nsfwLevel has 12 loaded values (6 real + stale), not 6. IN [1,2,4,8,16] = 5 keys, complement = 7 keys. Old condition (7 < 5) failed, falling through to the O(5 × acc_size) union path = 900ms at 100M. New condition: compare total complement CARDINALITY vs accumulator size. The 7 complement bitmaps have maybe ~5M total bits. Subtracting 5M bits from a 100M acc is O(5M) — microseconds. The old union path does 5× AND+OR on 100M bits = O(500M) — seconds. Condition: use complement when complement_cardinality < acc/2 OR complement_cardinality < 10M (absolute threshold for always-cheap). Also removes temporary debug eprintln from PR #199. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3 tasks
JustMaier
added a commit
that referenced
this pull request
Apr 13, 2026
nsfwLevel has 12 loaded values (6 real + stale), not 6. IN [1,2,4,8,16] = 5 keys, complement = 7 keys. Old condition (7 < 5) failed, falling through to the O(5 × acc_size) union path = 900ms at 100M. New condition: compare total complement CARDINALITY vs accumulator size. The 7 complement bitmaps have maybe ~5M total bits. Subtracting 5M bits from a 100M acc is O(5M) — microseconds. The old union path does 5× AND+OR on 100M bits = O(500M) — seconds. Condition: use complement when complement_cardinality < acc/2 OR complement_cardinality < 10M (absolute threshold for always-cheap). Also removes temporary debug eprintln from PR #199. Co-authored-by: Claude Opus 4.6 (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.
Temporary diagnostic — traces show nsfwLevel IN takes 900ms with 41-bit accumulator. The complement optimization should make this instant. This adds eprintln logging to see whether complement or original path fires, and the key values (loaded_count, complement_keys, in_keys).
Remove after diagnosis.
🤖 Generated with Claude Code