Skip to content

debug: which IN path fires for nsfwLevel (temporary)#199

Merged
JustMaier merged 1 commit intomainfrom
ivy/debug-complement-path
Apr 13, 2026
Merged

debug: which IN path fires for nsfwLevel (temporary)#199
JustMaier merged 1 commit intomainfrom
ivy/debug-complement-path

Conversation

@JustMaier
Copy link
Copy Markdown
Contributor

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

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 JustMaier merged commit 66660e8 into main Apr 13, 2026
1 check failed
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>
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant