MessagePack for C# v2, new era of .NET Core(Unity) I/O Pipelines

Zero copy with pipeline

When thinking of the internal structure of MessagePack for C#, there are the following two method signatures to be looked at:

Theory and performance

It is often misunderstood that just using Span will increase the performance, using async/await will increase the performance.

while (await channelReader.WaitToReadAsync())
while (channelReader.TryRead(out T item))

LZ4 compression for the array

One factor in Version 2’s performance improvement over Version 1 was the new allocation where Version 1 did not use a pool for 64K or higher serialization. For the internal buffer, Version 2 uses the 32K chunk’s linked list obtained from the ArrayPool (in the case where IBufferWriter is not given externally and Version 2’s internal buffer pool is used).

AOT (Unity IL2CPP, Xamarin, UWP, CoreRT)

Since MessagePack for C# is geared for performance, it has no fallback to an easy reflection in the AOT environment and we have no desire to implement one. Instead, by generating the code in advance, the fastest serialization is achieved whenever possible in the AOT environment. From Version 2, .NET Core Tools, MSBuild Task, and Unity Editor Window have been provided for easier handling. It is now easier to use than ever before.


Much of the wonderful work was done by Andrew Arnott. I thank him again.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Yoshifumi Kawai

Yoshifumi Kawai


a.k.a. neuecc. Creator of UniRx, UniTask, MessagePack for C#, MagicOnion etc. Microsoft MVP for C#. CEO/CTO of Cysharp Inc. Live and work in Tokyo, Japan.