infinispan/infinispan — pull request #2035 by maniksurtani (2013-08-29 14:35:03+00:00)
Title: Replace mod operations with bitwise AND where possible

This pull request replaces modular operations (%) with bitwise AND operations where used in a hot code path or in a loop. Modulus invokes division in most CPUs, and this is often 1 to 2 orders of magnitude slower than a bitwise AND.

Reflected in several places:

http://dhruba.name/2011/07/12/performance-pattern-modulo-and-powers-of-two/
http://scicomp.stackexchange.com/questions/187/why-is-division-so-much-more-complex-than-other-arithmetic-operations
http://disruptor.googlecode.com/files/Disruptor-1.0.pdf (Page 5, last paragraph)