msgpack-cli icon indicating copy to clipboard operation
msgpack-cli copied to clipboard

Serialization performance is very slow in .NET Core

Open neuecc opened this issue 7 years ago • 4 comments

MsgPack-Cli is extremely slow(slower than JSON.NET!) in .NET Core. I think MsgPack-Cli is using reflection based serializer in .NET Core.

public class MyClass
{
    public int MyProperty { get; set; }
}

class Program
{
    static void Main(string[] args)
    {
        var serializer = MsgPack.Serialization.SerializationContext.Default.GetSerializer<MyClass>();

        // MsgPack.Serialization.ReflectionSerializers.ReflectionObjectMessagePackSerializer`1[[]]
        Console.WriteLine(serializer.GetType().FullName);
    }
}

neuecc avatar Mar 10 '17 13:03 neuecc

Here is csproj, launch VS2017 -> Reference NuGet -> Run.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="MsgPack.Cli" Version="0.9.0-beta2" />
  </ItemGroup>

</Project>

neuecc avatar Mar 10 '17 14:03 neuecc

Same here. I was excited to find this project to improve our performance but wow for larger objects it's as bad as 8x slower to serialize versus JSON.NET...

Salgat avatar Aug 09 '18 17:08 Salgat

How large is it? I want to measure and investigate it.

yfakariya avatar Aug 09 '18 22:08 yfakariya

The size of the serialized object's file was 220MB versus 300MB serialized as a json file by JSON.NET. The vast majority of the slowdown for MessagePack is serializing (deserializing is fast). The object format (if it matters) was,

class DataSet {
  IDictionary<Guid, Class1> Class1;
  IDictionary<Guid, Class2> Class2;
}

class Class1 {
  string Property1;
  ISet<Guid> Property2;
}

class Class1 {
  string Property1;
  ISet<Guid> Property2;
  Guid Property3; 
}

With 1000 Class1 entries and 1000 Class2 entries, with each entry having 1000 guids in Property2.

Salgat avatar Aug 10 '18 02:08 Salgat