-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[@parcel/graph] SharedTypeMap should dynamically select the store data type #8621
Comments
I like this idea! The heuristic seems simple enough. This might just work for edges in particular, since they are re-hashed and copied into the new array on resize. I think it has some conceptual overlap with another potential optimization, too: Edge types are always going to fit into 8 bits (or could be enforced as such), so we could save a fair amount of space if we used |
@lettertwo |
Yes, in most case(may 99.99%) edeg type is less than 255, so use u8 rather than u32 can save more memory, but this adds more |
The only usage is
which imports parcel/packages/core/utils/src/shared-buffer.js Lines 1 to 24 in c3bbe0a
I think we could just copy that over into the graph package. |
🙋 feature request
SharedTypeMap and SerializedAdjacencyList use Uint32Array to store data, but in most case Uint16Array is enough, so if can dynamically select the store data type, it's can save half memory to store and transform?
🤔 Expected Behavior
Dynamically select the AdjacencyList's store data type
😯 Current Behavior
The AdjacencyList's store data type is always Uint32Array, in most cases it is wasted
💁 Possible Solution
Each resize we can choose the appropriate data type(Uint32Array/Uint16Array) depending on the number of nodes/edges
We can hard code Uint32Array to Uint16Array and test some usecase, find if this approach is effective by comparing
🔦 Context
None
💻 Examples
I make a sample with 100_000 nodes and edges, it looks like to be working
The text was updated successfully, but these errors were encountered: