Skip to content

Optimize bg4 prediction #308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

hoytak
Copy link
Collaborator

@hoytak hoytak commented May 10, 2025

This PR optimizes the bg4 prediction used in the compression scheme analysis by bypassing the per-byte popcnt call, which can be quite slow. This was shown to be a bottleneck; this PR speeds this operation up.

On Arm/neon, this uses an intrinsic vector popcnt instruction, and on intel it uses a bit twiddling method to calculate the per-byte popcount on u128s that is much more efficient than subsequent popcnt calls.

@hoytak hoytak requested review from ylow and seanses May 10, 2025 00:59
@hoytak
Copy link
Collaborator Author

hoytak commented May 10, 2025

Method gives a 2x speedup.

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