Open marcbarry opened 5 years ago
Hi,
I am using MessagePack-CSharp and I'm facing the same issue. Did you find a solution to reduce the first call delay ?
Thanks. Harold
@yfakariya is the answer to the slow-start / warm-up question to use the SerializerGenerator
api? https://github.com/msgpack/msgpack-cli/wiki/Xamarin-and-Unity
In fact, serializer generation path is not optmized well. The overhead should be come from runtime code generation. I recognize this should be filed in backlog, mainly memory usage optimization to reduce gc.
As @marcbarry said, SerializerGenerator
API may help you.
In agreement with the previous comment, when I serialise a simple class
The initial call to
MessagePackSerializer.Get
takes several hundred milliseconds (somewhere between 350ms to 400ms) and the first call toMessagePackSerializer.Unpack()
takes a further 30ms~ or so.Subsequent calls to both
MessagePackSerializer.Pack()
andMessagePackSerializer.Unpack()
are fast.The delay only seems to happen when the program first runs. I assume this behaviour is by-design, but is there a way to work around, or at least reduce the "slow start" behaviour?
Tested on
MSgPack.Cli v1.0.0
targeting .NET Framework 4.5.Code to reproduce:
Example output:
Is there anything I can do to reduce this initial time calls to
MessagePackSerializer.Get()
take?See also https://github.com/msgpack/msgpack-cli/issues/191
Thanks!