Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binary serialization slow (sometimes) in .NET 4.6

Tags:

c#

.net

I have recently upgraded the .NET framework on my machine to .NET 4.6 and have noticed a big difference in times of binary (de)serialization of objects from/to files.

For example, I have a 10MB file which was deserialized in ~2 seconds on my machine with .NET 4.5.2. After upgrading to .NET 4.6 it takes up to 50 seconds(!) - actual time is pretty random: sometimes it takes 2 seconds, sometimes 50 seconds (same file, same program, even same process).

Has anybody else noticed similar behavior and maybe found a workaround (or solution) for this issue?

like image 800
Bartek Avatar asked Aug 28 '15 12:08

Bartek


1 Answers

Little reason to assume it has anything to do with binary serialization, it is pretty deterministic. Given the random behavior and the likelihood that you'll poke the garbage collector pretty heavily with a 10 megabyte file, a very good candidate is this bug. Quite a doozy.

If you have a good repro then use the new Diagnostics Tools to see any slow gen #1 collections. And tinker with GCSettings.LatencyMode, if it has an affect then you know it is the underlying cause. Should be fixed soon.

like image 89
Hans Passant Avatar answered Sep 29 '22 03:09

Hans Passant