jamescourtney / FlatSharp

Fast, idiomatic C# implementation of Flatbuffers
Apache License 2.0
510 stars 51 forks source link

Evaluate Collapsing PropertyCache and VectorCache #223

Closed jamescourtney closed 3 years ago

jamescourtney commented 3 years ago

The main difference is preallocation of vectors with vector cache. Can we meet in the middle and use a Dictionary that fills up gradually?

jamescourtney commented 3 years ago

Dictionary is too slow to be a proper replacement for an array. However, due to the work in #224, it's now possible to collapse these serialization modes.

PropertyCache, VectorCache, and VectorCacheMutable will be removed in FlatSharp 6. They will be replaced with Progressive and ProgressiveMutable. ProgressiveMutable will support write through for structs.

The semantics of Progressive deserialization are a hybrid of VectorCache and PropertyCache.

fs_preallocate will support values of Always, Never, and Default, with the following semantics:

Always Never Default
Greedy OK Error OK
Progressive OK OK OK
Lazy Error OK OK

The meaning of Default can vary contextually.

Example:

table Table (fs_serializer:"Progressive")
{
       Vector : [ OtherTable ] (fs_vector:"IIndexedVector", fs_preallocate:"Never");
}
jamescourtney commented 3 years ago

This is done -- need more benchmarking to determine if we should keep the fs_preallocate attribute or not.

jamescourtney commented 3 years ago

fs_preallocate removed.