apache / apache/accumulo

Optimization for some mod ops

Open
#6,095 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
1.2k
Forks
487
Avg merge
4d 5h
Merged PRs (30d)
13

Description

The following optimization can be made to mod operations. This can be applied where applicable with a comment explaining the original operation for clarity

`n % x === n & (x-1)` when x is a power of 2 but bitwise AND is much faster

_Originally posted by @kevinrr888 in https://github.com/apache/accumulo/pull/6025#discussion_r2742486786_

Contributor guide

Open the contributing guide

Research direction

No files, tests, or entry points are named. Search the Java code for modulo operations and identify cases where the divisor is a power of two, then verify that the suggested bitwise operation preserves behavior. Done means applicable cases use the optimization with a comment explaining the original operation and the relevant tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
performance
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.