You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by GitBox <gi...@apache.org> on 2020/10/17 16:49:58 UTC

[GitHub] [lucenenet] theolivenbaum commented on issue #346: Remove Debugging.AssertsEnabled

theolivenbaum commented on issue #346:
URL: https://github.com/apache/lucenenet/issues/346#issuecomment-711044655


   @NightOwl888  I'm reviewing my previous benchmarks on our usage of Lucene today, and I think my initial conclusion on Debugging.AssertsEnabled being the cause of the "slowness" of FixedBitSet.Set / Get is actually incorrect.
   
   Using dotMemory now to measure memory allocations, one can clearly see that there is a lambda capture being allocated on every call to the FixedBitSet.Set / Get methods.
   ![image](https://user-images.githubusercontent.com/8791811/96348382-9d078d00-10a8-11eb-8f0c-afb7dfdc7ea5.png)
   
   This can also be seen on [SharpLab](https://sharplab.io/#v2:D4AQTAjAsAUCDMACEEBsyyICIFMBGArgOZECWAdkYrAN6yIPJIrp4D2bANogIIDOfHACcALnwCi5AIZ5OOACYBueoxUMEyNMgAsvAcJEAKdl0QBjNuXmkRpSwBpkAVgA8AZRFCKRAHyIAtjgCUkQ4AOI45MJSImxCAJRqiHQwjGnUqYwAvrA5MLCwGuCIAGKkAB4KAEI2bjgitEkUIsLS3EI4UvKWnACeiJyWRADaALqIeDZ8ypkMza1S7Z3d5H2IzYjkBP41YjNp80JtiB1dPf0bW/4A6nHy00lJRbp1RhsU8jjlibPJSQcAM0QhlwhBI3gAdPxBKIJNJZAp4th8MQyJQofpRIYPl9ED4ALyIAAMiAAZKT1lZcS5NttdnxHIYkfi/AAiHHlfGsxAAakpn3KvMQrMcV3pXKFYqm8X26Tm5BEiAA7ncAHLbRCEjl4vyoRSIAD0BsQ1gAbohUNp/owNpNFVqqYKKUTyvAAfqjQE2PILVbfmlBpQJjZ/FI+ABrTWICAAGUQLhpdtlcrtfGGKqE8nV/nGwEJdtDEeTiCyqhgWSAA) if we look at the decompiled C# code:
   
   `````csharp
   public class FixedBitSet
   {
       [CompilerGenerated]
       private sealed class <>c__DisplayClass3_0
       {
           public int index;
   
           public FixedBitSet <>4__this;
   
           internal string <Set>b__0()
           {
               return "index=" + index + ", numBits=" + <>4__this.numBits;
           }
       }
   
       internal readonly long[] bits;
   
       internal readonly int numBits;
   
       internal readonly int numWords;
   
       public void Set(int index)
       {
           <>c__DisplayClass3_0 <>c__DisplayClass3_ = new <>c__DisplayClass3_0();    <------ unnecessary allocation, probably due to the capture of numBits
           <>c__DisplayClass3_.index = index;
           <>c__DisplayClass3_.<>4__this = this;
           if (Debugging.AssertsEnabled)
           {
               Debugging.Assert(<>c__DisplayClass3_.index >= 0 && <>c__DisplayClass3_.index < numBits, new Func<string>(<>c__DisplayClass3_.<Set>b__0));
           }
           int num = <>c__DisplayClass3_.index >> 6;
           int num2 = <>c__DisplayClass3_.index & 0x3F;
           long num3 = 1L << num2;
           bits[num] |= num3;
       }
   }
   `````
   
   
   @NightOwl888 I'll push a pull request with only the fix for this asap
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org