Print this page
rev 2896 : 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
Summary: There is a high number of mispredicted branches associated with calling BitMap::iteratate() from within CMBitMapRO::iterate(). Implement a version of CMBitMapRO::iterate() directly using inline-able routines.
Reviewed-by:

Split Close
Expand all
Collapse all
          --- old/src/share/vm/utilities/bitMap.inline.hpp
          +++ new/src/share/vm/utilities/bitMap.inline.hpp
↓ open down ↓ 170 lines elided ↑ open up ↑
 171  171    idx_t res_offset = l_offset;
 172  172  
 173  173    // check bits including and to the _left_ of offset's position
 174  174    idx_t pos = bit_in_word(res_offset);
 175  175    idx_t res = map(index) >> pos;
 176  176    if (res != (uintptr_t)NoBits) {
 177  177      // find the position of the 1-bit
 178  178      for (; !(res & 1); res_offset++) {
 179  179        res = res >> 1;
 180  180      }
 181      -    assert(res_offset >= l_offset &&
 182      -           res_offset < r_offset, "just checking");
      181 +
      182 +    // In the following assert, checking that res_offset is strictly
      183 +    // less than r_offset is too strong. Consider the case where
      184 +    // l_offset is bit 15 and r_offset is bit 17 of the same map word,
      185 +    // and where bits [18:17:16:15] == [01:00:00:00]. The calculation
      186 +    // above would yield the offset of bit 18. All we can assert is that
      187 +    // res_offset is strictly less than size() since we know that there
      188 +    // are set bits at offsets above, but in the same map word as, r_offset
      189 +    // The bits in the range (r_offset:l_offset] are all 0.
      190 +    assert(res_offset >= l_offset && res_offset < size(), "just checking");
 183  191      return MIN2(res_offset, r_offset);
 184  192    }
 185  193    // skip over all word length 0-bit runs
 186  194    for (index++; index < r_index; index++) {
 187  195      res = map(index);
 188  196      if (res != (uintptr_t)NoBits) {
 189  197        // found a 1, return the offset
 190  198        for (res_offset = bit_index(index); !(res & 1); res_offset++) {
 191  199          res = res >> 1;
 192  200        }
↓ open down ↓ 137 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX