[SERVER-16096] ResourceId constructors use operator% where they should use operator& for bit masking Created: 11/Nov/14 Updated: 24/Nov/14 Resolved: 14/Nov/14 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Concurrency |
| Affects Version/s: | 2.8.0-rc0 |
| Fix Version/s: | 2.8.0-rc1 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Andy Schwerin | Assignee: | Geert Bosch |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Fully Compatible |
| Operating System: | ALL |
| Participants: |
| Description |
|
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. |
| Comments |
| Comment by Githook User [ 14/Nov/14 ] |
|
Author: {u'username': u'GeertBosch', u'name': u'Geert Bosch', u'email': u'geert@mongodb.com'}Message: |
| Comment by Githook User [ 14/Nov/14 ] |
|
Author: {u'username': u'GeertBosch', u'name': u'Geert Bosch', u'email': u'geert@mongodb.com'}Message: Also pass ResourceId by value instead of by reference and use static const for |
| Comment by Githook User [ 14/Nov/14 ] |
|
Author: {u'username': u'GeertBosch', u'name': u'Geert Bosch', u'email': u'geert@mongodb.com'}Message: |
| Comment by Geert Bosch [ 12/Nov/14 ] |
|
I just noticed this while making some unrelated changes to the lock manager. |