﻿<?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>Luc commented on A WCF Perf Mystery</title><description>Don(t forget to close the proxy. It will allow for the TCP connection to be closed without timeout when you call Host.Close().
  
  
Just add:
  
 ((IDisposable)(srv)).Dispose();
  
after srv.Test("hello");
</description><link>http://ayende.com/3856/a-wcf-perf-mystery#comment10</link><guid>http://ayende.com/3856/a-wcf-perf-mystery#comment10</guid><pubDate>Wed, 11 Feb 2009 16:13:11 GMT</pubDate></item><item><title>magellings commented on A WCF Perf Mystery</title><description>If it's the first call it will take a while as it's a cold startup for WCF.  Be sure to have 3.5 SP1 installed on the machine.  Optimization was done to the CLR to improve cold startup times.
</description><link>http://ayende.com/3856/a-wcf-perf-mystery#comment9</link><guid>http://ayende.com/3856/a-wcf-perf-mystery#comment9</guid><pubDate>Mon, 09 Feb 2009 16:39:17 GMT</pubDate></item><item><title>Dave commented on A WCF Perf Mystery</title><description>I believe that WCF is using some sort of on demand (lazy) initialization. On line 12 a proxy between ISvr and Svr (the class, not the var) is created and used as a client. If it's the first call towards WCF than most of the WCF framework is loaded. It's works a bit like how applications are created and destroyed in the asp.net process. The first visitors initializes the application and is faced a longer execution time than following requests.
  
  
I also noticed on our services that it once occurred once. So during the startup of our service master host (a windows service that fires up other WCF services), after the host is created, we perform the first call, so the framework is loaded and clients don't have to deal with a slow first call. 
  
  
I can't backup most of the stories and mainly believed that we we're using WCF somehow in a wrong way. Because we had a simple workaround we didn't put that much attention to it. Now, after reading this post, I'm getting seconds doubts..
</description><link>http://ayende.com/3856/a-wcf-perf-mystery#comment8</link><guid>http://ayende.com/3856/a-wcf-perf-mystery#comment8</guid><pubDate>Mon, 09 Feb 2009 08:04:18 GMT</pubDate></item><item><title>Ben C commented on A WCF Perf Mystery</title><description>Hi Ayende, The line numbers in the code snippet come out when you cut and paste. So in order to run the snippet one must remove them by hand. On some blogs you get a link to copy the plain code to the clipboard. Actually, I don't think the line numbers are necessary, as you don't refer to them at all. Cheers.
</description><link>http://ayende.com/3856/a-wcf-perf-mystery#comment7</link><guid>http://ayende.com/3856/a-wcf-perf-mystery#comment7</guid><pubDate>Mon, 09 Feb 2009 02:00:21 GMT</pubDate></item><item><title>Ayende Rahien commented on A WCF Perf Mystery</title><description>James,
  
Thanks!
</description><link>http://ayende.com/3856/a-wcf-perf-mystery#comment6</link><guid>http://ayende.com/3856/a-wcf-perf-mystery#comment6</guid><pubDate>Sat, 07 Feb 2009 14:18:45 GMT</pubDate></item><item><title>Mark Monster commented on A WCF Perf Mystery</title><description>That's interesting information James. This is good to know, I always thought that the starting of a ServiceHost took so much time.
  
  
Mark Monster
</description><link>http://ayende.com/3856/a-wcf-perf-mystery#comment5</link><guid>http://ayende.com/3856/a-wcf-perf-mystery#comment5</guid><pubDate>Sat, 07 Feb 2009 11:48:02 GMT</pubDate></item><item><title>James Kovacs commented on A WCF Perf Mystery</title><description>Your client, srv, has an open TCP connection to the host. When you say:
  
  
host.Close();
  
  
there is a default 10 second timeout for the client to finish communication. (Total time on my machine is 11.15 s.) You know that communication is finished. So explicitly specify the timeout:
  
  
host.Close(new TimeSpan(0));
  
  
Completion time is 1.14s with this change.
  
  
Or you can close the client channel after the call to srv.Test():
  
  
var clientChannel = (IChannel)srv;
  
clientChannel.Close();
  
  
Completion time is also 1.14s.
  
  
HTH, James
</description><link>http://ayende.com/3856/a-wcf-perf-mystery#comment4</link><guid>http://ayende.com/3856/a-wcf-perf-mystery#comment4</guid><pubDate>Sat, 07 Feb 2009 06:52:12 GMT</pubDate></item><item><title>Steve commented on A WCF Perf Mystery</title><description>Network?
</description><link>http://ayende.com/3856/a-wcf-perf-mystery#comment3</link><guid>http://ayende.com/3856/a-wcf-perf-mystery#comment3</guid><pubDate>Sat, 07 Feb 2009 06:15:58 GMT</pubDate></item><item><title>Cos commented on A WCF Perf Mystery</title><description>According to the profiler, it's the close() that takes up your time. 
</description><link>http://ayende.com/3856/a-wcf-perf-mystery#comment2</link><guid>http://ayende.com/3856/a-wcf-perf-mystery#comment2</guid><pubDate>Sat, 07 Feb 2009 06:06:27 GMT</pubDate></item><item><title>Set commented on A WCF Perf Mystery</title><description>It's the first call...So I guess everything gets initialized at that moment
</description><link>http://ayende.com/3856/a-wcf-perf-mystery#comment1</link><guid>http://ayende.com/3856/a-wcf-perf-mystery#comment1</guid><pubDate>Sat, 07 Feb 2009 05:54:43 GMT</pubDate></item></channel></rss>