Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 150745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:20:21+00:00 2026-05-11T09:20:21+00:00

For some caching I’m thinking of doing for an upcoming project, I’ve been thinking

  • 0

For some caching I’m thinking of doing for an upcoming project, I’ve been thinking about Java serialization. Namely, should it be used?

Now I’ve previously written custom serialization and deserialization (Externalizable) for various reasons in years past. These days interoperability has become even more of an issue and I can foresee a need to interact with .Net applications so I’ve thought of using a platform-independant solution.

Has anyone had any experience with high-performance use of GPB? How does it compare in terms of speed and efficiency with Java’s native serialization? Alternatively, are there any other schemes worth considering?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T09:20:21+00:00Added an answer on May 11, 2026 at 9:20 am

    I haven’t compared Protocol Buffers with Java’s native serialization in terms of speed, but for interoperability Java’s native serialization is a serious no-no. It’s also not going to be as efficient in terms of space as Protocol Buffers in most cases. Of course, it’s somewhat more flexible in terms of what it can store, and in terms of references etc. Protocol Buffers is very good at what it’s intended for, and when it fits your need it’s great – but there are obvious restrictions due to interoperability (and other things).

    I’ve recently posted a Protocol Buffers benchmarking framework in Java and .NET. The Java version is in the main Google project (in the benchmarks directory), the .NET version is in my C# port project. If you want to compare PB speed with Java serialization speed you could write similar classes and benchmark them. If you’re interested in interop though, I really wouldn’t give native Java serialization (or .NET native binary serialization) a second thought.

    There are other options for interoperable serialization besides Protocol Buffers though – Thrift, JSON and YAML spring to mind, and there are doubtless others.

    EDIT: Okay, with interop not being so important, it’s worth trying to list the different qualities you want out of a serialization framework. One thing you should think about is versioning – this is another thing that PB is designed to handle well, both backwards and forwards (so new software can read old data and vice versa) – when you stick to the suggested rules, of course 🙂

    Having tried to be cautious about the Java performance vs native serialization, I really wouldn’t be surprised to find that PB was faster anyway. If you have the chance, use the server vm – my recent benchmarks showed the server VM to be over twice as fast at serializing and deserializing the sample data. I think the PB code suits the server VM’s JIT very nicely 🙂

    Just as sample performance figures, serializing and deserializing two messages (one 228 bytes, one 84750 bytes) I got these results on my laptop using the server VM:

     Benchmarking benchmarks.GoogleSize$SizeMessage1 with file google_message1.dat  Serialize to byte string: 2581851 iterations in 30.16s; 18.613789MB/s  Serialize to byte array: 2583547 iterations in 29.842s; 18.824497MB/s  Serialize to memory stream: 2210320 iterations in 30.125s; 15.953759MB/s  Deserialize from byte string: 3356517 iterations in 30.088s; 24.256632MB/s  Deserialize from byte array: 3356517 iterations in 29.958s; 24.361889MB/s  Deserialize from memory stream: 2618821 iterations in 29.821s; 19.094952MB/s   Benchmarking benchmarks.GoogleSpeed$SpeedMessage1 with file google_message1.dat  Serialize to byte string: 17068518 iterations in 29.978s; 123.802124MB/s  Serialize to byte array: 17520066 iterations in 30.043s; 126.802376MB/s  Serialize to memory stream: 7736665 iterations in 30.076s; 55.93307MB/s  Deserialize from byte string: 16123669 iterations in 30.073s; 116.57947MB/s  Deserialize from byte array: 16082453 iterations in 30.109s; 116.14243MB/s Deserialize from memory stream: 7496968 iterations in 30.03s; 54.283176MB/s   Benchmarking benchmarks.GoogleSize$SizeMessage2 with file google_message2.dat  Serialize to byte string: 6266 iterations in 30.034s; 16.826494MB/s  Serialize to byte array: 6246 iterations in 30.027s; 16.776697MB/s  Serialize to memory stream: 6042 iterations in 29.916s; 16.288969MB/s  Deserialize from byte string: 4675 iterations in 29.819s; 12.644595MB/s  Deserialize from byte array: 4694 iterations in 30.093s; 12.580387MB/s  Deserialize from memory stream: 4544 iterations in 29.579s; 12.389998MB/s   Benchmarking benchmarks.GoogleSpeed$SpeedMessage2 with file google_message2.dat  Serialize to byte string: 39562 iterations in 30.055s; 106.16416MB/s  Serialize to byte array: 39715 iterations in 30.178s; 106.14035MB/s  Serialize to memory stream: 34161 iterations in 30.032s; 91.74085MB/s  Deserialize from byte string: 36934 iterations in 29.794s; 99.98019MB/s  Deserialize from byte array: 37191 iterations in 29.915s; 100.26867MB/s  Deserialize from memory stream: 36237 iterations in 29.846s; 97.92251MB/s  

    The ‘speed’ vs ‘size’ is whether the generated code is optimised for speed or code size. (The serialized data is the same in both cases. The ‘size’ version is provided for the case where you’ve got a lot of messages defined and don’t want to take a lot of memory for the code.)

    As you can see, for the smaller message it can be very fast – over 500 small messages serialized or deserialized per millisecond. Even with the 87K message it’s taking less than a millisecond per message.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to setup some caching on my site and am having troubles with
I am trying to put some distributed caching into play, I'm using this indeXus.Net
I'm needing to cache some data using System.Web.Caching.Cache . Not sure if it matters,
Some programming languages such as Java and C# include encryption packages in their standard
Some web applications, like Google Docs, store data generated by the users. Data that
Some WPF controls (like the Button ) seem to happily consume all the available
Some API returns me XmlCursor pointing on root of XML Document. I need to
Some things look strange to me: What is the distinction between 0.0.0.0, 127.0.0.1, and
Some Eclipse plugins are mandated by your environment. The appropriate source code management plugin,
Some e-Marketing tools claim to choose which web page to display based on where

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.