Skip to content

v4.0.0-rc.10

Pre-release
Pre-release

Choose a tag to compare

@github-actions github-actions released this 13 Nov 13:14
· 365 commits to main since this release

Install: dotnet add package Nino --version 4.0.0-rc.10 (Unity package: 4.0.0-preview.210)

Other languages: go get github.com/JasonXuDeveloper/Nino/runtimes/go/v4@v4.0.0-rc.10, cargo add nino-serialization@=4.0.0-rc.10, npm install nino-serialization@4.0.0-rc.10.

New

  • NinoDeserializer.Deserialize<T>(in ReadOnlySequence<byte>) and Deserialize<T>(in ReadOnlySequence<byte>, ref T) read what a PipeReader or gRPC hands you: one segment in place, several copied once into a pooled buffer.
  • A layout baseline ([assembly: NinoLayouts] in NinoLayouts.cs, created by an IDE refactoring or nino-gen layouts) makes the analyzer report, as you type, any change to a saved or sent type that breaks old data or old builds (NINO034), loses data silently (NINO035) or needs care (NINO036), with code fixes to undo or accept it; nino-gen layouts --check does the same in CI.
  • NinoSerializer.Serialize(value, stream) / SerializeAsync and NinoDeserializer.Deserialize<T>(stream) (also ref value) / DeserializeAsync<T>, with boxed forms: the same bytes as the span APIs with no framing, through pooled buffers, a read taking the stream to its end; intercepted calls go straight to the generated formatter (async forms not in the netstandard2.0 build).
  • [NinoOnSerializing], [NinoOnSerialized], [NinoOnDeserializing] and [NinoOnDeserialized] mark methods of a [NinoType] that Nino calls before and after writing and reading every value of the type (base classes first), as MemoryPack's callbacks; NINO038-NINO044 report declarations that would never be called.
  • nino-gen inspect --assembly X.dll --type Ns.Message message.bin prints every member of a Nino message with its offset, length, encoding and value (type ids, keyed entries, references and deferred bodies included), or --json; on malformed data it shows what was read and the offset and reason of the failure.
  • NinoKernels.Interleave32 lets a host register a native kernel that writes the pairs of SortedList<K,V> and other four-byte key/value collections; Unity registers a Burst one. The bytes are unchanged.
  • NinoKernels.NormalizeBoolSlots lets netstandard hosts provide native nullable-bool array and list normalization without changing their bytes or invalid-value errors.
  • NinoKernels.Interleave32Scalar, the reference a registered pair-interleave kernel must match.
  • .NET 11 support: projects targeting net11.0 use the net10.0 build of Nino.Core with every fast path, and the unit tests run on the .NET 11 runtime.
  • Each release signs the Unity package with Unity's package signing and OpenUPM publishes the signed file, so Unity 6.3 and later shows Nino as signed (#266).
  • The Unity package's Burst kernels test themselves at startup against Nino's scalar code; a kernel that throws or writes other bytes on the installed Burst is not used, and a warning names it.

Performance

  • NinoDeserializer.Deserialize<T>(stream) and DeserializeAsync read an UnmanagedMemoryStream and a MemoryMappedViewStream in place instead of copying their bytes into a pooled array.
  • BitArray writes its bits straight into the output: serializing 1,000 bits is 2.0 to 2.2x as fast on x64 and 2.5x on Arm64 Neoverse-N2 (GitHub runners, run 43212065213 against the previous main).
  • SortedList<TKey, TValue> of raw keys and values writes its pairs in one vector pass: serializing 1,000 pairs is 15.7 to 17.1x as fast on x64 and 12.3x on Arm64 Neoverse-N2, deserializing 1.9 to 2.8x (GitHub runners, run 43212065213 against the previous main).
  • Nino writes arrays and lists of raw values and fixed-size types straight into a PipeWriter, ArrayBufferWriter<byte> or any other IBufferWriter<byte> through one GetSpan of their size, instead of copying them from its scratch buffer (also ArraySegment<T>, array-backed Memory<T> and single-segment ReadOnlySequence<T> of raw values on .NET Standard 2.1 and later, and their multidimensional arrays on .NET 8 and later).
  • ILookup<TKey, TElement> is written through its groupings directly: serializing a 1,000-element lookup is 5.0 to 6.6x as fast on x64 and 4.8x on Arm64 Neoverse-N2 (GitHub runners, run 43212065213 against the previous main).
  • Serializing an ILookup or IGrouping whose groupings are lists (what ToLookup and GroupBy return, and what Nino deserializes) copies their elements in blocks instead of enumerating them, and allocates nothing.
  • Interface collections of raw elements (a ReadOnlyCollection<int>, or an IReadOnlyList<T>, ICollection<T> or IEnumerable<T> member holding an ICollection<T>) are written as one block: 16 to 23x as fast on x64 and 18.9x on Arm64 Neoverse-N2 for a ReadOnlyCollection<int> of 1,000 values (GitHub runners, run 43212065213 against the previous main).
  • Interface collections of 16 or more elements of any type are copied out once, not enumerated: an IReadOnlyList<string> of 1,000 strings serializes 1.16 to 1.32x as fast on x64 and 1.17x on Arm64 Neoverse-N2 (GitHub runners, run 43212065213 against the previous main).
  • Polymorphic collections write each subtype inline with the depth checked once per element: GenericIntBase and NonGenericBase arrays serialize 1.13 to 1.49x as fast on x64 and 1.40 to 1.46x on Arm64 Neoverse-N2 (GitHub runners, run 43212065213 against the previous main).
  • ConcurrentStack<T> of raw elements is written without allocating on every .NET from 8 on; .NET 9 and 11 used to enumerate it.
  • Writing into a caller's IBufferWriter<byte>, growing pooled buffers, copying multi-segment sequences and reading new BitArrays use Nino's block copy instead of .NET's Memmove: on GitHub's runners (AMD EPYC 7763 and 9V74, Intel Xeon 8573C, Neoverse-N2) writing an int array into an external buffer is 1.07-1.41x faster and a Memory<byte> payload 1.09-1.45x faster; other cases are on par.

Fixes

  • IsSupported and ASP.NET Core MVC recognize formatters registered after an earlier unsupported result.
  • Empty multidimensional arrays with large element types no longer throw IndexOutOfRangeException on deserialization.
  • An assembly removed from the registry while its formatter registration was failing is no longer kept alive by a strong reference.
  • Prefetching no longer calls a property getter that has a body or can dispatch to an override, so a custom getter runs only when the member is serialized.
  • Reusing Latin-1 strings preserves unchanged non-ASCII values on .NET 8 and later, including collection reads and the no-SIMD path.
  • The Go runtime's ReadShape no longer accepts a multi-dimensional array claiming more elements than the bytes left when its elements' minimum size is 0, which made generated code allocate them up front.
  • The Go runtime's readers no longer let nested collections each presize against the whole data, which let a small hostile message allocate about a thousand times its size.
  • The Rust runtime reads multi-dimensional arrays with a zero dimension after a longer one (such as new int[1000, 0]), which it rejected.
  • The TypeScript runtime and the readers nino-gen generates no longer let nested collections each presize against the whole data: a read presizes at most 16 bytes per byte of data plus 16 KB, so hostile input cannot exhaust memory.
  • T?[] and List<T?> of unmanaged T write zeros for the value of each null element, as the spec says, also when that memory held other bytes (an uninitialized or rented array); before, those bytes reached the wire.
  • Raw structs with Nullable fields write zeros for the value of each field without one, as the spec says, also when that memory held other bytes; before, those bytes reached the wire.
  • Unity 6000.6 (Burst 2.0): serializing a string of 16 or more chars no longer throws "This Exception was thrown from a function compiled with Burst" from NinoBurst.Narrow; every Burst kernel now tests one instruction set per branch, which Burst 1.8 and 2.0 both compile.
  • The package page on nuget.org shows the README as formatted Markdown instead of raw HTML tags, with the benchmark chart of the newest release.

Every change between v4 releases: Changelog.

What's Changed since v4.0.0-rc.9

672 commits

✨ Features

⚡ Performance (455)
🐛 Fixes (25)
♻️ Refactoring and cleanup (47)
📖 Documentation (37)
🧪 Tests (20)
🔧 Build, CI and dependencies (76)

Contributors

Thanks to everyone who contributed to this release: @JasonXuDeveloper

Full Changelog: v4.0.0-rc.9...v4.0.0-rc.10

📊 Benchmarks

Charts of one run on GitHub's runners; each section's full table is attached to this release, and benchmarks-manifest.json lists the files.

.NET x64: Nino v4 fastest or on par in 159 of 166 cases against every library measured (728 rows)
Real workloads .NET x64, Real workloads: time per operation
Basic types and structs .NET x64, Basic types and structs: time per operation
Polymorphism .NET x64, Polymorphism: time per operation
Nullable values .NET x64, Nullable values: time per operation
Collections and common types .NET x64, Collections and common types: time per operation
Reuse and pooling .NET x64, Reuse and pooling: time per operation
Reference tracking and version tolerance .NET x64, Reference tracking and version tolerance: time per operation
Others .NET x64, Others: time per operation

BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS, .NET 10.0.15; runners: AMD EPYC 9V74 3.69 GHz, AMD EPYC 9V45 4.33 GHz, AMD EPYC 9V45 4.20 GHz, Intel Xeon Platinum 8370C 2.80 GHz (Max: 2.73 GHz), AMD EPYC 9V74 3.68 GHz, AMD EPYC 9V45 4.52 GHz, Intel Xeon 6973P-C 3.87 GHz, AMD EPYC 7763 3.16 GHz, AMD EPYC 7763 2.60 GHz, Intel Xeon 6975P-C 2.70 GHz, AMD EPYC 7763 3.24 GHz, AMD EPYC 9V74 3.66 GHz, AMD EPYC 7763 2.58 GHz. The full table: dotnet-x64.md.

.NET Arm64: Nino v4 fastest or on par in 159 of 166 cases against every library measured (728 rows)
Real workloads .NET Arm64, Real workloads: time per operation
Basic types and structs .NET Arm64, Basic types and structs: time per operation
Polymorphism .NET Arm64, Polymorphism: time per operation
Nullable values .NET Arm64, Nullable values: time per operation
Collections and common types .NET Arm64, Collections and common types: time per operation
Reuse and pooling .NET Arm64, Reuse and pooling: time per operation
Reference tracking and version tolerance .NET Arm64, Reference tracking and version tolerance: time per operation
Others .NET Arm64, Others: time per operation

BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS, .NET 10.0.15; runner: Neoverse-N2. The full table: dotnet-arm64.md.

v3 3.3.13 vs v4 (.NET x64, same runners): v4 faster in 101 of 137 cases, on par in 22 (median 2.2× faster)

BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS, .NET 10.0.15; runners: AMD EPYC 9V74 3.68 GHz, AMD EPYC 9V45 4.21 GHz, AMD EPYC 9V45 4.23 GHz, AMD EPYC 9V74 3.69 GHz, Intel Xeon Platinum 8370C 2.80 GHz (Max: 3.40 GHz), AMD EPYC 9V45 4.34 GHz, AMD EPYC 9V74 3.66 GHz, AMD EPYC 9V74 3.70 GHz, Intel Xeon 6973P-C 4.15 GHz, AMD EPYC 7763 2.69 GHz, Intel Xeon 6975P-C 2.70 GHz, AMD EPYC 7763 2.62 GHz, AMD EPYC 7763 2.70 GHz, AMD EPYC 7763 2.63 GHz. The full table: dotnet-v3-x64.md.

Go runtime x64: Nino fastest or on par in 15 of 16 operations Go runtime x64

AMD EPYC 9V45, linux/amd64. The full table: runtime-go-x64.md (made from runtime-go-x64.csv).

Go runtime Arm64: Nino fastest or on par in 15 of 16 operations Go runtime Arm64

linux/arm64. The full table: runtime-go-arm64.md (made from runtime-go-arm64.csv).

Rust runtime x64: nino fastest or on par in 22 of 22 operations Rust runtime x64

a GitHub x64 runner. The full table: runtime-rust-x64.md.

Rust runtime Arm64: nino fastest or on par in 21 of 22 operations Rust runtime Arm64

a GitHub arm64 runner. The full table: runtime-rust-arm64.md.

TypeScript runtime x64: Nino fastest or on par in 21 of 24 operations TypeScript runtime x64

Node v27.0.0. The full table: runtime-typescript-x64.md (made from runtime-typescript-x64.json).

TypeScript runtime Arm64: Nino fastest or on par in 21 of 24 operations TypeScript runtime Arm64

Node v27.0.0. The full table: runtime-typescript-arm64.md (made from runtime-typescript-arm64.json).

Unity, Burst kernels in an IL2CPP player: Unity 6000.6.9f1: the Burst kernels faster in 36 of 54 operations, up to 145× Unity, Burst kernels in an IL2CPP player

Unity 2022.3.62f2, IL2CPP player (C++ Release, code generation OptimizeSpeed, stripping Minimal, not a Development build, Nino.Core Release), Linux x64, AMD EPYC 7763 64-Core Processor (4 cores), Burst 1.8.29 (x64 targets SSE2, SSE4, AVX2), kernels AVX2. Unity 6000.6.9f1, IL2CPP player (C++ Release, code generation OptimizeSpeed, stripping Minimal, not a Development build, Nino.Core Release), Linux x64, AMD EPYC 7763 64-Core Processor (4 cores), Burst 2.0.0 (x64 targets SSE2, SSE4, AVX2), kernels AVX2. The full table: unity-x64.md.

Build: v3 3.3.13 vs v4 source generator: at 1,100 types, compiling the generated code 188× faster, generated source 12× smaller Build: v3 3.3.13 vs v4 source generator

AMD EPYC 9V45, 4 cores, .NET 10.0.15, Roslyn 4.3.0.0. The full table: build-x64.md (made from build-v3-100.json, build-v3-30.json, build-v4-100.json, build-v4-30.json).