-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make BinaryFormatter faster #20569
Comments
A trivial change here that would help would simply be to increase the allowed size of the array used by the ObjectManager, e.g. here:
to:
That should make a very measurable difference in the deserialization time for a large graph like the one in the repro, at the expense of using some more memory, but not a ton more, especially given that it'll be relatively proportional to the size of the graph in question. Subsequently a different data structure could be considered, e.g. a tree of some kind, an array of trees of some kind, etc., rather than an array of lists. |
@Alois-xx , can you please tell us more about the way you're using BinaryFormatter? I'd like to better understand the parts of deserialization performance that are important to your scenario. |
I have found in our regular .NET based product large deserialization times which did lead to strange architectural changes because the root cause was never fully understood. I have now checked .NET Core if BinaryFormatter has become better and in fact it did not. Hence my request to improve at least .NET Core and if possible backmerge it to the .NET Desktop BCL as well. |
Deserialization of an 114Mbyte Dictionary, takes about 10 minutes, and uses 1Gbyte memory! So there is a big potential for improvement here
It seems that it's all forward references that needs fixup. |
Will this change be merged to the Full .NET Framework? Will this be part of a minor update and what is the expected timeframe for it to arrive? |
The change is marked for consideration for being ported to the .NET Framework, but there are currently no plans for if/when that would happen. |
Is there a way I can integrate this change to ObjectManager into my application without replacing the complete framework I'm pointing to? There doesn't seem to be a way to substituted a type or it's methods without modifying the original type somehow. I could do this easily in Java just by bumping a jar up in the classpath. |
The next .NET Framework update 4.7.3? will contain a fix for the regular .NET Framework. For .NET Core the fix is already in with .NET Core 2.0. |
Hope it come soon to .NET Framework, it is really painful to wait for large graph deserialization. |
This fix is scheduled to be included in .NET Framework 4.7.2 update. It won't be enabled by default. It will be only enabled when Early access preview builds of .NET Framework 4.7.2 should start showing up on https://github.com/Microsoft/dotnet-framework-early-access/ soon. Please give it a try once the build with this fix is available. For reference, the .NET Framework port is internal MS bug DevDiv 443438. |
Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
When BinaryFormatter encounters a larger object list it gets quadratic deserialization times due to the linear search in
Sample
Serialization time 2.31s
Deserialization 21.16s
This caused some unexpected "slowdowns" in production code when "real" big objects (e.g. 20 - 100 MB) object graphs are deserialized. Deserialization times of 10 minutes are not uncommon due to this. It would be great if this ugly thing gets cleaned up in .NET Core.
The text was updated successfully, but these errors were encountered: