diff --git a/src/nimcso/bitArrayAutoconfigured.nim b/src/nimcso/bitArrayAutoconfigured.nim index 74867b2..be210cb 100644 --- a/src/nimcso/bitArrayAutoconfigured.nim +++ b/src/nimcso/bitArrayAutoconfigured.nim @@ -32,6 +32,10 @@ func divUp(a, b: int): int = const lenInt64 = elementN.divUp(64) echo "Using ", lenInt64, " uint64s to store ", elementN, " elements." +# Side Note: There is a good reason to use uint64 even if the problem is smaller. The reason is performance. A 64-bit CPU is much better at handling 64-bit numbers; thus even if you hard-code the type +# of the bit array values to be uint8 or uint16, the compiler will likely align them to fill 64-bit boundaries anyways, so there won't be any memory savings, while it will be slightly slower. E.g., +# [1, uint64] -> CPU Time [Expanding to elementN nodes 1000 times from empty] 1011.2us | -as with default config.yaml at step 24 -> 222.3 MB RAM +# [3, utin16] -> CPU Time [Expanding to elementN nodes 1000 times from empty] 1049.2us | -as with default config.yaml at step 24 -> 223.7 MB RAM type BitArray* = object ## Creates an array of bits all packed in together.