<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>while true blog &#187; Development</title>
	<atom:link href="http://blog.whiletrue.com/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.whiletrue.com</link>
	<description></description>
	<lastBuildDate>Thu, 19 Jan 2012 08:36:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>What if Visual Studio had Achievements?</title>
		<link>http://blog.whiletrue.com/2011/01/what-if-visual-studio-had-achievements/</link>
		<comments>http://blog.whiletrue.com/2011/01/what-if-visual-studio-had-achievements/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 14:43:15 +0000</pubDate>
		<dc:creator>rudi</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Comedy]]></category>

		<guid isPermaLink="false">http://blog.whiletrue.com/?p=165</guid>
		<description><![CDATA[What if Visual Studio supported achievements, just like games on Steam, Xbox or PS3? Bragging to your coworkers about which one you&#8217;ve just unlocked, imagine that! Here&#8217;s a little proposed list for some of them. .NET / C# flavored, of course. Falling Down &#8211; Created a new SharePoint project Job Security &#8211; Written a LINQ [...]]]></description>
			<content:encoded><![CDATA[<p>What if Visual Studio supported achievements, just like games on Steam, Xbox or PS3? Bragging to your coworkers about which one you&#8217;ve just unlocked, imagine that! Here&#8217;s a little proposed list for some of them. .NET / C# flavored, of course.</p>
<ul>
<li><b>Falling Down</b> &#8211; Created a new SharePoint project</li>
<li><b>Job Security</b> &#8211; Written a LINQ query with over 30 lines of code</li>
<li><b>The Sword Fighter</b> &#8211; 5 Consecutive Solution Rebuilds with zero code changes</li>
<li><b>Shotgun Debugging</b> &#8211;  5 Consecutive Solution Rebuilds with a single character change</li>
<li><b>The Mathematician</b> &#8211; Defined 15 local variables with a single character name</li>
<li><b>The Academic</b> &#8211; Written 1000 lines of F#</li>
<li><b>Spaghetti Monster</b> &#8211; Written a single line with more than 300 characters</li>
<li><b>Wild One</b> &#8211; Mixed tabs and spaces for indentation more than 5 times in a single line</li>
<li><b>The Organizer</b> &#8211; Created a Solution with more than 50 projects</li>
<li><b>The Portal</b> &#8211; Created a circular project dependency</li>
<li><b>The Multitasker</b> &#8211; Have more than 50 source files open at the same time</li>
<li><b>The Code Keeper</b> &#8211; Uninstalled Resharper because it made you redundant</li>
<li><b>Pasta Chef</b> &#8211; Created a class with more than 100 fields, properties or methods</li>
<li><b>Procedural Programmer</b> &#8211; Created a method with more than 10 out parameters</li>
<li><b>Steam Powered</b> &#8211; Added Visual Studio as a Steam game</li>
<li><b>The Poet</b> &#8211; Written a source file with more than 10,000 lines</li>
<li><b>The Enterprise</b> &#8211; Build Solution took more than 10 minutes</li>
<li><b>Highway to Hell</b> &#8211; Successfully created a WCF service</li>
<li><b>The Explainer</b> &#8211; Written a comment with more than 100 words</li>
<li><b>TPS Reports</b> &#8211; Created a Crystal Reports Project</li>
<li><b>Rage Quit</b> &#8211; ALT+F4 after a failed bug fix</li>
<li><b>Ooooh Shiny</b> &#8211; Written 100 extensions methods</li>
<li><b>Look Ma</b> &#8211; Written an infinite Fibonacci generator using yield</li>
<li><b>The Engineer</b> &#8211; Killed a zombie with The Wrench</li>
<li><b>The Architect</b> &#8211; Created 25 Interfaces in a single project</li>
<li><b>The Right Way</b> &#8211; Test method is longer than the tested method</li>
<li><b>The Defender</b> &#8211; Checked every argument for null exceptions</li>
<li><b>Pokemon Programming</b> &#8211; Caught all the exceptions</li>
<li><b>Black Magic</b> &#8211; Implemented a RealProxy</li>
<li><b>Gimme back my ASM</b> &#8211; Used ILGenerator</li>
<li><b>I&#8217;m Sorry</b> &#8211; Created a new Visual Basic Project</li>
<li><b>The SEO Expert</b> &#8211; ASP.NET MVC Routing table with more than 100 routes</li>
<li><b>The Matrix</b> &#8211; Windows Forms with more than 100 controls</li>
<li><b>The Daredevil</b> &#8211; UpdatePanels nested more than 3 layers deep</li>
<li><b>Just a Test</b> &#8211; Nested multiline C-style comments that caused a compilation error</li>
<li><b>Warm Bath</b> &#8211; Successfully consumed a non .NET SOAP web service</li>
<li><b>Old School</b> &#8211; Defined more than 100 static objects</li>
<li><b>The Cloner</b> &#8211; Copy-pasted more than 50 lines</li>
<li><b>The Dependency</b> &#8211; Referenced more than 30 projects</li>
<li><b>Paying the bills</b> &#8211; Imported a Visual Basic project</li>
<li><b>First Hit</b> &#8211; Included a Codeproject.com library into your project and it actually compiled</li>
<li><b>Paula</b> &#8211; Define a firstname field with value <i>Brillant</i></li>
<li><b>Every Option Considered</b> &#8211; Created an enum with more than 30 values</li>
</ul>
<p>Inspired by Steam Holiday sales and Battlefield Bad Company 2. Odd web coding exposed on the most <a href="http://www.whiletrue.com/">minimalistic company page</a> possible. Enjoy.</p>
<p><b>Update</b>: Jeff Sandquist from Microsoft&#8217;s Developer Relations told us that they are going to make this happen! Check out their <a href="http://channel9.msdn.com/coding4fun">Coding 4 Fun</a> and <a href="http://channel9.msdn.com/">Channel 9</a> projects. More details to follow.</p>
<p><b>Update 2</b>: An extension is now <a href="http://blog.whiletrue.com/2012/01/visual-studio-achievements-now-a-reality/">available</a> for Visual Studio!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.whiletrue.com/2011/01/what-if-visual-studio-had-achievements/feed/</wfw:commentRss>
		<slash:comments>178</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC, session state and concurrent requests: not what you&#8217;d expect</title>
		<link>http://blog.whiletrue.com/2010/09/asp-net-mvc-sessions-and-concurrent-requests-not-what-youd-expect/</link>
		<comments>http://blog.whiletrue.com/2010/09/asp-net-mvc-sessions-and-concurrent-requests-not-what-youd-expect/#comments</comments>
		<pubDate>Tue, 28 Sep 2010 14:05:32 +0000</pubDate>
		<dc:creator>rudi</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://blog.whiletrue.com/?p=121</guid>
		<description><![CDATA[Using ASP.NET&#8217;s session storage and management providers for web applications is a no-brainer. User&#8217;s preferences, external API access tokens, uploaded documents, you name it, it usually makes sense. We&#8217;ll move it into the database when it gets too big, right? Our new photo book creation and printing service, Poyomi (a little tech intro) uses the [...]]]></description>
			<content:encoded><![CDATA[<p>Using ASP.NET&#8217;s session storage and management providers for web applications is a no-brainer. User&#8217;s preferences, external API access tokens, uploaded documents, you name it, it usually makes sense. We&#8217;ll move it into the database when it gets too big, right?</p>
<p>Our new photo book creation and printing service, <a href="http://www.poyomi.com/" target="_blank">Poyomi</a> (a little <a href="http://blog.whiletrue.com/2010/09/poyomi-architecture-net-meets-nosql-and-amqp/">tech intro</a>) uses the session state via MVC&#8217;s wrapper class <code>HttpSessionStateBase</code> which is provider as the <code>SessionData</code> property on a MVC controller. We store pretty much everything before the finished photo book is assembled: cover design, book&#8217;s designed pages, photo assembly preferences, perhaps an access token for flickr or SmugMug&#8230;</p>
<p><a href="http://www.poyomi.com" target="_blank">Poyomi</a> has to render many preview images for a client, doing it so asynchronously by offloading the rendering work to backend servers. A single page&#8217;s design and contained photos come from a serialized object in the session itself, that is then transferred via AMQP to the queue processor. All the MVC web app has to do is to wait for the response and pass it over to the client.</p>
<p>Since each photo book contains many pages, browsers will try to load images using multiple concurrent requests at the same time. That shouldn&#8217;t be a problem for the massively threaded queue processor and a simple MVC app, right?</p>
<p>Unfortunately, no. All of the little thumbnails were being loaded sequentially and the backend was doing just a single rendering job at a time. What was going on? I took a look at IIS&#8217; requests page (IIS manager &gt; Home &gt; IIS section &gt; Worker Processes &gt; Right click on the Pool &gt; View Current Requests).</p>
<p><a href="http://farm2.static.flickr.com/1110/4728909442_c06bdc750d_o.png" target="_blank"><img style="float: none;" src="http://farm2.static.flickr.com/1110/4728909442_1f53340d01.jpg" alt="IIS requests trace" align="left" /></a></p>
<p>Huh? A single request at a time. Talk about abysmal performance.</p>
<h2>More consequences on typical ASP.NET MVC websites</h2>
<p>AJAX requests often get used to offload time intensive operations. In case all of your HTTP requests, AJAX or not, demand the usage of the session data, they will all block each other. In case the user decides to &#8220;cancel&#8221; the current background operation by clicking on a link to another page on your site, the execution of it will be delayed until all of the existing requests finish processing.</p>
<h2>ASP.NET&#8217;s session state</h2>
<p>Digging and debugging revealed that it all has to do with the way ASP.NET handles session access. You can read about it more at <a href="http://msdn.microsoft.com/en-us/library/ms178581.aspx" target="_blank">MSDN</a>.</p>
<p>By default, no concurrent access to the session state is allowed. Even read-only requests (as far as the session is concerned) will be locked exclusively to prevent potential corruption of its state. There is a global or per-ASPX-page setting called <a href="http://msdn.microsoft.com/en-us/library/16kf4xz0.aspx" target="_blank"><code>EnableSessionState</code></a> to alter this behavior: either by disabling the session state altogether&#8230; which isn&#8217;t really useful in our case&#8230; or by marking certain pages as being read-only and thus enabling parallel execution of read-only requests. Yay! But what about our cool and modern ASP.NET MVC 2 application?</p>
<p>Well, it can be done. But doing so requires a visit to the MvcFutures department. I&#8217;ve found a single <a href="http://blogs.msdn.com/b/rickandy/archive/2009/12/17/session-less-mvc-controller.aspx" target="_blank">lone blog post</a> that describes the required changes to your MVC execution flow &#8211; presumably by a coworker of the one that programmed the solution. Essentially, it implements a new controller factory that is able to set the session state mode per the controller being executed.</p>
<h2>Setting the session state mode in ASP.NET MVC 2</h2>
<ol>
<li>Download the <a href="http://aspnet.codeplex.com/releases/view/41742" target="_blank">MvcFutures library</a>. Add a local reference to the <code>Microsoft.Web.Mvc.dll</code> library.</li>
<li>
<p>
Add the module into your project&#8217;s <code>Web.config</code> to load the dynamic session controller factory. Add the highlighted lines:
</p>
<pre name="codex" class="xml">
&lt;httpModules&gt;
  &lt;add name=&quot;ScriptModule&quot; type=&quot;System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35&quot;/&gt;
  &lt;add name=&quot;UrlRoutingModule&quot; type=&quot;System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35&quot;/&gt;
  <span style="background-color: #f2c5a4">&lt;add name=&quot;MvcDynamicSessionModule&quot; type=&quot;Microsoft.Web.Mvc.MvcDynamicSessionModule, Microsoft.Web.Mvc, Version=2.0.0.0&quot;/&gt;</span>
&lt;/httpModules&gt;
&lt;modules runAllManagedModulesForAllRequests=&quot;true&quot;&gt;
    &lt;remove name=&quot;ScriptModule&quot;/&gt;
    &lt;remove name=&quot;UrlRoutingModule&quot;/&gt;
    &lt;add name=&quot;ScriptModule&quot; preCondition=&quot;managedHandler&quot; type=&quot;System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35&quot;/&gt;
    &lt;add name=&quot;UrlRoutingModule&quot; type=&quot;System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35&quot;/&gt;
    <span style="background-color: #f2c5a4">&lt;add name=&quot;MvcDynamicSessionModule&quot; type=&quot;Microsoft.Web.Mvc.MvcDynamicSessionModule, Microsoft.Web.Mvc, Version=2.0.0.0&quot;/&gt;</span>
&lt;/modules&gt;
</pre>
<p>Add this module after the routing module.</p>
</li>
<li>
<p>Tell MVC to use the new dynamic session controller factory by instantiating and assigning it in your <code>Global.asax.cs</code> file: </p>
<pre name="codex" class="c-sharp">
protected void Application_Start() {
    AreaRegistration.RegisterAllAreas();
    RegisterRoutes(RouteTable.Routes);
    <span style="background-color: #f2c5a4">ControllerBuilder.Current.SetControllerFactory(new MvcDynamicSessionControllerFactory());</span>
}
</pre>
</li>
<li>
Use the session state attribute on your controller:</p>
<pre name="codex" class="c-sharp">
  <span style="background-color: #f2c5a4">[ControllerSessionState(ControllerSessionState.ReadOnly)]</span>
  public class AjaxReadonlyController : Controller {
</pre>
<p>Other state modes are: <code>Required</code> (equivalent to <code>Default</code>), <code>ReadOnly</code> and <code>Disabled</code>.</p>
</li>
</ol>
<p>Enjoy your high-performance website!</p>
<h2>Using Autofac with DynamicSessionControllerFactory</h2>
<p>If you are using <a href="http://code.google.com/p/autofac/" target="_blank">Autofac</a> for dependency injection (and why aren&#8217;t you?) you&#8217;ll have to nest the two controller factories. <code>Global.asax.cs</code>&#8216; <code>Application_Start</code>:</p>
<p>
<pre name="codex" class="c-sharp">
var factory = new AutofacControllerFactory(ContainerProvider);
var dyn = new MvcDynamicSessionControllerFactory(factory);
ControllerBuilder.Current.SetControllerFactory(dyn);
</pre>
</p>
<p>Also, be warned that you cannot inject the session data object into your classes anymore. For example, if you were using something akin to:</p>
<p>
<pre name="codex" class="c-sharp">
var builder = new ContainerBuilder();
builder.Register(s => HttpContext.Current.Session).As<HttpSessionState>().HttpRequestScoped();
</pre>
</p>
<p>&#8230;then this won&#8217;t work anymore. The controller&#8217;s <code>SessionData</code> property is null until MVC gets around to executing your method. You&#8217;ll have to pass it to instances that were already instantiated by Autofac&#8217;s controller factory at execution time.</p>
<h2>In conclusion</h2>
<p>I&#8217;m sure that almost every MVC project uses the session for storage of little tokens, strings, counters&#8230; which by default blocks the execution of parallel requests. Surprisingly, almost no one blogged about this before. Hopefully this article will add some exposure to this problem.</p>
<p>All of this applies to ASP.NET MVC 2, the latest production ready version. Please let me know if this is going to be implemented in MVC 3 without the usage of MvcFutures!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.whiletrue.com/2010/09/asp-net-mvc-sessions-and-concurrent-requests-not-what-youd-expect/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Poyomi&#8217;s architecture: .NET meets NoSQL and AMQP</title>
		<link>http://blog.whiletrue.com/2010/09/poyomi-architecture-net-meets-nosql-and-amqp/</link>
		<comments>http://blog.whiletrue.com/2010/09/poyomi-architecture-net-meets-nosql-and-amqp/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 12:18:23 +0000</pubDate>
		<dc:creator>rudi</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://blog.whiletrue.com/?p=108</guid>
		<description><![CDATA[Welcome to our first behind the scenes post, an upcoming series of technical articles about Poyomi, our new photobook creation and printing service. Handling lots of incoming photos, processing them and rendering live previews as fast as possible shouldn&#8217;t be a problem with todays powerful server configurations, but doing so with good scalability options certainly [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.poyomi.com/wp-content/uploads/2010/09/blog_prod1.jpg"><img src="http://blog.poyomi.com/wp-content/uploads/2010/09/blog_prod1-300x199.jpg" alt="Venice sample book" title="blog_prod1" width="300" height="199" class="alignleft size-medium wp-image-58" /></a><br />
<a href="http://blog.poyomi.com/wp-content/uploads/2010/09/blog_prod2.jpg"><img src="http://blog.poyomi.com/wp-content/uploads/2010/09/blog_prod2-300x199.jpg" alt="Some of our sample books" title="blog_prod2" width="300" height="199" class="alignleft size-medium wp-image-57" /></a>
</p>
<p>Welcome to our first behind the scenes post, an upcoming series of technical articles about <a href="http://www.poyomi.com/">Poyomi</a>, our new photobook creation and printing service.</p>
<p>Handling lots of incoming photos, processing them and rendering live previews as fast as possible shouldn&#8217;t be a problem with todays powerful server configurations, but doing so with good scalability options certainly requires a special architecture. Here&#8217;s out approach.</p>
<p>Our <a href="http://www.whiletrue.com/">company&#8217;s</a> primary development platform is .NET 3.5 with C# 3, which might have had a reputation as being a bit of Microsoft-centric when it comes to interfacing with database engines, but lately this isn&#8217;t the case anymore. For Poyomi, we use two &#8220;next generation&#8221; backend products: <a href="http://couchdb.apache.org/" target="_blank">CouchDB</a> key/value database and <a href="http://www.rabbitmq.com/" target="_blank">RabbitMQ</a> message queuing server.</p>
<p><img src="http://blog.poyomi.com/wp-content/uploads/2010/09/poyomi_overview.png" alt="" title="Overview" width="527" height="615" class="alignnone size-full wp-image-68" /></p>
<p>Website&#8217;s backend is written in ASP.NET MVC and is meant to use as little CPU resources as possible &#8211; almost everything is offloaded to the Queue Processor (homegrown package) by sending a message to one of the message queues on the RabbitMQ server. The underlying <a href="http://en.wikipedia.org/wiki/AMQP" target="_blank">AMQP</a> protocol is bi-directional, so messages are sent and received with millisecond latency &#8211; no polling for messages every few seconds! Even serialized messages in the megabyte range are handled nicely &#8211; for instance, a newly uploaded photo from a user.</p>
<p>Consuming the real-time message queue is a job for our custom .NET / C# Queue Processor (the plan is to open source it some day, keep bugging us). It handles message serialization, resource limiting (each CPU gets a single job of this type), task status reports (via CouchDB), logging, task chaining and much more. Some of the tasks that we handle asynchronously by offloading them to the QP instead of doing them in MVC (gah!):</p>
<ul>
<li>Resizing images to thumbnail sizes</li>
<li>Rotating images</li>
<li>Rendering a live preview of a spread</li>
<li>Validating uploaded photos</li>
<li>Downloading photos from external sites like flickr</li>
<li>Arranging photos on a single page with a special, CPU intensive algorithm</li>
<li>Calculating photo&#8217;s color clusters</li>
<li>Rendering the final PDF: One task per two pages in a PDF, so adding more QP consumers almost linearly decreases the time needed for the final assembly!</li>
<li>Little tasks like sending notification emails, contact emails, &#8230;</li>
</ul>
<p>
<a href="http://blog.poyomi.com/wp-content/uploads/2010/09/spread-prev.jpg" target="_blank"><img src="http://blog.poyomi.com/wp-content/uploads/2010/09/spread-prev-300x200.jpg" alt="" title="spread-prev" width="300" height="200" class="size-medium wp-image-70" align="none" style="float: none" /></a><br />
<br />
All of the previews are rendered in real time.
</p>
<p>Photo storage duties are handled by <a href="http://couchdb.apache.org/" target="_blank">CouchDB</a>, a NoSQL Key-Value database with a HTTP REST interface. Everything is stored as a JSON document, with one very useful feature that we exploit fully: binary attachments. Each photo is stored as a single document with multiple image attachments &#8211; the original photo and various thumbnails. No more scattered files all across the filesystem, everything is kept together!</p>
<p><a href="http://blog.poyomi.com/wp-content/uploads/2010/09/poyomi-couchdb-1.png"><img src="http://blog.poyomi.com/wp-content/uploads/2010/09/poyomi-couchdb-1-293x300.png" alt="" title="CouchDB photo" width="293" height="300" class="alignnone size-medium wp-image-69" /></a></p>
<p>Querying for all of a particular user&#8217;s photos is done with CouchDB&#8217;s views &#8211; a map-reduce system for database queries. The mapping and reduction functions are written in JavaScript and kept in a special JSON document. But its main strength is querying for documents by its ID (the primary key, in SQL speak). Non-blocking, really fast and reliable, it works like a charm for things like task status updates and photo meta information.</p>
<p>Overall scalability is ensured by adding more message queue consumers &#8211; Queue Processors. Bringing one up is really easy, since the only two required connections are to RabbitMQ and CouchDB. A pair of configuration variables for each of those, host and port, that&#8217;s it. No more network shares or NFS mounts for storage, everything is handled via HTTP and AMQP. We love this.</p>
<p>Our MVC and QP servers are Windows machines, while RabbitMQ and CouchDB sit on a Linux server alongside nginx for web proxying and caching duties.</p>
<p>We&#8217;re proudly using many open source libraries, thanks guys! Here&#8217;s a little list: <a href="http://github.com/foretagsplatsen/Divan">Divan</a>, a CouchDB client, <a href="http://www.rabbitmq.com/dotnet.html">RabbitMQ&#8217;s AMQP</a> client for sending and receiving queued messages, <a href="http://james.newtonking.com/pages/json-net.aspx">Json.NET</a> for serialization duties, <a href="http://www.pdfsharp.net/">PDFSharp</a> for PDF authoring, <a href="http://code.google.com/p/autofac/">Autofac</a> for Dependency Injection, <a href="http://flickrnet.codeplex.com/">FlickrNet</a> for consuming flickr&#8217;s API and Yahoo&#8217;s <a href="http://yuidotnet.codeplex.com/">YUI Compressor</a> for .NET.</p>
<p>Please let us know what you&#8217;re most interested in for the next in the series of technical articles &#8211; <a href="http://www.poyomi.com/">take a look around</a>, you&#8217;re sure to find something technically interesting! And the <a href="http://www.poyomi.com/gallery">photobooks</a> aren&#8217;t that shabby looking either.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.whiletrue.com/2010/09/poyomi-architecture-net-meets-nosql-and-amqp/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>NT konferenca 2009: Continuous integration</title>
		<link>http://blog.whiletrue.com/2009/05/nt-konferenca-2009-continuous-integration/</link>
		<comments>http://blog.whiletrue.com/2009/05/nt-konferenca-2009-continuous-integration/#comments</comments>
		<pubDate>Tue, 26 May 2009 06:00:36 +0000</pubDate>
		<dc:creator>Gorazd</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[MSBuild]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Unit testing]]></category>
		<category><![CDATA[ntk2009 CI]]></category>

		<guid isPermaLink="false">http://blog.whiletrue.com/?p=78</guid>
		<description><![CDATA[Demo source code (6.17MB) from the talk &#8220;Continuous integration: good, bad and the ugly&#8221; given at the NT konferenca 2009 in Portorož, Slovenia. Check the included Readme file for instructions.]]></description>
			<content:encoded><![CDATA[<p><a href="http://zoidberg.whiletrue.com/ntk/ntk09-demo-src.zip">Demo source code</a> (6.17MB) from the talk &#8220;Continuous integration: good, bad and the ugly&#8221; given at the <a href="http://ntk.si/">NT konferenca 2009</a> in Portorož, Slovenia. Check the included Readme file for instructions.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.whiletrue.com/2009/05/nt-konferenca-2009-continuous-integration/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC Performance</title>
		<link>http://blog.whiletrue.com/2009/04/aspnet-mvc-performance/</link>
		<comments>http://blog.whiletrue.com/2009/04/aspnet-mvc-performance/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 09:44:17 +0000</pubDate>
		<dc:creator>rudi</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[asp mvc linq sql optimization performance magcloud]]></category>

		<guid isPermaLink="false">http://blog.whiletrue.com/?p=61</guid>
		<description><![CDATA[A closer look at the recently released ASP.NET MVC 1.0 preffered web development stack and some of its performance implications. All of the displayed techniques are in use in production at MagCloud. The talk was first given in Slovene on 15.4.2009 at a local Microsoft developers user group, SLODUG. ASP.NET MVC Performance View more presentations [...]]]></description>
			<content:encoded><![CDATA[<p>A closer look at the recently released ASP.NET MVC 1.0 preffered web development stack and some of its performance implications. All of the displayed techniques are in use in production at <a href="http://www.magcloud.com">MagCloud</a>.</p>
<p>The talk was first given in Slovene on 15.4.2009 at a local Microsoft developers user group, <a href="http://slodug.si/">SLODUG</a>.</p>
<div id="__ss_1304737" style="width: 425px; text-align: left;"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" title="ASP.NET MVC Performance" href="http://www.slideshare.net/rudib/aspnet-mvc-performance?type=presentation">ASP.NET MVC Performance</a><object width="425" height="355" data="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=performance-eng-090417043244-phpapp01&amp;rel=0&amp;stripped_title=aspnet-mvc-performance" type="application/x-shockwave-flash"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=performance-eng-090417043244-phpapp01&amp;rel=0&amp;stripped_title=aspnet-mvc-performance" /><param name="allowfullscreen" value="true" /></object></p>
<div style="font-size: 11px; font-family: tahoma,arial; height: 26px; padding-top: 2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/">presentations</a> from <a style="text-decoration:underline;" href="http://www.slideshare.net/rudib">rudib</a>.</div>
</div>
<p><b>Additional notes:</b></p>
<p>We cannot assume that only implementing database caching will lead to a significant performance gain before optimizing any other aspects of page&#8217;s rendering. Here&#8217;s a few more metrics for the DUGG application:</p>
<ul>
<li>First run, as in the slides, no optimizations whatsoever: <b>5.9</b> requests / second</li>
<li>Added: Compiled SQL-LINQ queries: <b>6.88</b> requests / second</li>
<li>Added: Fully cached SQL-LINQ queries: <b>7.43</b> requests / second/
<li>
<li>Removed: expression links, replaced with route and actions links. Also fixed path to partials with the full path: <b>112</b> requests/second</li>
</ul>
<p>That still leaves room for the treble performance improvement with URL caching and views that render enumerations.</p>
<p>It&#8217;s one of the general rules of optimizing software that speedups in one part of the application will have a lot of consequences elsewhere which you can&#8217;t really predict. Test, measure, profile, optimize a single hotspot, repeat!</p>
<p><b>Errata (23.4.2009)</b></p>
<p>Thanks to Simone Chiaretta&#8217;s analysis of my results, he&#8217;s <a href="http://codeclimber.net.nz/archive/2009/04/22/how-to-improve-htmlhelper.renderpartial-performances-donrsquot-run-in-debug-mode.aspx">nailed it</a> that I forgot to disable the debug mode for benchmarks (oops!). This disables ASP.NET MVC&#8217;s internal cache for paths to views, rendering my part of optimization notes to replace paths to views with full paths irrelevant. I&#8217;ve re-run all of the benchmarks, removed two slides and added an errata to the end of the slides.</p>
<p>It would be nice if I can be proven wrong on other points as well. <img src='http://blog.whiletrue.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.whiletrue.com/2009/04/aspnet-mvc-performance/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Marking variables in VS.NET Debugger</title>
		<link>http://blog.whiletrue.com/2007/07/marking-variables-in-vsnet-debugger/</link>
		<comments>http://blog.whiletrue.com/2007/07/marking-variables-in-vsnet-debugger/#comments</comments>
		<pubDate>Fri, 20 Jul 2007 14:42:20 +0000</pubDate>
		<dc:creator>Gorazd</dc:creator>
				<category><![CDATA[vs.net]]></category>

		<guid isPermaLink="false">http://blog.whiletrue.com/?p=22</guid>
		<description><![CDATA[Technorati Tags: vs.net, debugging Even after using Visual Studio for years (previous versions at least), you can always find hidden features. If you are debugging and have watch window open, you can click on &#8220;Make Object ID&#8221;. This will create ID for specific object or its member. You will get id&#8217;s such as 1#, 2# [...]]]></description>
			<content:encoded><![CDATA[<p CLASS="wlWriterSmartContent" ID="0767317B-992E-4b12-91E0-4F059A8CECA8:a3832d85-5026-4d34-a936-d8e3705eba69" CONTENTEDITABLE="false" STYLE="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px">Technorati Tags: <a HREF="http://technorati.com/tags/vs.net" REL="tag">vs.net</a>, <a HREF="http://technorati.com/tags/debugging" REL="tag">debugging</a></p>
<p>Even after using Visual Studio for years (previous versions at least), you can always find hidden features.</p>
<p>If you are debugging and have watch window open, you can click on &#8220;Make Object ID&#8221;. This will create ID for specific object or its member. You will get id&#8217;s such as 1#, 2# etc.</p>
<p><a HREF="http://blog.whiletrue.com/wp-content/uploads/2007/07/image.png" atomicselection="true"><img STYLE="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-right-width: 0px" HEIGHT="360" ALT="Click on " SRC="http://blog.whiletrue.com/wp-content/uploads/2007/07/image-thumb.png" WIDTH="564" BORDER="0" /></a></p>
<p>From now on, you can use</p>
<pre CLASS="csharpcode">
1#.SomeMember();</pre>
<p>even when this variable is not in scope. Quite useful for multithreaded debugging or for debugging code where you want to track specific objects through many layers.</p>
<p><a HREF="http://blog.whiletrue.com/wp-content/uploads/2007/07/image1.png" atomicselection="true"><img STYLE="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" HEIGHT="89" ALT="object id's" SRC="http://blog.whiletrue.com/wp-content/uploads/2007/07/image-thumb1.png" WIDTH="528" BORDER="0" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.whiletrue.com/2007/07/marking-variables-in-vsnet-debugger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple programming language performance benchmark(C# vs. Java vs. C++ vs. Ruby)</title>
		<link>http://blog.whiletrue.com/2006/05/simple-programming-language-performance-benchmarkc-vs-java-vs-c-vs-ruby/</link>
		<comments>http://blog.whiletrue.com/2006/05/simple-programming-language-performance-benchmarkc-vs-java-vs-c-vs-ruby/#comments</comments>
		<pubDate>Mon, 08 May 2006 14:48:30 +0000</pubDate>
		<dc:creator>Gorazd</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.whiletrue.com/?p=6</guid>
		<description><![CDATA[After writting last entry on installation of .NET and Java runtimes I did a bit of searching. I noticed that one of very popular contest is .NET versus Java or C/C++ versus Java or C/C++ versus .NET (ok, I haven&#8217;t actually seen the last one in the wild, but I am sure it exists). I [...]]]></description>
			<content:encoded><![CDATA[<p>After writting last entry on <a href="http://blog.whiletrue.com/?p=5"> installation of .NET and Java runtimes</a> I did a bit of searching. I noticed that one of very popular contest is .NET versus Java or C/C++ versus Java or C/C++ versus .NET (ok, I haven&#8217;t actually seen the last one in the wild, but I am sure it exists).</p>
<p>I have worked with all languages mentioned above. Assuming competent programmers, C/C++ with good compiler wins. Java and C# are usually about the same. I recently participated in one of the contest of topcoder.com. <a href="http://www.topcoder.com/longcontest/?module=ViewStandings&#038;rd=9974">This</a> confirms my statement. Also, keep in mind that coders in this contest are quite good and that Intel optimizing compiler is used, which supports SIMD (Single Instruction Multiple Data) instructions and is supposed to do vectorisation and other cool stuff.</p>
<p>Now, the funny part. For the many (most?) applications language (and platform) speed is not important. Even if one platform is 2x faster then the other, that is relatively unimportant. Of course, there are exceptions. You want games to be fast, image and video processing should be fast. But once application response time for any input is below, say, 0.1 s, there is rarely reason to optimize it.</p>
<p>I have been doing quite a lot of Ruby (on Rails and pure Ruby). Now, Ruby is slow. But writting code is fast (Rails is also awesome web framework). You might not want to base your Google killer search engine on Ruby but for many applications, Ruby is fast enough.</p>
<p>Now, I will stop talking and actually do some testing. Below is source code for very simple performance test.<br />
The code itself has no significance. I only wanted two loops and some operations. Timing was done from batch files.<br />
Timer started before the program was started and ended after program exited. So start-up times WERE included in the time.</p>
<p><strong>C#</strong></p>
<p><code><br />
using System;<br />
class Perf<br />
{<br />
	public static void Main()<br />
	{<br />
		long val = 0;<br />
		for (int x = 0; x < 10000; x++)<br />
		{<br />
			for (int y = 0; y < 100000; y++) val += y + x;<br />
		}<br />
		Console.WriteLine("Val = {0}", val);<br />
	}<br />
}</code></p>
<p><strong>Java</strong></p>
<p><code><br />
class perf<br />
{<br />
	public static void main(String[] args)<br />
	{<br />
		long val = 0;<br />
		for (int x = 0; x < 10000; x++)<br />
		{<br />
			for (int y = 0; y < 100000; y++) val += y + x;<br />
		}<br />
		System.out.println("Val = " +  val);<br />
	}<br />
}<br />
</code></p>
<p><strong>C++</strong></p>
<p><code><br />
#include <iostream><br />
using  namespace std;<br />
int main()<br />
{<br />
	long long val = 0;<br />
	for (int x = 0; x < 10000; x++)<br />
	{<br />
		for (int y = 0; y < 100000; y++) val += (y + x);<br />
	}<br />
   cout << "Val =" << val << endl;<br />
   return 0;<br />
}</code></p>
<p><strong>Ruby</strong></p>
<p>val = 0<br />
0.upto(10000) do |x|<br />
	0.upto(100000) do |y|<br />
		val += x + y<br />
	end<br />
end<br />
puts "Val = #{val}"</p>
<p>This was run on 1.7 Ghz IBM Thinkpad with 1.5Gb of RAM and Windows XP Professional SP2 (not that RAM is important here, maybe in some other test?).  Each test was run a couple of times and best time was recorded.</p>
<p>Java 1.5 (command line: java perf -server)<br />
<strong>6.84 seconds</strong></p>
<p>C#  2.0, without ngen.exe (code with ngen.exe was .3 seconds slower, go figure ):<br />
<strong>4.02 seconds</strong></p>
<p>C++ (compiled with cl cpp_perf.cpp /Og /Ox)</p>
<p><strong>2.97 seconds</strong></p>
<p>Ruby (it was so slow, I ran it for 1% of cases and extrapolated)<br />
<strong>3861 seconds</strong> (yes, there is no dot in there. It is more that 1 hour).</p>
<p>Now, what does that tell us? First, you should not use Ruby (or any other scripting language) for numberic processing. Really, they are not intended for that.<br />
Now, if you are Java guy and feel that C# "won" this round, you are mistaken. If 50% speed increase in numberical processing is significant for you, neither C# nor Java are right for you. C++ is the way to go. I used MS Visual C++ (from MS.NET 2005). If I used intel compiler, things might be different.</p>
<p>The moral of the story is: C++ for performance critical things (e.g where number chrunching performance factor 2x is an issue. It happens less than you would think). C#/Java have "good enough" performance for most tasks. Pure numerical performance should not be a factor in deciding which language to take (for c# vs. java).<br />
Ruby shows the weakest point of scripting languages - pure speed. But once you start being limited by other things (databases, web services, file system - pure speed becomes less and less of an issue).</p>
<p>And keep in mind, even handcrafted assembly code bubble-sort code written for exact hardware will lose agains quicksort  algorithm (even if written in Ruby...). At least for large enough number of elements.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.whiletrue.com/2006/05/simple-programming-language-performance-benchmarkc-vs-java-vs-c-vs-ruby/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.619 seconds -->

