FlatSharp v4.0.0 Release Notes

Release Date: 2020-10-07 // over 3 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 a class to a struct. It is no longer inheritable. A new ISpanWriter 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 with IInputBuffer
      • 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> and ReadOnlyMemory<byte> remain supported.