본문으로 건너뛰기
AI NEWS JOURNAL
Hacker News Show HNAI NEWS / JOURNAL

Show HN: Nino – Fastest C# serializer, safe on untrusted input, also TS/Go/Rust

Nino is a source-generated binary serializer for C#, and as far as we know the fastest one. In the same BenchmarkDotNet run on GitHub runners against MemoryPack 1.21.4, it serializes classes and polymorphic types 3.5–7.2x faster and deserializes them 1.7–2.1x faster (arrays of unmanaged structs are on par). Deserializing into existing objects allocates nothing. Reproduce: https://nino.xgamedev.net/en/docs/v4/benchmarksIt is built to read bytes you do not trust: lengths are checked before allocating, depth is bounded, hash flooding is limited, and the read paths are fuzzed in CI.The bytes are a spec, not a memory dump, so CoreCLR, Mono, IL2CPP and 32-bit hosts write the same bytes, and runtimes for TypeScript, Go and Rust pass the same conformance corpus.Trade-offs: positional by default (VersionTolerant or Keyed for stored data), a 4-byte type id on polymorphic values, no System.Type, needs C# 9 and Roslyn 4.3+.Docs: https://nino.xgamedev.net Comments URL: https://news.ycombinator.com/item?id=50413601 Points: 1 # Comments: 0

번역 서비스가 일시 중지되어 원문을 표시합니다.

The fastest binary serializer for C#. Source-generated, zero-allocation, thread-safe and safe on untrusted input. For .NET, Unity, Godot and HybridCLR, with the same bytes on every platform and runtime, Go, Rust and TypeScript included. 🌐 Website · 🚀 Getting Started · What's new in v4 · Benchmarks · 中文 Why Nino Fastest. Up to 7.2× faster serialization than MemoryPack, and up to 9.5× faster deserialization into existing objects. Benchmarks Safe on untrusted input. Crafted bytes cannot crash the process, read past the input, allocate out of proportion or name a type to create; every invalid input throws one NinoDataException. Untrusted data Zero allocation. Serialize into an IBufferWriter, deserialize into existing or pooled objects: nothing allocated per call, thread-safe, with no locks on the hot path. Zero allocation Everything at compile time. No reflection, no IL emit, no registration, no init call: works on IL2CPP, Native AOT and HybridCLR hot updates, and compiles up to 221× faster than v3. Platforms The same bytes everywhere. Identical bytes on every runtime and CPU, and from Go, Rust and TypeScript through the code nino-gen writes for your types. Other languages Rich types that evolve. Polymorphism without tags, keyed and version-tolerant types, reference tracking, every BCL collection. Supported types Mistakes caught as you type. 33 analyzer diagnostics, many with a one-click fix. Analyzers dotnet add package Nino --prerelease # .NET and Godot: the runtime and the generator openupm add com.jasonxudeveloper.nino # Unity 2022.3+ Nino v4 is a prerelease, so --prerelease is required: without it NuGet installs 3.9.x, which cannot read or write v4 data. Optional packages: Nino.Immutable (System.Collections.Immutable), Nino.AspNetCore (MVC formatters, Minimal API bodies and results), Nino.Codegen (your types as TypeScript, Go or Rust after each build; Nino.Codegen.Tool is the same as the nino-gen command). Installation for .NET, Unity and Godot. Quick start using Nino.Core; [NinoType] public sealed class Order { public long Id; public string Customer; public List Lines; } byte[] bytes = NinoSerializer.Serialize(order); Order copy = NinoDeserializer.Deserialize(bytes); NinoDeserializer.Deserialize(bytes, ref copy); // fills the same instance in place Polymorphism needs no tags: a value declared as its base is read back as its runtime type. [NinoType] public abstract class Message { public int Seq; } [NinoType] public sealed class Chat : Message { public string Text; } byte[] bytes = NinoSerializer.Serialize(new Chat { Text = "hi" }); Message msg = NinoDeserializer.Deserialize(bytes); // a Chat again Next: your first types, evolving data, reference tracking, pooling and the advanced guides. AI coding assistants Nino ships a skill for Claude Code, Codex, Cursor, Copilot and other agents: npx skills add JasonXuDeveloper/Nino The nino-serialization skill teaches your assistant to declare [NinoType]s, pick the format for data that outlives a release, use the fast and zero-allocation forms, and fix every NINO diagnostic. The docs are written for models too: llms.txt, llms-full.txt, and every page as Markdown (add .md to its URL). Benchmarks BenchmarkDotNet 0.15.8, .NET 10.0.14, server GC, Intel Xeon 6973P-C 3.54 GHz; Nino v4 and MemoryPack 1.21.4 in one run, Nino 3.3.13 from NuGet directly before it on the same machine. Payloads are about the same size (SimpleClass: 1,069 bytes in v4, 1,152 in v3, 1,148 in MemoryPack). Every case and the method: docs/v4-benchmarks.md; the notes of each release carry that release's numbers. Every case, Arm64, MessagePack and protobuf-net: .NET benchmarks; Unity with Burst; Go, Rust and TypeScript. Arrays of tuples and structs and string conversion use AVX-512, AVX2, SSSE3, Arm64 and WebAssembly SIMD (Burst kernels in Unity), with portable code writing the same bytes elsewhere: SIMD. Built for Compared with MemoryPack MemoryPack's README now calls it "a high-performance serialization format for trusted data only" (MemoryPack README); Nino is built for data from network peers and user files (details). While benchmarking we found three types MemoryPack 1.21.4 does not round-trip (BigInteger, BitArray on .NET 10, tuples between runtimes); Nino writes them by value. The full comparison covers them, what MemoryPack has that Nino does not, and how to switch. Also compared: MessagePack and protobuf-net. v4 vs v3 v4 is a rewrite of the runtime and the generator. Its binary format is not compatible with v3. Everything new: what's new in v4, the changelog and the migration guide; internals are in docs/v4-design.md. Contributing Issues and pull requests are welcome. CONTRIBUTING.md covers building, the test matrix and releasing. MIT License · Made by JasonXuDeveloper

자료 출처

원문 읽기 ↗

관련 주제

← 전체 소식 이어 읽기