﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Ayende Rahien commented on Optimizing “expensive” calls</title><description>BSON,
  
No, I didn't know about that, thanks, I'll try it.
</description><link>http://ayende.com/4477/optimizing-expensive-calls#comment17</link><guid>http://ayende.com/4477/optimizing-expensive-calls#comment17</guid><pubDate>Wed, 05 May 2010 15:57:24 GMT</pubDate></item><item><title>Thomas commented on Optimizing “expensive” calls</title><description>Thank you
</description><link>http://ayende.com/4477/optimizing-expensive-calls#comment16</link><guid>http://ayende.com/4477/optimizing-expensive-calls#comment16</guid><pubDate>Mon, 03 May 2010 08:20:43 GMT</pubDate></item><item><title>Ayende Rahien commented on Optimizing “expensive” calls</title><description>Thomas,
  
This is dotTrace, a wonderful tool from JetBrains
</description><link>http://ayende.com/4477/optimizing-expensive-calls#comment15</link><guid>http://ayende.com/4477/optimizing-expensive-calls#comment15</guid><pubDate>Mon, 03 May 2010 06:19:06 GMT</pubDate></item><item><title>Thomas commented on Optimizing “expensive” calls</title><description>What tool do you use, for creating the "report" with the expensive calls?
</description><link>http://ayende.com/4477/optimizing-expensive-calls#comment14</link><guid>http://ayende.com/4477/optimizing-expensive-calls#comment14</guid><pubDate>Mon, 03 May 2010 06:17:58 GMT</pubDate></item><item><title>Rafal commented on Optimizing “expensive” calls</title><description>Probably you need to process the json only because you have to make sure ID and Version attributes are set. If so, you could just copy the doc from json reader to a json writer, adding id and version if necessary.
</description><link>http://ayende.com/4477/optimizing-expensive-calls#comment13</link><guid>http://ayende.com/4477/optimizing-expensive-calls#comment13</guid><pubDate>Sat, 01 May 2010 11:51:57 GMT</pubDate></item><item><title>Fabio Maulo commented on Optimizing “expensive” calls</title><description>Very interesting NewtonSoft.Json is faster than BinaryFormatter.
</description><link>http://ayende.com/4477/optimizing-expensive-calls#comment12</link><guid>http://ayende.com/4477/optimizing-expensive-calls#comment12</guid><pubDate>Sat, 01 May 2010 04:51:44 GMT</pubDate></item><item><title>Andrew commented on Optimizing “expensive” calls</title><description>Can you serialize many objects at once with threads (keep some 'serialize' threads running looking for work).
  
  
May be overkill :) 
</description><link>http://ayende.com/4477/optimizing-expensive-calls#comment11</link><guid>http://ayende.com/4477/optimizing-expensive-calls#comment11</guid><pubDate>Sat, 01 May 2010 02:09:34 GMT</pubDate></item><item><title>James Newton-King commented on Optimizing “expensive” calls</title><description>There isn't any reflection involved here, just simple iteration over collections of known objects and then writing values as JSON text.
  
  
I think it would be possible to improve performance here a little: under the covers the JSON is being written by a class called JsonTextWriter. Like any good public API JsonTextWriter can write to any TextWriter, checks for errors and updates some public properties with state. Since the contents of JObject et al are already guaranteed to be valid and will always output a string it could have its own internal writer which optimizes to be written to a string and fore-gos error checking and state.
  
  
If performance is important that is an idea of something you could look at. I haven't done it myself because I think sub 1ms is plenty fast enough for average use already and in my opinion more important features in a serializer, but you obviously have different needs. Happy to include the source in future releases if you do write something! :)
  
  
~J
</description><link>http://ayende.com/4477/optimizing-expensive-calls#comment10</link><guid>http://ayende.com/4477/optimizing-expensive-calls#comment10</guid><pubDate>Fri, 30 Apr 2010 15:58:23 GMT</pubDate></item><item><title>Jeremy Gray commented on Optimizing “expensive” calls</title><description>I was sure you had that covered but just had to check. ;)
</description><link>http://ayende.com/4477/optimizing-expensive-calls#comment9</link><guid>http://ayende.com/4477/optimizing-expensive-calls#comment9</guid><pubDate>Fri, 30 Apr 2010 14:03:51 GMT</pubDate></item><item><title>Ayende Rahien commented on Optimizing “expensive” calls</title><description>Jeremy,
  
Yes, it calls that on two different objects
</description><link>http://ayende.com/4477/optimizing-expensive-calls#comment8</link><guid>http://ayende.com/4477/optimizing-expensive-calls#comment8</guid><pubDate>Fri, 30 Apr 2010 13:57:43 GMT</pubDate></item><item><title>Jeremy Gray commented on Optimizing “expensive” calls</title><description>Whenever looking at the results of a profiler run, I remind myself that unnecessary calls are as important as slow calls, and often moreso once the obvious slow calls have been addressed. With that in mind, does AddDocument need to call JToken.ToString twice?
</description><link>http://ayende.com/4477/optimizing-expensive-calls#comment7</link><guid>http://ayende.com/4477/optimizing-expensive-calls#comment7</guid><pubDate>Fri, 30 Apr 2010 13:55:50 GMT</pubDate></item><item><title>Marc Gravell commented on Optimizing “expensive” calls</title><description>I mistakenly assumed that this was doing a serialization step.
  
  
I'll get my coat.
</description><link>http://ayende.com/4477/optimizing-expensive-calls#comment6</link><guid>http://ayende.com/4477/optimizing-expensive-calls#comment6</guid><pubDate>Fri, 30 Apr 2010 13:50:38 GMT</pubDate></item><item><title>Ayende Rahien commented on Optimizing “expensive” calls</title><description>Marc,
  
That might be nice, but the reason issue here is that we have a Json document being saved into a file, nothing else.
  
There isn't really a place for IL gen here. It isn't an object to json
</description><link>http://ayende.com/4477/optimizing-expensive-calls#comment5</link><guid>http://ayende.com/4477/optimizing-expensive-calls#comment5</guid><pubDate>Fri, 30 Apr 2010 11:54:37 GMT</pubDate></item><item><title>Demis Bellot commented on Optimizing “expensive” calls</title><description>I'm a strong believer in 'selectively' optimizing where it makes sense. I actually think *it does* make sense to aggressively optimize serialization as it is ultimately used on every request so every optimization you can make improves the entire performance of your application as a whole. Personally I think application performance / perceived performance is *the primary goal* of all successful internet software companies. For a good example of an optimized HTML5 site view the source and traffic of yahoo's new search page (see: inline images :):
  
[http://search.yahoo.com/](http://search.yahoo.com/)  
  
Speed is the main reason why I'm not using JSON serialization for serializing POCO's. I don't think there is anything inherently wrong with the format, I just haven't found a JSON library with good performance. 0.8ms seconds doesn't seem like here much so maybe its not worth it for this case but bigger datasets mean longer times and I'm used to having entire web service requests finish in &gt; 1ms.
  
  
Using the Northwind dataset, I've benchmarked all leading serialization routines I could find in .NET here:
  
[www.servicestack.net/.../...-times.2010-02-06.html](http://www.servicestack.net/benchmarks/NorthwindDatabaseRowsSerialization.1000000-times.2010-02-06.html)  
  
@Marc Gravell's protobuf-net binary serialization is the clear leader here (makes every other binary serializer redundant) while I do ok with the leading text-serializer.
  
  
&gt;&gt;I do wonder, though, if I should try a second project to take my existing IL-generator and change the leaf-nodes to handle xml / json / something else. Could be interesting ;-p
  
Yes please do! I don't think you should worry about XML as MS's implementation is actually pretty good, and well if you use XML you're going to be more concerned with interoperability than performance. But there is a big potential for perf gains in the JSON-space - all .NET ajax apps thank you in advance for your efforts :)
</description><link>http://ayende.com/4477/optimizing-expensive-calls#comment4</link><guid>http://ayende.com/4477/optimizing-expensive-calls#comment4</guid><pubDate>Fri, 30 Apr 2010 11:50:34 GMT</pubDate></item><item><title>Marc Gravell commented on Optimizing “expensive” calls</title><description>Fair enough. That won't help at all, then ;-p (feel free to delete the comment if you want to avoid any unhelpful distraction)
  
  
I do wonder, though, if I should try a second project to take my existing IL-generator and change the leaf-nodes to handle xml / json / something else. Could be interesting ;-p
</description><link>http://ayende.com/4477/optimizing-expensive-calls#comment3</link><guid>http://ayende.com/4477/optimizing-expensive-calls#comment3</guid><pubDate>Fri, 30 Apr 2010 10:24:57 GMT</pubDate></item><item><title>Ayende Rahien commented on Optimizing “expensive” calls</title><description>Marc :-)
  
The data is any arbitrary JSON document.
</description><link>http://ayende.com/4477/optimizing-expensive-calls#comment2</link><guid>http://ayende.com/4477/optimizing-expensive-calls#comment2</guid><pubDate>Fri, 30 Apr 2010 10:20:49 GMT</pubDate></item><item><title>Marc Gravell commented on Optimizing “expensive” calls</title><description>How complex is the data? If you *do* care about this, I'm pretty confident I could get you some noticeable performance increase without any change to your object model, using the (not fully released, but pretty stable) protobuf-net "v2" build.
  
  
In particular, this:
  
  
- has a metadata abstraction layer, so you don't need to decorate your model with attributes if you want to keep it unaware of serialization
  
- has full ILGenerator pre-compilation (even to a dll if you really want) for performance
  
  
(and of course the usual protobuf advantages of not needing to do as much UTF encoding or string matching)
  
  
I've got some examples where I have to do large loops, because the measurement is in the low micro-seconds.
</description><link>http://ayende.com/4477/optimizing-expensive-calls#comment1</link><guid>http://ayende.com/4477/optimizing-expensive-calls#comment1</guid><pubDate>Fri, 30 Apr 2010 10:14:30 GMT</pubDate></item></channel></rss>