<?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>Florent Clairambault</title>
	<atom:link href="http://florent.clairambault.fr/feed" rel="self" type="application/rss+xml" />
	<link>http://florent.clairambault.fr</link>
	<description></description>
	<lastBuildDate>Tue, 16 Mar 2010 16:25:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0-alpha</generator>
		<item>
		<title>De retour chez OVH</title>
		<link>http://florent.clairambault.fr/de-retour-chez-ovh</link>
		<comments>http://florent.clairambault.fr/de-retour-chez-ovh#comments</comments>
		<pubDate>Mon, 15 Mar 2010 19:30:26 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[French]]></category>
		<category><![CDATA[1And1]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OVH]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=2534</guid>
		<description><![CDATA[Je suis de retour chez OVH. C&#8217;est plus cher, je n&#8217;ai plus de backup automatique et plus les garanties offertes par un serveur virtuel mais au moins ça fonctionne. Si vous envisagez de passer chez 1And1, préparez vous à rejoindre le cercle des utilisateurs mécontents (et généralement engagés sur 12 ou 24 mois).
J&#8217;ai eu la [...]]]></description>
			<content:encoded><![CDATA[<p>Je suis de retour chez OVH. C&#8217;est plus cher, je n&#8217;ai plus de backup automatique et plus les garanties offertes par un serveur virtuel mais au moins ça fonctionne. Si vous envisagez de passer chez 1And1, préparez vous à rejoindre le cercle des utilisateurs mécontents (et généralement engagés sur 12 ou 24 mois).</p>
<p>J&#8217;ai eu la mauvaise surprise de m&#8217;appercevoir que MySQL en Debian/stable était plus vieux que le MySQL de CentOS 5. Mais je m&#8217;en suis apperçu après coup, il me semblait évident que ça ne serait pas le cas. Si vous vous êtes un jour demandé ce que ça faisait de lancer un serveur MySQL avec des fichiers provenants d&#8217;une version plus récentes&#8230; Et bien ça ne donne rien de bon, les requêtes aboutissent rarement et de façon aléatoire (la même requête peut fonctionner ou ne pas fonctionner). On reçoit un bon paquet d&#8217;erreurs &#8220;Lost connection to the server&#8221;.</p>
<p>Pour un projet sur lequel je travail pendant mon temps libre avec d&#8217;autres personnes, j&#8217;utilise maintenant <a href="http://netbeans.org/features/php/">NetBeans</a> + <a href="https://www.dropbox.com/">Dropbox</a>.<br />
NetBeans c&#8217;est pour moi le meilleur IDE PHP du moment mais le soucis c&#8217;est qu&#8217;en mode FTP il ne fait qu&#8217;envoyer les fichiers modifiés. Lors de la création du projet NetBeans il télécharge tous les fichiers et après il ne fait que les envoyer. Cela a pour conséquence notable d&#8217;empêcher le travail à plusieurs.<br />
Pour remedier à ça en plus de l&#8217;accès FTP j&#8217;ai mis un répertoire DropBox partagé sur le serveur et ça marche niquel. Les développeurs et le serveur sont synchronisés. Bien sur je fais 2x plus de backups parce que ça fait assez peur.</p>
<p>Sinon j&#8217;ai tenté d&#8217;installer Nexenta 3b1 sur une machine VMWare et ça n&#8217;a malheureusement pas du tout marché. L&#8217;installeur était très très très long et il a crashé peu après avoir atteint 100%. Je ne m&#8217;attendais pas à grand chose la part d&#8217;un système qui met 3h à s&#8217;installer de toute façon. </p>
]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/de-retour-chez-ovh/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>French and English</title>
		<link>http://florent.clairambault.fr/french-and-english</link>
		<comments>http://florent.clairambault.fr/french-and-english#comments</comments>
		<pubDate>Fri, 12 Mar 2010 20:00:39 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[French]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[french]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=2508</guid>
		<description><![CDATA[Hi my dear visitors,
    You are more than 3 000 each month now. So maybe I choose try to make it easier for everyone so that you only subscribe to the feed in the languages you understand :
- all languages RSS stream
- english only RSS stream
- french only RSS stream
By the way, [...]]]></description>
			<content:encoded><![CDATA[<p>Hi my dear visitors,</p>
<p>    You are more than 3 000 each month now. So maybe I choose try to make it easier for everyone so that you only subscribe to the feed in the languages you understand :<br />
- <a href="http://florent.clairambault.fr/feed">all languages RSS stream</a><br />
- <a href="http://florent.clairambault.fr/cat/uncategorized/feed">english only RSS stream</a><br />
- <a href="http://florent.clairambault.fr/cat/french/feed">french only RSS stream</a></p>
<p>By the way, I updated the <a href="http://florent.clairambault.fr/tc65-faq">TC65 FAQ</a> to add questions and answers collected from <a href="http://groups.google.com/group/javacint">the javacint group</a>. I created this google group a year ago for developpers willing to exchange about the TC65. It started quite slowly but it now has 28 members. And considering how hard it is to find any information on this chip that&#8217;s a lot. I think it helped a lot of people.</p>
<hr />
<p><em>Translation for all the retarded french dudes :</em><br />
      Le blog a atteint 3000 visiteurs mensuel. Peut-être que je devrais maintenant faire en sorte que chacun n&#8217;ait à lire que les langue qu&#8217;il comprend :<br />
- <a href="http://florent.clairambault.fr/feed">flux RSS dans les deux langues</a><br />
- <a href="http://florent.clairambault.fr/cat/uncategorized/feed">flux RSS en anglais uniquement</a><br />
- <a href="http://florent.clairambault.fr/cat/french/feed">flux RSS en français uniquement</a></p>
]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/french-and-english/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Serveur privé 1&amp;1: Une belle arnaque</title>
		<link>http://florent.clairambault.fr/serveur-prive-1and1-une-belle-arnaque</link>
		<comments>http://florent.clairambault.fr/serveur-prive-1and1-une-belle-arnaque#comments</comments>
		<pubDate>Thu, 11 Mar 2010 21:56:37 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[French]]></category>
		<category><![CDATA[1And1]]></category>
		<category><![CDATA[serveur dédié]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=2493</guid>
		<description><![CDATA[J&#8217;avais 2 serveurs chez OVH et Dedibox qui étaient en redondance complète (fichiers, mysql, web, mails, dns) avec du DNS failover. N&#8217;ayant plus les même besoins, je voulais réduire mes coûts de serveur tout en gardant un serveur dont je puisse gérer le système. J&#8217;ai pris l&#8217;offre de serveur dédié de 1 And 1.
Et bien [...]]]></description>
			<content:encoded><![CDATA[<p>J&#8217;avais 2 serveurs chez OVH et Dedibox qui étaient en redondance complète (fichiers, mysql, web, mails, dns) avec du DNS failover. N&#8217;ayant plus les même besoins, je voulais réduire mes coûts de serveur tout en gardant un serveur dont je puisse gérer le système. J&#8217;ai pris l&#8217;offre de serveur dédié de 1 And 1.</p>
<p>Et bien je peux vous dire que je regrette. En gros chez 1&#038;1 on a 4 Go de mémoire &#8220;disponibles&#8221; et 1 Go de mémoire &#8220;réservée&#8221;. C&#8217;est un peu comme l&#8217;illimité d&#8217;orange qui est en fait limité. La mémoire disponible est là &#8220;parfois&#8221; et on ne peut même pas préciser qu&#8217;on en veut pas. Et la mémoire réservée, j&#8217;ai bien l&#8217;impression qu&#8217;elle ne l&#8217;est pas.</p>
<p>Le soucis que j&#8217;ai c&#8217;est que par moment le noyau virtualisé refuse d&#8217;allouer de la mémoire et là tout est bloqué :</p>

<div class="wp_codebox"><table><tr id="p24934"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p2493code4"><pre class="txt" style="font-family:monospace;">[Thu Mar 11 18:45:35 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Thu Mar 11 18:45:45 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Thu Mar 11 18:49:03 2010] [error] server reached MaxClients setting, consider raising the MaxClients setting</pre></td></tr></table></div>

<p>Quand apache signale qu&#8217;il a atteint les &#8220;MaxClients&#8221; c&#8217;est qu&#8217;il est crashé. Et là c&#8217;est perdu, le serveur accepte les connexions et ne répond jamais.</p>
<p>Le &#8220;cannot allocate memory&#8221; c&#8217;est tout à fait scandaleux. Comment on peut prétendre offrir un serveur virtualisé si on est pas capable de garantir un minimum de mémoire. Le pire étant quand même que je ne consomme vraiment pas beaucoup de RAM, je ne dois jamais dépasser les 800 Mo. Mes stats actuelles sont :</p>

<div class="wp_codebox"><table><tr id="p24935"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p2493code5"><pre class="txt" style="font-family:monospace;"># free -m
             total       used       free     shared    buffers     cached
Mem:          4096        570       3525          0          0          0
-/+ buffers/cache:        570       3525
Swap:            0          0          0</pre></td></tr></table></div>

<p>Donc là j&#8217;ai l&#8217;idée brillante d&#8217;activer un fichier de swap mais au moment où j&#8217;éxecute &#8220;swapon&#8221; en fait ce n&#8217;est pas possible :</p>

<div class="wp_codebox"><table><tr id="p24936"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p2493code6"><pre class="sh" style="font-family:monospace;">dd if=/dev/zero of=/var/swapfile bs=1M count=1024
mkswap /var/swapfile
swapon /var/swapfile</pre></td></tr></table></div>

<p>J&#8217;obtiens un bel &#8220;Operation not permitted&#8221; sur cette dernière commande. C&#8217;est là aussi qu&#8217;on se dit que la virtualisation noyau c&#8217;est pas forcément top.</p>
<p>C&#8217;est assez incroyable. Je préférerais 512 Mo de RAM &#8220;pour de vrai&#8221; que 4 Go de RAM sur lesquels je ne peux pas compter. </p>
<p>Mais ce n&#8217;est pas tout. Pendant un moment le serveur n&#8217;était quasiment plus joignable, j&#8217;avais 3 paquets sur 4 qui se perdaient. Puis un autre jour la charge atteignait des niveaux affolants en continu avec un serveur quasiment au repos. Le support m&#8217;a dis que j&#8217;avais du mal configurer un truc. La panne a duré 2 jours mais bien sur ils ont répondu 2 jours plus tard. Donc forcément, ils ne constatent pas de problème. Et il faut croire qu&#8217;ils n&#8217;ont pas d&#8217;outils de monitoring de charge pour reconnaitre le problème.</p>
<p>Bref je m&#8217;en vais de chez eux. Je vais tout faire pour ne pas payer l&#8217;argent de la période d&#8217;engagement, mais je préfère encore perdre cet argent qu&#8217;avoir à supporter (et plus exactement faire supporter aux visiteurs) des sites à la disponibilité aléatoire.</p>
]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/serveur-prive-1and1-une-belle-arnaque/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Six Sigma</title>
		<link>http://florent.clairambault.fr/six-sigma</link>
		<comments>http://florent.clairambault.fr/six-sigma#comments</comments>
		<pubDate>Wed, 10 Mar 2010 23:36:41 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[business management strategy]]></category>
		<category><![CDATA[six sigma]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=2479</guid>
		<description><![CDATA[There&#8217;s a definition on wikipedia. It&#8217;s much much wider than my tiny vision of this business management strategy.
But basically this strategy says : Fix the source of every problem and not each problem. In a factory, it means that have to change the production process to reduce the probability of making defective pieces instead of [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a definition <a href="http://en.wikipedia.org/wiki/Six_Sigma">on wikipedia</a>. It&#8217;s much much wider than my tiny vision of this business management strategy.</p>
<p>But basically this strategy says : Fix the source of every problem and not each problem. In a factory, it means that have to change the production process to reduce the probability of making defective pieces instead of fixing pieces faster. That means you have to spend time on fixing the problem. So this stategy also means : <strong>Spend time to save time</strong>. <em>(I know bold formatting is evil but well&#8230; I&#8217;m evil sorry)</em></p>
<p>How that applies to me or you ? In fact everywhere. For me it can be seen as the creation of automated processes to replace some humanely driven processes. If you&#8217;ve already done a task twice and it can be optimized / automatized, then do it.</p>
<p>I&#8217;ve seen a lot of Sharepoint projects that would benefit of some &#8220;six sigma&#8221; thoughts. They often end up with a huge installation manual instead of optimizing the Sharepoint deployment package of each project.</p>
]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/six-sigma/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux prioritization : do more with less</title>
		<link>http://florent.clairambault.fr/linux-prioritization-do-more-with-less</link>
		<comments>http://florent.clairambault.fr/linux-prioritization-do-more-with-less#comments</comments>
		<pubDate>Sun, 07 Mar 2010 18:34:04 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[cfq]]></category>
		<category><![CDATA[ionice]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[nice]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[prioritization]]></category>
		<category><![CDATA[real-time]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=2452</guid>
		<description><![CDATA[I find the concept of prioritization very interesting. It just enables you to do more with less. Doesn&#8217;t that sound great ?
Let&#8217;s say you want to be able to respond to user requests as fast as possible but update your data in a low priority manner :
You can set the process CPU priority from -20 [...]]]></description>
			<content:encoded><![CDATA[<p>I find the concept of prioritization very interesting. It just enables you to do more with less. Doesn&#8217;t that sound great ?</p>
<p>Let&#8217;s say you want to be able to respond to user requests as fast as possible but update your data in a low priority manner :<br />
You can set the process CPU priority from -20 (high priority) to 19 (low priority) by using the command :</p>

<div class="wp_codebox"><table><tr id="p245212"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2452code12"><pre class="sh" style="font-family:monospace;">nice -n &lt;priority&gt; &lt;command&gt;</pre></td></tr></table></div>

<p>You can set the process IO priority in 4 classes (0: none, 1: realtime, 2: best-effort, 3: idle) with some priorities within these classes (0-7, lower being higher prio). But you have to enable the CFQ (Complete Fair Queueing) scheduler first by typing something like that :</p>

<div class="wp_codebox"><table><tr id="p245213"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2452code13"><pre class="sh" style="font-family:monospace;">echo cfq &gt;/sys/block/hda/queue/scheduler</pre></td></tr></table></div>

<p>So the ultimate low priority command will be</p>

<div class="wp_codebox"><table><tr id="p245214"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2452code14"><pre class="sh" style="font-family:monospace;">ionice -c 3 nice -n 20 &lt;command&gt;</pre></td></tr></table></div>

<p>But sometimes changing the CPU and IO priority won&#8217;t change much because the problem you might have might occur within the SQL server for say. So what you do ? Well, you could slow down your low priority program. If you have a low priority php script, you could do it like that :</p>

<div class="wp_codebox"><table><tr id="p245215"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p2452code15"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <a href="http://www.php.net/list"><span style="color: #990000;">list</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$load</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span> <a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/proc/loadavg'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'sleeping '</span><span style="color: #339933;">.</span><span style="color: #000088;">$load</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <a href="http://www.php.net/usleep"><span style="color: #990000;">usleep</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$load</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">1000000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>This program will make a loop that will slow down with the increasing load. It means that this program will always keep space of the system, even if it&#8217;s run hundreads of time.</p>
<p>So yeah, you can now manage efficiently CPU and disk. Are you done ? Not really, there&#8217;s still the memory issue. Memory (RAM) is always fast unless there&#8217;s no memory left, then it&#8217;s paged and everything becomes thousand times slower. You can only disable the virtual memory (swap on Linux), set some memory allocation limits (with ulimit), but that&#8217;s pretty much it.<br />
I would personnally recommend to disable swap and always take more RAM than needed. On servers swap prevent them from having to kill process, but they are so much slowed by it that the whole system is slowed down. And then even ssh server is so slow you have an ssh timeout before reaching the shell.</p>
<p>So, Linux has a great scheduling capacity. But what about NOT scheduling AT ALL ? Well, Linux is also very able to do that. You can put some process in real-time mode, these processes won&#8217;t be interupted by anything unless they are sleeping or waiting for an I/O event.<br />
You can use the Real-Time (RT) mode using the rtprio command :</p>

<div class="wp_codebox"><table><tr id="p245216"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2452code16"><pre class="sh" style="font-family:monospace;">rtprio 99 &lt;command&gt;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/linux-prioritization-do-more-with-less/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stupid C++ vs C# performance comparison</title>
		<link>http://florent.clairambault.fr/stupid-cpp-vs-charp-performance-comparison</link>
		<comments>http://florent.clairambault.fr/stupid-cpp-vs-charp-performance-comparison#comments</comments>
		<pubDate>Fri, 26 Feb 2010 20:00:35 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[C# .Net]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[g++]]></category>
		<category><![CDATA[gmcs]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mono]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=2409</guid>
		<description><![CDATA[I found out that there is a much better test than the one i did here. In fact the main interest of the post is this spreadsheet :



I recently did a simple and stupid comparison test between C++ (g++) and C# .Net (mono).
My point here is that C# can actually be considered as a very [...]]]></description>
			<content:encoded><![CDATA[<p>I found out that there is a much better test than the one i did <a href="http://reverseblade.blogspot.com/2009/02/c-versus-c-versus-java-performance.html">here</a>. In fact the main interest of the post is this spreadsheet :</p>
<div style="text-align: center">
<a href="http://i.mivi.fr/013092c429a64dd39a55850d8467bad0869e5b35.gif"><img src="http://i.mivi.fr/013092c429a64dd39a55850d8467bad0869e5b35.x.700.gif" /></a>
</div>
<p>I recently did a simple and stupid comparison test between C++ (g++) and C# .Net (mono).</p>
<p>My point here is that C# can actually be considered as a very fast language. It allows automatic hardware-specific optimization.<br />
Lot of people think it&#8217;s like a java, it has a virtual machine. But in fact it just compiles everything into native language when it accesses methods. This is the whole purpose of the JIT (Just Int Time compiler).</p>
<p>If you feel the JIT compiler is a possible reason of slowness (it slows down the program startup), you can pre-compile your assemblys (mono &#8211;aot on linux). If you feel the mono files are a drawback, you can bundle everything in one file using mkbundle. You can read more about this <a href="http://www.mono-project.com/Guide:Running_Mono_Applications">here</a>.</p>
<p>The only real drawback you have in the .Net framework is the garbage collector. It prevents the C# .Net it from being a realtime language/framework. But in real life usage it doesn&#8217;t slow much.</p>
<p>The purpose of the following test is to show that C++ isn&#8217;t faster than C# &#8220;as is&#8221;. I KNOW C# can not be faster than C++ because C# can do few hardware specific optimizations when you can do all of them in C++.</p>
<p>But if you&#8217;re searching for arguments to choose C# .Net over native C++, you should also consider these :</p>
<ul>
<li>C# is much more simple. No headers, the languages specifications are simple and clear</li>
<li>You don&#8217;t have to manage the memory in .Net (no memory leak, optimal memory consumption, etc.)</li>
<li>.Net don&#8217;t just crash, they always throw an exception and they only crash if nobody catches it</li>
<li>Mono (and presumely the .Net framework) does some really interesting optimizations :

<div class="wp_codebox"><table><tr id="p240926"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2409code26"><pre class="sh" style="font-family:monospace;"># mono --list-opt</pre></td></tr></table></div>

<p>I put some link so that you can learn about these really interesting optimization. This is like design patterns, you should really know these things.</em></p>
<table>
<tr>
<td>peephole</td>
<td><a href="http://en.wikipedia.org/wiki/Peephole_optimization">Peephole postpass</a></td>
</tr>
<tr>
<td>branch</td>
<td><a href="http://www.compileroptimizations.com/category/branch_optimization.htm">Branch optimizations</a></td>
</tr>
<tr>
<td>inline</td>
<td><a href="http://dotnetperls.com/inline-optimization">Inline method calls</a></td>
</tr>
<tr>
<td>cfold</td>
<td><a href="http://www.nullstone.com/htmls/category/consfold.htm">Constant folding</a></td>
</tr>
<tr>
<td>consprop</td>
<td><a href="http://en.wikipedia.org/wiki/Constant_folding#Constant_propagation">Constant propagation</a></td>
</tr>
<tr>
<td>copyprop</td>
<td><a href="http://en.wikipedia.org/wiki/Copy_propagation">Copy propagation</a></td>
</tr>
<tr>
<td>deadce</td>
<td><a href="http://en.wikipedia.org/wiki/Dead_code_elimination">Dead code elimination</a></td>
</tr>
<tr>
<td>linears</td>
<td><a href="http://en.wikipedia.org/wiki/Register_allocation">Linear scan global reg allocation</a></td>
</tr>
<tr>
<td>cmov</td>
<td><a href="http://assemblyrequired.crashworks.org/2009/01/04/fcmp-conditional-moves-for-branchless-math/">Conditional moves</a></td>
</tr>
<tr>
<td>shared</td>
<td>Emit per-domain code</td>
</tr>
<tr>
<td>sched</td>
<td><a href="http://en.wikipedia.org/wiki/Instruction_scheduling">Instruction scheduling</a></td>
</tr>
<tr>
<td>intrins</td>
<td>Intrinsic method implementations</td>
</tr>
<tr>
<td>tailc</td>
<td><a href="http://en.wikipedia.org/wiki/Tail_recursion">Tail recursion and tail calls</a></td>
</tr>
<tr>
<td>loop</td>
<td><a href="http://en.wikipedia.org/wiki/Loop_optimization">Loop related optimizations</a></td>
</tr>
<tr>
<td>fcmov</td>
<td><a href="http://en.wikipedia.org/wiki/FCMOV">Fast x86 FP compares</a></td>
</tr>
<tr>
<td>leaf</td>
<td><a href="http://moby.cs.uchicago.edu/documentation/HTML/ImplNotes/report011.html#htoc82">Leaf procedures optimizations</a></td>
</tr>
<tr>
<td>aot</td>
<td><a href="http://www.mono-project.com/AOT">Usage of Ahead Of Time compiled code</a></td>
</tr>
<tr>
<td>precomp</td>
<td>Precompile all methods before executing Main</td>
</tr>
<tr>
<td>abcrem</td>
<td><a href="http://blogs.msdn.com/clrcodegeneration/archive/2009/08/13/array-bounds-check-elimination-in-the-clr.aspx">Array bound checks removal</a></td>
</tr>
<tr>
<td>ssapre</td>
<td><a href="http://en.wikipedia.org/wiki/Partial_redundancy_elimination">SSA based Partial Redundancy Elimination</a></td>
</tr>
<tr>
<td>exception</td>
<td><a href="http://stackoverflow.com/questions/1108050/does-the-net-jit-optimize-nested-try-catch-statements">Optimize exception catch blocks</a></td>
</tr>
<tr>
<td>ssa</td>
<td><a href="http://en.wikipedia.org/wiki/Static_single_assignment_form">Use plain SSA form</a></td>
</tr>
<tr>
<td>treeprop</td>
<td>Tree propagation</td>
</tr>
<tr>
<td>sse2</td>
<td><a href="http://en.wikipedia.org/wiki/SSE2">SSE2 instructions on x86</a></td>
</tr>
<tr>
<td>gshared</td>
<td>Share generics</td>
</tr>
<tr>
<td>simd</td>
<td><a href="http://en.wikipedia.org/wiki/SIMD">Simd intrinsics</a></td>
</tr>
</table>
</li>
<li>Multithreading in .net is much easier than any other language. You even have the parrallel loop operations, like <a href="http://www.lovethedot.net/2009/02/parallelfor-deeper-dive-parallel.html">Parallel.For</a>.</li>
</ul>
<p><strong>SO ! Here is the test&#8230;</strong></p>
<p>I wrote these two sample programs :</p>
<p>One in C++ :</p>

<div class="wp_codebox"><table><tr id="p240927"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code" id="p2409code27"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#include &lt;iostream&gt;</span>
<span style="color: #0000ff;">using</span> <span style="color: #0000ff;">namespace</span> std<span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">long</span> stupidThing<span style="color: #008000;">&#40;</span> <span style="color: #0000ff;">long</span> nb <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">long</span> out <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">while</span><span style="color: #008000;">&#40;</span> nb <span style="color: #000080;">&gt;</span> <span style="color: #0000dd;">0</span> <span style="color: #008000;">&#41;</span>
		out <span style="color: #000040;">*</span><span style="color: #000080;">=</span> nb<span style="color: #000040;">--</span><span style="color: #008080;">;</span>
&nbsp;
&nbsp;
	<span style="color: #0000ff;">return</span> out<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">int</span> main<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
&nbsp;
	<span style="color: #0000ff;">long</span> total <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span> <span style="color: #0000ff;">int</span> i <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> i <span style="color: #000080;">&lt;</span> <span style="color: #0000dd;">1000000</span><span style="color: #008080;">;</span> <span style="color: #000040;">++</span>i <span style="color: #008000;">&#41;</span>
		<span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span> <span style="color: #0000ff;">long</span> l <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> l <span style="color: #000080;">&lt;</span> <span style="color: #0000dd;">100</span><span style="color: #008080;">;</span> <span style="color: #000040;">++</span>l <span style="color: #008000;">&#41;</span>
			total <span style="color: #000040;">+</span><span style="color: #000080;">=</span> stupidThing<span style="color: #008000;">&#40;</span> l <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Total : &quot;</span> <span style="color: #000080;">&lt;&lt;</span> total <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>One in C# :</p>

<div class="wp_codebox"><table><tr id="p240928"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code" id="p2409code28"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">namespace</span> test <span style="color: #008000;">&#123;</span>
        <span style="color: #6666cc; font-weight: bold;">class</span> Program <span style="color: #008000;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">long</span> stupidThing<span style="color: #008000;">&#40;</span> <span style="color: #6666cc; font-weight: bold;">long</span> nb <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
                        <span style="color: #6666cc; font-weight: bold;">long</span> ret <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">;</span>
                        <span style="color: #0600FF; font-weight: bold;">while</span> <span style="color: #008000;">&#40;</span> nb <span style="color: #008000;">&gt;</span> <span style="color: #FF0000;">0</span> <span style="color: #008000;">&#41;</span>
                                ret <span style="color: #008000;">*=</span> nb<span style="color: #008000;">--;</span>
                        <span style="color: #0600FF; font-weight: bold;">return</span> ret<span style="color: #008000;">;</span>
                <span style="color: #008000;">&#125;</span>
&nbsp;
                <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> Main<span style="color: #008000;">&#40;</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> args <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
&nbsp;
                        <span style="color: #6666cc; font-weight: bold;">long</span> total <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
&nbsp;
                        <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span> <span style="color: #6666cc; font-weight: bold;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&lt;</span> <span style="color: #FF0000;">1000000</span><span style="color: #008000;">;</span> <span style="color: #008000;">++</span>i <span style="color: #008000;">&#41;</span>
                                <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span> <span style="color: #6666cc; font-weight: bold;">long</span> l <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> l <span style="color: #008000;">&lt;</span> <span style="color: #FF0000;">100</span><span style="color: #008000;">;</span> <span style="color: #008000;">++</span>l <span style="color: #008000;">&#41;</span>
                                        total <span style="color: #008000;">+=</span> stupidThing<span style="color: #008000;">&#40;</span> l <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                        Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span> <span style="color: #666666;">&quot;Total : {0}&quot;</span>, total <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>First of all, I open a shell in real-time priority, because I don&#8217;t want my other processses to mess with my tests :</p>

<div class="wp_codebox"><table><tr id="p240929"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2409code29"><pre class="sh" style="font-family:monospace;"># rtprio 99 bash</pre></td></tr></table></div>

<p>Then I compile the two programs :</p>

<div class="wp_codebox"><table><tr id="p240930"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p2409code30"><pre class="sh" style="font-family:monospace;"># gmcs test.cs
# g++ -O4 test.cpp -o test</pre></td></tr></table></div>

<p>And then I launch my test :</p>
<p>On a 64 bits host :</p>

<div class="wp_codebox"><table><tr id="p240931"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2409code31"><pre class="txt" style="font-family:monospace;">Kernel : 2.6.9-023stab051.3-smp #1 SMP Wed Nov 4 18:36:34 MSK 2009 x86_64 x86_64 x86_64 GNU/Linux</pre></td></tr></table></div>


<div class="wp_codebox"><table><tr id="p240932"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
</pre></td><td class="code" id="p2409code32"><pre class="sh" style="font-family:monospace;"># time ./test ; time ./test ; time ./test ; time mono test.exe ; time mono test.exe ; time mono test.exe
Total : -6192109806162068864
&nbsp;
real    0m12.433s
user    0m12.394s
sys     0m0.049s
Total : -6192109806162068864
&nbsp;
real    0m12.415s
user    0m12.411s
sys     0m0.014s
Total : -6192109806162068864
&nbsp;
real    0m12.430s
user    0m12.411s
sys     0m0.026s
Total : -6192109806162068864
&nbsp;
real    0m10.311s
user    0m10.287s
sys     0m0.029s
Total : -6192109806162068864
&nbsp;
real    0m10.254s
user    0m10.247s
sys     0m0.011s
Total : -6192109806162068864
&nbsp;
real    0m10.250s
user    0m10.255s
sys     0m0.012s</pre></td></tr></table></div>

<p>C# clearly beats C++ here. Well</p>
<p>On a 32 bits host :</p>

<div class="wp_codebox"><table><tr id="p240933"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p2409code33"><pre class="txt" style="font-family:monospace;">Kernel : 2.6.30-2-686 #1 SMP Fri Dec 4 00:53:20 UTC 2009 i686 GNU/Linux</pre></td></tr></table></div>


<div class="wp_codebox"><table><tr id="p240934"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
</pre></td><td class="code" id="p2409code34"><pre class="sh" style="font-family:monospace;"># time ./test ; time ./test ; time ./test ; time mono test.exe ; time mono test.exe ; time mono test.exe
Total : 100461056
&nbsp;
real    1m10.927s
user    1m7.376s
sys     0m0.056s
Total : 100461056
&nbsp;
real    1m12.590s
user    1m8.976s
sys     0m0.020s
Total : 100461056
&nbsp;
real    1m13.279s
user    1m9.532s
sys     0m0.056s
Total : -6192109806162068864
&nbsp;
real    2m22.492s
user    2m15.260s
sys     0m0.136s
Total : -6192109806162068864
&nbsp;
real    2m23.002s
user    2m15.760s
sys     0m0.104s
Total : -6192109806162068864
&nbsp;
real    2m25.102s
user    2m17.709s
sys     0m0.144s</pre></td></tr></table></div>

<p>C++ beats C# here, but in 32 bits C++ use other types whereas C# use the same. In C# long is always 64 bits, in C++ it can be 64 bits or 32 bits (depending on the current architecture).</p>
<p>I haven&#8217;t tested this on strings but I&#8217;m pretty sure it would be slower in .Net as sizeof(Char) == 2 in C# .Net. It means that each string is two times bigger in C# .Net than in C++.</p>
]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/stupid-cpp-vs-charp-performance-comparison/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>D language</title>
		<link>http://florent.clairambault.fr/d-language</link>
		<comments>http://florent.clairambault.fr/d-language#comments</comments>
		<pubDate>Thu, 25 Feb 2010 21:57:40 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[C# .Net]]></category>
		<category><![CDATA[D language]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=2406</guid>
		<description><![CDATA[This is just a very short post about this language I recently discovered : the D language. As described on its little website : &#8220;D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. [...]]]></description>
			<content:encoded><![CDATA[<p>This is just a very short post about this language I recently discovered : the D language. As described on <a href="http://www.d-programming-language.org/">its little website</a> : &#8220;D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. Special attention is given to the needs of quality assurance, documentation, management, portability and reliability.&#8221;.</p>
<p>It has most of the features of the java and the C# (best language ever), but it is fully compiled (no JVM or JIT stuff).</p>
<p>You should have a quick loot of its features on the <a href="http://www.digitalmars.com/d/">Digital mars website</a> (they&#8217;re the who made it).</p>
<p>I wonder if this language really has a future. C# (with the .Net framework) compiles and runs on every platform (thanks to <a href="http://www.mono-project.com/">mono</a>), even <a href="http://monotouch.net/">on the iPhone</a>, so it only remove the burden of the libraries required to run .net apps.<br />
So, will it really beats its performance ? Because in C# is very fast (my next post will bring a stupid C++/C# performance comparison), and in C# avoiding time or memory consuming mistakes or multi-threading our code is very easy.</p>
]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/d-language/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SPSecurity.RunWithElevatedPrivileges</title>
		<link>http://florent.clairambault.fr/spsecurity-runwithelevatedprivileges</link>
		<comments>http://florent.clairambault.fr/spsecurity-runwithelevatedprivileges#comments</comments>
		<pubDate>Mon, 22 Feb 2010 20:00:56 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[C# .Net]]></category>
		<category><![CDATA[Sharepoint]]></category>
		<category><![CDATA[SPSite]]></category>
		<category><![CDATA[SPWeb]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=2303</guid>
		<description><![CDATA[If like me you&#8217;re wondering what exactly does SPSecurity.RunWithElevatedPrivileges, this is what I understand of it :

1
2
3
4
5
SPSecurity.RunWithElevatedPrivileges&#40; &#40;&#41; =&#62; &#123;
    using&#40; var newSite = new SPSite&#40; site.Url &#41; &#41; &#123;
        // your stuff
    &#125;
&#125;&#41;;

Is equivalent to :

1
2
3
using&#40; var newSite = new SPSite&#40; [...]]]></description>
			<content:encoded><![CDATA[<p>If like me you&#8217;re wondering what exactly does SPSecurity.RunWithElevatedPrivileges, this is what I understand of it :</p>

<div class="wp_codebox"><table><tr id="p230337"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p2303code37"><pre class="csharp" style="font-family:monospace;">SPSecurity<span style="color: #008000;">.</span><span style="color: #0000FF;">RunWithElevatedPrivileges</span><span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">=&gt;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">using</span><span style="color: #008000;">&#40;</span> var newSite <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> SPSite<span style="color: #008000;">&#40;</span> site<span style="color: #008000;">.</span><span style="color: #0000FF;">Url</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        <span style="color: #008080; font-style: italic;">// your stuff</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>Is equivalent to :</p>

<div class="wp_codebox"><table><tr id="p230338"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p2303code38"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">using</span><span style="color: #008000;">&#40;</span> var newSite <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> SPSite<span style="color: #008000;">&#40;</span> site<span style="color: #008000;">.</span><span style="color: #0000FF;">Url</span>, site<span style="color: #008000;">.</span><span style="color: #0000FF;">SystemAccount</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Token</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">// your stuff</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>So if this is just to open an elevated privilege SPSite, it will be equivalent. But if you do some more complex things, as soon as you load a new SPSite it will open it with the original UserToken. And you lose&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/spsecurity-runwithelevatedprivileges/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# .Net : How works automatic assembly versioning</title>
		<link>http://florent.clairambault.fr/c-net-how-works-automatic-assembly-versioning</link>
		<comments>http://florent.clairambault.fr/c-net-how-works-automatic-assembly-versioning#comments</comments>
		<pubDate>Sun, 21 Feb 2010 12:02:01 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[assembly versions]]></category>
		<category><![CDATA[C# .Net]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=2388</guid>
		<description><![CDATA[When you choose to automatically generate a new version of your assembly at compilation, you have to set in the AssemblyInfo.cs file, this line :

1
2
3
4
5
6
7
8
9
10
// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//     [...]]]></description>
			<content:encoded><![CDATA[<p>When you choose to automatically generate a new version of your assembly at compilation, you have to set in the AssemblyInfo.cs file, this line :</p>

<div class="wp_codebox"><table><tr id="p238841"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code" id="p2388code41"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">// Version information for an assembly consists of the following four values:</span>
<span style="color: #008080; font-style: italic;">//</span>
<span style="color: #008080; font-style: italic;">//      Major Version</span>
<span style="color: #008080; font-style: italic;">//      Minor Version </span>
<span style="color: #008080; font-style: italic;">//      Build Number</span>
<span style="color: #008080; font-style: italic;">//      Revision</span>
<span style="color: #008080; font-style: italic;">//</span>
<span style="color: #008080; font-style: italic;">// You can specify all the values or you can default the Build and Revision Numbers </span>
<span style="color: #008080; font-style: italic;">// by using the '*' as shown below:</span>
<span style="color: #008000;">&#91;</span>assembly<span style="color: #008000;">:</span> AssemblyVersion<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;1.0.*&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span></pre></td></tr></table></div>

<p>But what do these automatically generated numbers mean ? Well, chances are you don&#8217;t care. But one day after using this features for years I decided that I would.</p>
<ul>
<li>The build number is the number of days since 01/01/2000</li>
<li>The revision number if the number of 2 seconds periods since 00:00 of this day</li>
</ul>
<p>So&#8230; To get the compilation date of an assembly from its version, you would have to do :</p>

<div class="wp_codebox"><table><tr id="p238842"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p2388code42"><pre class="csharp" style="font-family:monospace;">var version <span style="color: #008000;">=</span> Assembly<span style="color: #008000;">.</span><span style="color: #0000FF;">GetExecutingAssembly</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetName</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Version</span><span style="color: #008000;">;</span>
var date <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> DateTime<span style="color: #008000;">&#40;</span> <span style="color: #FF0000;">2000</span>, 01, 01 <span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">AddDays</span><span style="color: #008000;">&#40;</span> version<span style="color: #008000;">.</span><span style="color: #0000FF;">Build</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">AddSeconds</span><span style="color: #008000;">&#40;</span> version<span style="color: #008000;">.</span><span style="color: #0000FF;">Revision</span> <span style="color: #008000;">*</span> <span style="color: #FF0000;">2</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>This feature is great if your need some atomic versionning of a particular library for instance. Each program using your library has its own version and you don&#8217;t risk to break working feature in future release of your library. And if you want to force the use of a newer version of a library within a particular application, you can use some <a href="http://msdn.microsoft.com/en-us/library/7wd6ex19(VS.71).aspx">assembly redirection</a>.<br />
But you should also note that if you deploy your assembly in the <a href="/tag/GAC">GAC</a> (like it&#8217;s required to do with Sharepoint), you will have tons of &#8220;garbage&#8221; versions of your assembly. And there&#8217;s not &#8220;easy fix&#8221; for that.</p>
]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/c-net-how-works-automatic-assembly-versioning/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Threads and Sharepoint</title>
		<link>http://florent.clairambault.fr/threads-and-sharepoint</link>
		<comments>http://florent.clairambault.fr/threads-and-sharepoint#comments</comments>
		<pubDate>Sat, 20 Feb 2010 08:00:31 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[multithreading]]></category>
		<category><![CDATA[Sharepoint]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=2321</guid>
		<description><![CDATA[When you are using threads on sharepoint, you should take care of some little things :

The method used to launch the thread must have the &#8220;[STAThread]&#8221; attribute, it avoids some huge memory leaks.
If you need to use an SPSite from the calling site, you should copy its URL and UserToken to build a new SPSite [...]]]></description>
			<content:encoded><![CDATA[<p>When you are using threads on sharepoint, you should take care of some little things :</p>
<ul>
<li>The method used to launch the thread must have the &#8220;[STAThread]&#8221; attribute, it avoids some huge memory leaks.</li>
<li>If you need to use an SPSite from the calling site, you should copy its URL and UserToken to build a new SPSite in the new thread. If you&#8217;re not using that &#8220;design pattern&#8221;, things will get really wrong.</li>
<li>And of course you should dispose any sharepoint SPSite (SPWebs come from SPSite) allocated within the thread.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/threads-and-sharepoint/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.367 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2010-03-16 18:42:57 -->
