5

I am profiling my ASP.NET MVC app and when I hit my local version on IIS and I have noticed that deserializing an object of about 77kb takes around 100ms, is this expected?

Also the CPU seems to max out while im profiling, is the task of deserializing very intense, or should I be looking elsewhere?

Thanks for any help you can give.

2
  • You could always get the source for json.net and profile to see whats so intensive. It will be difficult to suggest anything without some more info (or data) Commented Jan 19, 2012 at 1:17
  • I have done some sampling using the VS profiler and the largest amount of sampling seems to be the JsonConvert.DeserializeObject Commented Jan 19, 2012 at 1:31

2 Answers 2

2

The complexity of the object usually plays a major role with regards to deserializing. Objects that contain child objects in a recursive pattern will eat CPU and memory to parse correctly.

A simple Name:Value map can become much more complex if the Value is another map (object) of Name:Value. If this type of recursion is going on you may want to try denormalizing (making a Name:[primitive]Value) your JSON so it's easier for the system to parse.

Denormalizing with respect to MVC (rdbms data) may be a bit difficult. Flattening many-to-many relationships isn't feasible in many cases.

You could try comparing JSON.net to the built-in JavaScriptSerializer and see if you can get an improvement.

Sign up to request clarification or add additional context in comments.

Comments

0

At a certain point, objects become cumbersome to deserialise, given that several serialisation frameworks, inclusing JSON.NET, leverage Reflection. Also, when an object reaches 85KB in size, it is immediately pushed to the Large Object Heap by the Garbage Collector, which will have a performance impact.

I suggest using JSON# - a performance sctentric .NET JSON parser to improve performance, and avoid memory bottlenecks.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.