Skip to content

perf: power of two bitwise AND - #12

Merged
HawkinWay merged 3 commits into
mainfrom
5-feature-power-of-two-bitwise-AND
Jul 26, 2026
Merged

perf: power of two bitwise AND#12
HawkinWay merged 3 commits into
mainfrom
5-feature-power-of-two-bitwise-AND

Conversation

@HawkinWay

Copy link
Copy Markdown
Owner

Overview

This PR optimizes the index wrapping logic in RingBuffer by enforcing
power-of-two capacities and replacing runtime modulo operations with
bitwise masking.

Observation

The optimization reduces index calculation overhead by eliminating
runtime modulo operations.

The overall performance impact depends on workload and system conditions,
because atomic synchronization and cache coherence remain dominant factors
in SPSC throughput.

@HawkinWay
HawkinWay merged commit e5ffb2e into main Jul 26, 2026
3 checks passed
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