Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-16096

ResourceId constructors use operator% where they should use operator& for bit masking

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.8.0-rc1
    • Affects Version/s: 2.8.0-rc0
    • Component/s: Concurrency
    • Labels:
      None
    • Fully Compatible
    • ALL

      The ResourceId constructors hash a resource name and then compute that value modulo 0x1fffffffffffffffULL. The author almost certainly meant to mask off the high order 3 bits, which is achieved by taking the bitwise and (operator&) rather than the unsigned integer modulus (operator%). Since operator% with this constant requires integer division, it is computationally far more expensive than necessary, but it may not be affecting the correctness of operation.

      ResourceId should probably be rewritten entirely in terms of bit masking, instead of a mix of bit masking and narrow bit field structures.

            Assignee:
            geert.bosch@mongodb.com Geert Bosch
            Reporter:
            schwerin@mongodb.com Andy Schwerin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: