-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Deserialization gets slow after deserializing large collection #541
Comments
Well, I can confirm you aren't imagining it. Presumably something in the using (var reader = ProtoReader.Create(ms, RuntimeTypeModel.Default, null))
{
var node = reader.Model.Deserialize(reader, null, typeof(Node));
} but yeah, something is definitely broken in there |
Thanks Marc, it seems to work okay. Would you recommend using the same pattern for all deserialization calls or only when deserializing large objects? I also tested by using it on the large collection and that seemed to work as well. using (var reader = ProtoReader.Create(ms, RuntimeTypeModel.Default))
{
var nodes = reader.Model.Deserialize(reader, null, typeof(NodeCollection));
} |
This is more of a workaround than a recommendation - it abuses some knowledge of what happens internally with the pooling model: in the current code, the code shown above won't continually re-use the same reader. The recommendation is that I find and fix the actual problem, especially since the above workaround won't work with the 3.* changes that are in my pending branches. So... yeah, I need to find out what is actually wrong here! |
Ok, let me know if you need any help. |
I need to deserialize a large collection and then a lot of smaller objects. The performance however degrades considerably when deserializing the smaller objects if I deserialized the large object first. Is there a cache or something that needs to be cleared between deserializations?
I made a small sample program that recreates the problem. Deserializing a single node 1000 times takes 0 milliseconds if I don't first deserialize the large collection and 1200 milliseconds if I do.
It seems that removing the AsReference = true from the NodeCollection.Nodes property speeds things up considerably, but don't I need that to be able to track all nodes and their children?
The text was updated successfully, but these errors were encountered: