facebook / facebook/folly

AtomicBitSet inconsistent size with bitset

Open
#1,012 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
30.5k
Forks
5.9k
PR merge metrics
No merged PRs in 30d

Description

`std::bitset` specifies N as the (minimum) number of bits in the bitset (there is a small additional capacity due to rounding storage up to a block width).

https://github.com/facebook/folly/blob/1fd24252eb182190b3c0a3061c914e4d61a38b8c/folly/AtomicBitSet.h#L34-L35

https://github.com/facebook/folly/blob/1fd24252eb182190b3c0a3061c914e4d61a38b8c/folly/AtomicBitSet.h#L119

`AtomicBitSet` uses N as the number of blocks in the bitset, thereby making it have anywhere between `N*4` to `N*8` actual bits (depending on the block size used), which seems inconvenient. It also means that its actual storage size is significantly larger than the consumer might have expected if they had assumed that N was the number of bits, as in `std::bitset`.

`size()` similarly returns this number of blocks instead of the number of bits as `std::bitset` does.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.