Identify DotvvmProperty with systematic 32-bit IDs #1867
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
All DotvvmProperties now get assigned 32-bit IDs, which can be used for more efficient lookup and identification. The has a ID 16b + 16b structure to allow optimizing certain common operations and make the assignment consistent even when we initialize controls on multiple threads.
The ID format is (bit 0 is (id >> 31)&1, bit 31 is id&1)
All IDs are assigned sequentially, with reserved blocks at the start for the most important types which we might want to address directly in a compile-time constant.
IDs put a limit on the number of properties in a type (64k), the number of property groups (32k), and the number of property group members. All property groups share the same name dictionary, which allows for significant memory savings, but it might be limiting in obscure cases.
As property groups share the name-ID mapping, we do not to keep the GroupedDotvvmProperty instances in memory after the compilation is done. VirtualPropertyGroupDictionary will map strings directly to the IDs and back.
Shorter unmanaged IDs allows for efficient lookup in unorganized arrays using SIMD — 8 property IDs fit into a single vector register. Since controls with more than 8 properties are not common, we can actually be faster with brute force.
We should evaluate whether it makes sense to keep the custom hashtable optimized for small table. Currently, the patch still keeps this code in place. The standard Dictionary`2 is also faster when indexed with integer compared to a reference type, so the difference will be even less.
Number of other places in the framework were adjusted to address properties directly using the IDs.