FlatSharp v4.0.0 Release Notes
Release Date: 2020-10-07 // over 2 years ago-
๐ Version 4 is a significant milestone for FlatSharp, and represents the culmination of a lot of work. Hope you enjoy it, to the extent that it's possible to enjoy a serialization library!
What's new?
Glad you asked!
- ๐ Support for optional/nullable scalars (tables only) (google/flatbuffers#6014)
- ๐ Support for "indexed vectors", which are Vectors that look and act like Dictionaries. Under the hood, these are sorted vectors that expose a simpler programming model, so it's no longer necessary to worry about whether a vector is sorted or not. Check out the indexed vectors sample!
- ๐ Shared strings are now supported in sorted vectors
- ๐ New method of publishing benchmark data, benchmarks extended to include .NET 5.0
Internal stuff
๐ Lots of work went into optimizing how the CLR JIT treats FlatSharp's code. Performance is increased anywhere from 10 - 30% relative to version 3.3.1.
- Much of this improvement was changes to allow the JIT to elide virtual function calls when invoking methods on SpanReader and InputBuffer. More background is available here: dotnet/runtime#32815
- Other changes involved removing some unnecessary branches and function calls on hot paths
๐ FlatSharp's backend was completely rewritten to be more modular, so that future types can be supported more easily. It is now possible (though not advised) to write your own plugins. This amounted to a rewrite of a large part of the code.
๐ฅ Breaking Changes
FlatSharp adheres to semantic versioning, and there are breaking public API changes in version 4:
SpanWriter
has been changed from aclass
to astruct
. It is no longer inheritable. A newISpanWriter
interface has been introduced should you wish to provide your own.UnsafeSpanWriter
remains a class, but is sealed.- ๐ The base class
InputBuffer
has been removed. It has been replaced withIInputBuffer
ArrayInputBuffer
,MemoryInputBuffer
,ReadOnlyMemoryInputBuffer
, and the unsafe variants remain the same.
- ๐ Support for memory vectors has been dropped for all types but
byte
. This was to address a design oversight where precompiled serializers would produce incorrect results when running on big-endian platforms.Memory<byte>
andReadOnlyMemory<byte>
remain supported.