Poupou's blog http://pages.infinit.net/ctech/poupou.html Looking for perfect security? Try a wireless brick.<br> Otherwise you may find some unperfect stuff here... Copyright &copy; 2003-2006 S&eacute;bastien Pouliot. All rights reserved. Thu, 14 Aug 2008 19:40:22 GMT spouliot@videotron.ca spouliot@videotron.ca Blog-e-ho! Gendarme 0.2 140d0be2-c273-4cc5-aa3c-fd37cde70189 http://pages.infinit.net/ctech/20080716-1115.html Wed, 16 Jul 2008 23:15:34 GMT <p>Mono has branched for 2.0! Quite a good news for everyone. It's also a great moment for all gendarmes because it means we branched too! <p>The <a href="http://www.mono-project.com/Gendarme" target="_blank">Gendarme</a> 0.2 release includes the results of the last six months of hacking, including some major events like the Novell Hack Week (Winter 2008 edition), which changed much of the Gendarme framework, the first "Gendarme Rule Day" and the first part of <a href="http://code.google.com/soc/2008/" target="_blank">GSoC 2008</a> work by <a href="http://nestor.babuine.net/" target="_blank">N&eacute;stor Salceda</a>. <p><b>General highlights:</b> <ul> <li>Performance enhancements, memory usage reduction (mostly inside <a href="http://www.mono-project.com/Cecil" target="_blank">Cecil</a> but the gains are very visible in Gendarme) <li>MDB/PDB support: source files and line numbers are now provided with defects <li>New Windows installer: You can now easily enjoy Gendarme, and it's wizard, from Windows computers <li>.desktop file for the Wizard runner <li>Console runner now uses color when displaying on the console <li>Albeit a bit invisible to end users, we started using the new unit test helpers made during <a href="http://code.google.com/opensource/ghop/2007-8/" target="_blank">GHOP</a> <li>Bug fixes: works continue, like previous releases, to remove false positives from existing rules <li>and a lot of new rules including... </ul> <p><b>Gendarme.Rules.BadPractice</b></p> <ul> <li>AvoidCallingProblematicMethodsRule <li>AvoidVisibleConstantFieldRule <li>DoNotForgetNotImplementedMethodsRule <li>DisableDebuggingCodeRule <li>ObsoleteMessagesShouldNotBeEmptyRule <li>ReplaceIncompleteOddnessCheckRule </ul> <p><b>Gendarme.Rules.Concurrency</b></p> <ul> <li>DoNotLockOnThisOrTypesRule <li>DoNotLockOnWeakIdentityObjectsRule <li>DoNotUseLockedRegionOutsideMethodRule </ul> <p><b>Gendarme.Rules.Correctness</b></p> <ul> <li>DoNotRoundIntegersRule <li>ReviewDoubleAssignmentRule <li>ReviewSelfAssignmentRule <li>ReviewUselessControlFlow <li>ReviewUseOfInt64BitsToDoubleRule <li>ReviewUseOfModuloOneOnIntegersRule </ul> <p><b>Gendarme.Rules.Design</b></p> <ul> <li>AvoidMultidimensionalIndexerRule <li>AvoidRefAndOutParametersRule <li>AvoidVisibleNestedTypesRule <li>ConsiderConvertingFieldToNullableRule <li>ConsiderUsingStaticTypeRule <li>ImplementGenericCollectionInterfacesRule <li>ImplementIComparableCorreclyRule <li>PreferIntegerOrStringForIndexersRule </ul> <p><b>Gendarme.Rules.Exception</b></p> <ul> <li>AvoidArgumentExceptionDefaultConstructorRule <li>AvoidThrowingBasicExceptionsRule <li>DoNotThrowReservedExceptionRule <li>ExceptionShouldBeVisibleRule <li>MissingExceptionConstructorsRule </ul> <p><b>Gendarme.Rules.Interoperability</b></p> <ul> <li>DoNotCastIntPtrToInt32Rule </ul> <p><b>Gendarme.Rules.Maintainability (new)</b></p> <ul> <li>AvoidComplexMethodsRule <li>AvoidDeepInheritanceTreeRule <li>AvoidLackOfCohesionOfMethodRule <li>ConsiderUsingStopwatchRule <li>PreferStringIsNullOrEmptyRule </ul> <p><b>Gendarme.Rules.Naming</b></p> <ul> <li>DoNotPrefixEventsWithAfterOrBeforeRule </ul> <p><b>Gendarme.Rules.Performance</b></p> <ul> <li>AvoidLargeNumberOfLocalVariablesRule <li>AvoidLargeStructureRule <li>AvoidRepetitiveCastsRule <li>AvoidTypeGetTypeWhenPossibleRule <li>AvoidUnusedPrivateFieldsRule <li>AvoidUnneededUnboxingRule <li>AvoidUnsealedUninheritedInternalClassesRule <li>ImplementEqualsTypeRule <li>OverrideValueTypeDefaultsRule <li>RemoveUnusedLocalVariablesRule <li>UseIsOperatorRule <li>UseTypeEmptyTypesRule </ul> <p><b>Gendarme.Rules.Portability</b></p> <ul> <li>DoNotHardcodePathsRule </ul> <p><b>Gendarme.Rules.Serialization (new)</b></p> <ul> <li>CallBaseMethodsOnISerializableTypesRule <li>DeserializeOptionalFieldRule <li>ImplementISerializableCorrectlyRule <li>MarkAllNonSerializableFieldsRule <li>MissingSerializableAttributeOnISerializableTypeRule <li>MissingSerializationConstructorRule <li>UseCorrectSignatureForSerializationMethodsRule </ul> <p>Contributors for this release are:<br> Andres G. Aragoneses, Cedric Vivier, Daniel Abramov, JB Evain, Nestor Salceda, Scott Peterson, Sebastien Pouliot, Seo Sanghyeon. <p><b>Availability</b>: Preview packages should be available soon (Gendarme resides inside <b>mono-tools</b>). I'll update the Win32 installer asap (probably tomorrow night), check the <a href="http://groups.google.com/group/gendarme" target="_blank">Files</a> section of the group to get it. Now is the time for testing and reporting :-) Thanks to everyone! </p> Gendarme Speed Up 300e6800-efde-4d32-906f-3c08ae661912 http://pages.infinit.net/ctech/20080717-0655.html Thu, 17 Jul 2008 18:55:11 GMT <p>In the last six months a lot of attention was given to <a href="http://www.mono-project.com/Gendarme" target="_blank">Gendarme</a>'s performance. First we updated it's framework to make it easier to <i>skip</i> rules when they are not applicable, e.g. checking for 2.0 features inside a 1.x assembly. Then I spent some time reducing memory allocations in <a href="http://www.mono-project.com/Cecil" target="_blank">Cecil</a>. Since Gendarme is a big consumer (it reads everything) even small gains show up quickly. </p> <p>This was an important step to move forward because the some of the new features, like <b>debugging symbols</b> (mdb and pdb on windows) and automatic <b>assembly resolving</b> were sure to require a lot more time (and memory) to process rules (not to mention that the number of rules is itself growing fast). Also to keep its value Gendarme, or at least its default rule set, needs to execute quickly enough that there's <b>no good reason</b> not to execute it at each build. And finally it's also because we're not much more patient than our users - we want results <b>now</b> :-) <p>So last night I took the time to measure how the new Gendarme 0.2, to be released with <a href="http://www.mono-project.com/" target="_blank">Mono</a> 2.0, compares the the old Gendarme 0.0.5.1 released with Mono 1.9. The next table shows the time (in seconds) required to analyze the 72 assemblies that Mono ships for it's 2.0 profile. </p> <p> <table border=1 cellpadding=5 cellspacing=0> <tr><td><td align="center" colspan=2>Gendarme 0.0.5.1<td colspan=2 align="center">Gendarme 0.2.0.0<td align="center" colspan=2>Change<td align="center" rowspan=2>Mean time per<br>rule delta <tr><td><td align="center"># rules<td align="center">time<td align="center"># rules<td align="center">time<td>rules factor<td>time factor <tr><td>BadPractice <td align="right">7 <td align="right">9.39688 <td align="right">13 <td align="right">21.933973 <td align="right">186% <td align="right">233.42% <td align="right">0.34 <tr><td>Concurrency <td align="right">3 <td align="right">9.703159 <td align="right">6 <td align="right">14.05999 <td align="right">200% <td align="right">144.90% <td align="right">-0.89 <tr><td>Correctness <td align="right">7 <td align="right">11.732152 <td align="right">13 <td align="right">15.228963 <td align="right">186% <td align="right">129.81% <td align="right">-0.50 <tr><td>Design <td align="right">25 <td align="right">4.235242 <td align="right">33 <td align="right">4.29234 <td align="right">132% <td align="right">101.35% <td align="right">-0.04 <tr><td>Exceptions <td align="right">2 <td align="right">9.467328 <td align="right">7 <td align="right">16.499359 <td align="right">350% <td align="right">174.28% <td align="right">-2.38 <tr><td>Interoperability<td align="right">4 <td align="right">8.841298 <td align="right">5 <td align="right">14.582129 <td align="right">125% <td align="right">164.93% <td align="right">0.71 <tr><td>Maintainability <td align="right">0 <td align="right">0 <td align="right">6 <td align="right">18.499207 <td align="right">N/A <td align="right">N/A <td align="right">N/A <tr><td>Naming <td align="right">11 <td align="right">8.352653 <td align="right">12 <td align="right">2.133514 <td align="right">109% <td align="right">25.54% <td align="right">-0.58 <tr><td>Performance <td align="right">13 <td align="right">157.135513 <td align="right">25 <td align="right">39.716426 <td align="right">192% <td align="right">25.28% <td align="right">-10.50 <tr><td>Portability <td align="right">4 <td align="right">11.556642 <td align="right">5 <td align="right">42.844831 <td align="right">125% <td align="right">370.74% <td align="right">5.68 <tr><td>Security <td align="right">10 <td align="right">6.434193 <td align="right">10 <td align="right">8.709008 <td align="right">100% <td align="right">135.36% <td align="right">0.23 <tr><td>Serialization <td align="right">0 <td align="right">0 <td align="right">7 <td align="right">1.539076 <td align="right">N/A <td align="right">N/A <td align="right">N/A <tr><td>Smells <td align="right">6 <td align="right">652.999564 <td align="right">6 <td align="right">685.303299 <td align="right">100% <td align="right">104.95% <td align="right">5.38 <tr><td>UI <td align="right">3 <td align="right">3.163413 <td align="right">3 <td align="right">0.106041 <td align="right">100% <td align="right">3.35% <td align="right">-1.02 <tr><td><td ><td ><td ><td ><td><td> <tr><td><b>TOTAL</b> <td align="right">95 <td align="right">893.018037 <td align="right">151 <td align="right">885.448156 <td align="right">159% <td align="right">99.15% <td align="right">-3.54 <tr><td><td ><td ><td ><td ><td><td> <tr><td>default <td align="right">89 <td align="right">172.60422 <td align="right">145 <td align="right">99.322118 <td align="right">163% <td align="right">57.54% <td align="right">-1.25 </table> <p>The number of rules and execution times are given for each rule assembly/category. We can see the impact of the new features when looking at <b>Security</b>, it has the same number of rules but it now requires 35% more time to execute them. We can also see how skipping rules can help in <b>UI</b> where it nows takes only 3% of the previous time to execute the rules (since UI rules don't applies to the class librairies).</p> <p>The good news is that, globally, executing every rules takes just a bit less time than before. Considering that we added <b>56 rules</b> in this release this was quite a nice surprise (even if a bit planned I did not anticipate a <i>status quo</i>). But the results are even better if we consider Gendarme's <b>default</b> rule set (i.e. everything but the Smell rules) as it requires less than 60% of the time than the previous version did, even with the extra 56 rules. <p> Results are still preliminary since Mono 2.0 won't ship until September. Some existing rules don't yet take advantages of the new API and I intend to update them (or at least a few of them) before then and provide an updated table. And who knows maybe I'll even dive into Cecil a littl'bit more ;-) </p> <p>There is no end in performance (so expect more blog entries on the subject ;-). We need to stay vigilant because even small things, like memory allocations, can make big differences in rules executed thousands of times. We already have ideas to speed up a lot of rules using a new feature. This should happen in the next Novell Hack Week and the results will be visible in Mono 2.1. With a bit of luck we'll have more rules and results in even less time (or at least worked upon that goal). <p> Big Bump 51f778c7-9c07-402a-9f7a-1b01a2aaa9c8 http://pages.infinit.net/ctech/20080814-0733.html Thu, 14 Aug 2008 19:33:21 GMT <p>Earlier this week the <a href="http://www.mono-project.com/" target="_blank">Mono</a> 2.0 branch was tagged for preview #2. Included with it, inside <b>mono-tools</b>, is the updated <a href="http://www.mono-project.com/Gendarme" target="_blank">Gendarme</a>. <p>Most of the <a href="http://anonsvn.mono-project.com/source/branches/mono-2-0/mono-tools/gendarme/NEWS" target="_blank">changes</a> between now and the first preview are not very visible. Like promised a lots of rules were tweaked to reduce false positives. Some of them were also optimized to be (quite a bit) faster. <b>A big thanks to everyone for the feedback (and the patches too ;-).</b> Hopefully I'll have time to get more fixes into the branch before the release candidate in early September. <p>So what's the most visible change ? Well from now on Gendarme version will match Mono version numbers. This should avoid any confusion (e.g. bug reports) concerning the versions and it also answers the feedback I received that 0.2 was not very representative of Gendarme's status. <p>This second preview is also a good time to update the performance table of my previous <a href="http://pages.infinit.net/ctech/20080717-0655.html" target="_blank">blog entry</a>. Again I compared the time needed for Gendarme 0.0.5.1, shipped with Mono 1.9.1 (confusing heh?), versus the 2.0p2 release (less confusing :-) by executing each rule category (and default one) on all (72) Mono 2.0 assemblies. <p> <table border=1 cellpadding=5 cellspacing=0> <tr><td><td align="center" colspan=2>Gendarme 0.0.5.1<td colspan=2 align="center">Gendarme 2.0 p2<td align="center" colspan=2>Change<td align="center" rowspan=2>Mean time per<br>rule delta <tr><td><td align="center"># rules<td align="center">time<td align="center"># rules<td align="center">time<td>rules factor<td>time factor <tr><td>BadPractice <td align="right">7 <td align="right">9.839234 <td align="right">13 <td align="right">20.940601 <td align="right">186% <td align="right">212.83% <td align="right">0.21 <tr><td>Concurrency <td align="right">3 <td align="right">10.03967 <td align="right">6 <td align="right">14.167014 <td align="right">200% <td align="right">141.11% <td align="right">-0.99 <tr><td>Correctness <td align="right">7 <td align="right">11.229753 <td align="right">13 <td align="right">15.350205 <td align="right">186% <td align="right">136.69% <td align="right">-0.42 <tr><td>Design <td align="right">25 <td align="right">4.437044 <td align="right">33 <td align="right">3.738977 <td align="right">132% <td align="right">84.27% <td align="right">-0.06 <tr><td>Exceptions <td align="right">2 <td align="right">9.743716 <td align="right">7 <td align="right">16.194831 <td align="right">350% <td align="right">166.21% <td align="right">-2.56 <tr><td>Interoperability<td align="right">4 <td align="right">9.044328 <td align="right">5 <td align="right">14.150847 <td align="right">125% <td align="right">156.46% <td align="right">0.57 <tr><td>Maintainability <td align="right">0 <td align="right">0 <td align="right">6 <td align="right">17.895726 <td align="right">N/A <td align="right">N/A <td align="right">N/A <tr><td>Naming <td align="right">11 <td align="right">8.482943 <td align="right">12 <td align="right">2.145394 <td align="right">109% <td align="right">25.29% <td align="right">-0.59 <tr><td>Performance <td align="right">13 <td align="right">155.027838 <td align="right">25 <td align="right">33.18588 <td align="right">192% <td align="right">21.41% <td align="right">-10.60 <tr><td>Portability <td align="right">4 <td align="right">11.598787 <td align="right">5 <td align="right">21.198526 <td align="right">125% <td align="right">182.77% <td align="right">1.34 <tr><td>Security <td align="right">10 <td align="right">6.734685 <td align="right">10 <td align="right">8.593943 <td align="right">100% <td align="right">127.61% <td align="right">0.19 <tr><td>Serialization <td align="right">0 <td align="right">0 <td align="right">7 <td align="right">1.349845 <td align="right">N/A <td align="right">N/A <td align="right">N/A <tr><td>Smells <td align="right">6 <td align="right">652.531303 <td align="right">6 <td align="right">686.105971 <td align="right">100% <td align="right">105.15% <td align="right">5.60 <tr><td>UI <td align="right">3 <td align="right">3.272789 <td align="right">3 <td align="right">0.114405 <td align="right">100% <td align="right">3.50% <td align="right">-1.05 <tr><td><td ><td ><td ><td ><td><td> <tr><td><b>TOTAL</b> <td align="right">95 <td align="right">891.98209 <td align="right">151 <td align="right">855.132165 <td align="right">159% <td align="right">95.87% <td align="right">-3.73 <tr><td><td ><td ><td ><td ><td><td> <tr><td>default <td align="right">89 <td align="right">174.698965 <td align="right">145 <td align="right">67.466905 <td align="right">163% <td align="right">38.62% <td align="right">-1.50 </table> <p>So the new total percentage of 95.87% is a bit better than the previous one (99.15%). Not surprising since the smells are taking a huge amount of time, compared to all other rules, and have not been much optimized since the first preview (but I got ideas for them too ;-). <p>However there's a bigger difference for the <i>default</i> rule set (what the console runner execute unless instructed otherwise). It nows takes 38.62% of the time (versus 57.54% for the first preview). In both cases the times are compared to the version 0.0.5.1 and includes the 56 <b>additional</b> rules. <p>The win32 installer for Gendarme 2.0p2 will be available shortly on the <a href="http://groups.google.com/group/gendarme/files?hl=en" target=_blank>google group file section</a>. Linux packages (i.e. mono-tools) should be available early next week.