Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performance of protobuf-net vs. protobuf-csharp-port

I know the features and design of both libraries but I haven't found any direct performance comparison between those two. Both are definitely great libs. Regarding the design I think protobuf-csharp-port should be slightly faster due to less reflection, right?

Furthermore:

  • When will protobuf-net V2 be released? Any plans, Marc?
  • Will there be a new version of protobuf-csharp-port, Jon?

Thank you.

like image 360
Stephan Avatar asked Oct 19 '25 15:10

Stephan


1 Answers

Re performance; protobuf-net is designed to perform that reflection as little as possible, creating efficient data access code after that. In v2, it takes this much further in many ways - using much lower-level meta-programming, and if you want it (entirely optional), pre-generation of a standalone serializer dll - so at runtime the reflection cost is somewhere between minimal (if using runtime meta-programming) to nil (if using pre-generation).

Re release; "when it is ready"; life is crazy hectic, but an alpha dll is available for both full .NET and iPhone (this latter will probably work on most of the lighter runtimes, since iPhone is the most restrictive). Ultimately, reality is that (as unsponsored, etc) it is going to lag a bit behind things like work and family - I try to find time when I can, though.

I think a more sensible comparison is the goals; protobuf-net is designed to be easily fitted onto your existing DTO or domain model, without significant rework - or for use in a code-first scenario. It also supports generation from .proto, but that isn't the primary goal (but is of course hugely desirable). It also sports a very different API, geared around common .NET metaphors, rather than common protobuf metaphors.

Or to put it another way:

  • protobuf-csharp-port focuses on protobuf, and adds C# / .NET to the existing protobuf landscape
  • protobuf-net focuses on C# / .NET, and adds protobuf to the existing C# / .NET landscape

A subtle distinction, maybe - and indeed either would make a worthy serialization API for .NET.

As a corollary, if your primary aim is interop between heterogeneous environments that you actively work on in the same team - then maybe protobuf-csharp-port is a better match for you.

I'm also a bit... "loose" with protobuf, so I have no (well, minimal) guilt going a little bit beyond the standard spec (while staying inside the protocol definition) to shoehorn in inheritance, full-graphs, etc - which are common in the .NET ecosystem but have no direct map in protobuf. And of course I can look more at tools like WCF (and to a lesser degree: remoting).

like image 65
Marc Gravell Avatar answered Oct 22 '25 06:10

Marc Gravell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!