Skip to content

Comments

define SmallHashMap in spacetimedb_data_structures#4136

Merged
Centril merged 1 commit intomasterfrom
centril/small-hash-map
Jan 27, 2026
Merged

define SmallHashMap in spacetimedb_data_structures#4136
Centril merged 1 commit intomasterfrom
centril/small-hash-map

Conversation

@Centril
Copy link
Contributor

@Centril Centril commented Jan 27, 2026

Description of Changes

Defines SmallHashMap in spacetimedb_data_structures.
The data structure is a hybrid map that is backed by a vector and linear scan for the first M elements.
Then it falls back into a normal hash map.
For the first N elements, where N < M, the vector is stored inline. That is, the vector is a SmallVec<[(K, V); N>.
The structure is optimized for access patterns where the keys and values are accessed together,
therefore, keys and values are not stored separately.

API and ABI breaking changes

None, just additive.

Expected complexity level and risk

1

Testing

A comprehensive proptest suite is added for the datastructure.

@Centril Centril force-pushed the centril/small-hash-map branch from 31c6ed4 to a98b1be Compare January 27, 2026 13:11
@Centril Centril enabled auto-merge January 27, 2026 13:13
@Centril Centril added this pull request to the merge queue Jan 27, 2026
Merged via the queue into master with commit 8348151 Jan 27, 2026
27 of 28 checks passed
@Centril Centril deleted the centril/small-hash-map branch January 27, 2026 16:08
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.

2 participants