Skip to content

Conversation

@ThomasWaldmann
Copy link
Member

@ThomasWaldmann ThomasWaldmann commented Nov 9, 2024

  • RESERVED is uint32_t, so we can't assign it to a 32bit int
  • in general, instead of using C int, let's rather use size_t for array indexes and sizes. size_t is unsigned, so no problem with that. it's 32bit on 32bit platforms, 64bit on 64bit platforms.
  • exception: indexes into the kv array are always only uint32_t to save memory.

Note that due to the load factor of the hashtable, it makes sense to have hashtables with a bit more than 2^32 buckets even if the kv array is limited to less than 2^32.
If there would be close to 2^32 stored kv items, the hashtable would be approximately 2^33 buckets large (if the load factor is 0.5).

- RESERVED is uint32_t, so we can't assign it to a 32bit int
- in general, instead of using C int, let's rather use size_t for array
  indexes and sizes. size_t is unsigned, so no problem with that.
  it's 32bit on 32bit platforms, 64bit on 64bit platforms.
- exception: indexes into kv array are always only uint32_t to save memory.

Note that due to the load factor of the hashtable, it makes sense to have
hashtables with a bit more than 2^32 buckets even if the kv array is
limited to less than 2^32.

If there would be close to 2^32 stored kv items, the hashtable would be
approximately 2^33 buckets large (if the load factor is 0.5).
@ThomasWaldmann ThomasWaldmann added this to the 0.0.2 milestone Nov 9, 2024
@ThomasWaldmann ThomasWaldmann merged commit f2dd024 into master Nov 10, 2024
1 check passed
@ThomasWaldmann ThomasWaldmann deleted the fix-32bit-platforms branch November 10, 2024 00:37
@ThomasWaldmann
Copy link
Member Author

Worked for me, tested on a 32bit x86 debian12 vagrant box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant