lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [lucenenet] NightOwl888 opened a new pull request #383: Fix for Delegate-based Asserts
Date Tue, 03 Nov 2020 21:17:40 GMT

NightOwl888 opened a new pull request #383:
URL: https://github.com/apache/lucenenet/pull/383


   This fixes the issue that was discussed at length in #373, #372, and #346. Thanks to @theolivenbaum
for initially coming up with this idea. The solution we ended up with was to mimic the built-in
`System.Diagnostics.Debug.Assert(bool, string, string, object[])` method signature with some
important differences:
   
   1. Instead of passing an object array, we pass generic parameters to avoid boxing on the
initial call.
   2. Use `J2N.Text.StringFormatter` (in the invariant culture) to automatically format passed
in collections and arrays rather than using `Arrays.ToString()` or `Collections.ToString()`
helper methods.
   
   Arguments were modified to do a minimum of processing upon the function call. We still
have some light math and other processing, but the heavier operations were deferred by wrapping
raw parameters into a `struct` that overloads `object.ToString()` in order to do the processing
only in the case where the assert fails.
   
   There was only 1 edge case in `IndexWriter` where the `Debug.Assert` method approach was
abandoned and the condition and throw were placed inline to avoid unnecessary object locking.
   
   ## Benchmarks
   
   ### IndexFiles
   
   ``` ini
   
   BenchmarkDotNet=v0.12.1, OS=Windows 10.0.18363.1082 (1909/November2018Update/19H2)
   Intel Core i7-8850H CPU 2.60GHz (Coffee Lake), 1 CPU, 12 logical and 6 physical cores
   .NET Core SDK=3.1.403
     [Host]                    : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203),
X64 RyuJIT
     4.8.0-beta00005           : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203),
X64 RyuJIT
     4.8.0-beta00006           : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203),
X64 RyuJIT
     4.8.0-beta00007           : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203),
X64 RyuJIT
     4.8.0-beta00008           : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203),
X64 RyuJIT
     4.8.0-beta00009           : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203),
X64 RyuJIT
     4.8.0-beta00010           : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203),
X64 RyuJIT
     4.8.0-beta00011           : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203),
X64 RyuJIT
     4.8.0-beta00012           : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203),
X64 RyuJIT
     4.8.0-wip00_before_GH-383 : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203),
X64 RyuJIT
     4.8.0-wip01_after_GH-383  : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203),
X64 RyuJIT
   
   InvocationCount=1  IterationCount=15  LaunchCount=2  
   UnrollFactor=1  WarmupCount=10  
   
   ```
   |     Method |                       Job |                               NuGetReferences
|     Mean |    Error |   StdDev |      Gen 0 |     Gen 1 |     Gen 2 | Allocated |
   |----------- |-------------------------- |----------------------------------------------
|---------:|---------:|---------:|-----------:|----------:|----------:|----------:|
   | IndexFiles |           4.8.0-beta00005 |    Lucene.Net.Analysis.Common 4.8.0-beta00005
| 728.9 ms | 29.40 ms | 44.01 ms | 43000.0000 | 8000.0000 | 7000.0000 | 220.97 MB |
   | IndexFiles |           4.8.0-beta00006 |    Lucene.Net.Analysis.Common 4.8.0-beta00006
| 706.2 ms | 31.32 ms | 44.91 ms | 44000.0000 | 8000.0000 | 7000.0000 | 221.05 MB |
   | IndexFiles |           4.8.0-beta00007 |    Lucene.Net.Analysis.Common 4.8.0-beta00007
| 682.4 ms | 11.91 ms | 17.08 ms | 43000.0000 | 8000.0000 | 7000.0000 | 220.88 MB |
   | IndexFiles |           4.8.0-beta00008 |    Lucene.Net.Analysis.Common 4.8.0-beta00008
| 688.6 ms | 13.02 ms | 18.67 ms | 44000.0000 | 8000.0000 | 7000.0000 | 221.39 MB |
   | IndexFiles |           4.8.0-beta00009 |    Lucene.Net.Analysis.Common 4.8.0-beta00009
| 694.2 ms | 17.55 ms | 25.72 ms | 44000.0000 | 8000.0000 | 7000.0000 | 221.23 MB |
   | IndexFiles |           4.8.0-beta00010 |    Lucene.Net.Analysis.Common 4.8.0-beta00010
| 686.0 ms |  9.90 ms | 14.19 ms | 44000.0000 | 8000.0000 | 7000.0000 | 221.25 MB |
   | IndexFiles |           4.8.0-beta00011 |    Lucene.Net.Analysis.Common 4.8.0-beta00011
| 672.3 ms | 12.04 ms | 17.65 ms | 44000.0000 | 8000.0000 | 7000.0000 | 221.32 MB |
   | IndexFiles |           4.8.0-beta00012 |    Lucene.Net.Analysis.Common 4.8.0-beta00012
| 723.5 ms | 15.38 ms | 21.56 ms | 56000.0000 | 7000.0000 | 6000.0000 | 286.98 MB |
   | IndexFiles | 4.8.0-wip00_before_GH-383 | Lucene.Net.Analysis.Common 4.8.0-ci0000002206
| 710.9 ms |  9.76 ms | 14.00 ms | 56000.0000 | 7000.0000 | 6000.0000 | 286.92 MB |
   | IndexFiles |  4.8.0-wip01_after_GH-383 | Lucene.Net.Analysis.Common 4.8.0-ci0000002207
| 676.7 ms | 13.18 ms | 19.31 ms | 43000.0000 | 8000.0000 | 7000.0000 |    220 MB |
   
   ### SearchFiles
   
   ``` ini
   
   BenchmarkDotNet=v0.12.1, OS=Windows 10.0.18363.1082 (1909/November2018Update/19H2)
   Intel Core i7-8850H CPU 2.60GHz (Coffee Lake), 1 CPU, 12 logical and 6 physical cores
   .NET Core SDK=3.1.403
     [Host]                    : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203),
X64 RyuJIT
     4.8.0-beta00005           : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203),
X64 RyuJIT
     4.8.0-beta00006           : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203),
X64 RyuJIT
     4.8.0-beta00007           : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203),
X64 RyuJIT
     4.8.0-beta00008           : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203),
X64 RyuJIT
     4.8.0-beta00009           : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203),
X64 RyuJIT
     4.8.0-beta00010           : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203),
X64 RyuJIT
     4.8.0-beta00011           : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203),
X64 RyuJIT
     4.8.0-beta00012           : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203),
X64 RyuJIT
     4.8.0-wip00_before_GH-383 : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203),
X64 RyuJIT
     4.8.0-wip01_after_GH-383  : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203),
X64 RyuJIT
   
   IterationCount=15  LaunchCount=2  WarmupCount=10  
   
   ```
   |      Method |                       Job |                                           
                             NuGetReferences |      Mean |     Error |    StdDev |    Median
|     Gen 0 |     Gen 1 | Gen 2 | Allocated |
   |------------ |-------------------------- |----------------------------------------------------------------------------------------
|----------:|----------:|----------:|----------:|----------:|----------:|------:|----------:|
   | SearchFiles |           4.8.0-beta00005 |       Lucene.Net.Analysis.Common 4.8.0-beta00005,Lucene.Net.QueryParser
4.8.0-beta00005 | 147.19 ms |  4.647 ms |  6.956 ms | 148.25 ms | 8750.0000 |  500.0000 |
    - |  41.39 MB |
   | SearchFiles |           4.8.0-beta00006 |       Lucene.Net.Analysis.Common 4.8.0-beta00006,Lucene.Net.QueryParser
4.8.0-beta00006 | 147.26 ms |  5.150 ms |  7.550 ms | 148.73 ms | 8750.0000 |  500.0000 |
    - |  41.37 MB |
   | SearchFiles |           4.8.0-beta00007 |       Lucene.Net.Analysis.Common 4.8.0-beta00007,Lucene.Net.QueryParser
4.8.0-beta00007 | 146.96 ms |  4.879 ms |  7.303 ms | 146.52 ms | 8750.0000 |  250.0000 |
    - |  41.26 MB |
   | SearchFiles |           4.8.0-beta00008 |       Lucene.Net.Analysis.Common 4.8.0-beta00008,Lucene.Net.QueryParser
4.8.0-beta00008 |  87.58 ms |  1.373 ms |  1.925 ms |  87.11 ms | 8666.6667 |  500.0000 |
    - |  40.33 MB |
   | SearchFiles |           4.8.0-beta00009 |       Lucene.Net.Analysis.Common 4.8.0-beta00009,Lucene.Net.QueryParser
4.8.0-beta00009 |  98.01 ms | 12.322 ms | 17.274 ms |  87.68 ms | 8666.6667 |  500.0000 |
    - |  40.33 MB |
   | SearchFiles |           4.8.0-beta00010 |       Lucene.Net.Analysis.Common 4.8.0-beta00010,Lucene.Net.QueryParser
4.8.0-beta00010 |  90.83 ms |  2.601 ms |  3.730 ms |  90.26 ms | 8666.6667 |  500.0000 |
    - |  40.19 MB |
   | SearchFiles |           4.8.0-beta00011 |       Lucene.Net.Analysis.Common 4.8.0-beta00011,Lucene.Net.QueryParser
4.8.0-beta00011 |  94.19 ms |  3.758 ms |  5.625 ms |  95.31 ms | 8600.0000 |  200.0000 |
    - |  40.19 MB |
   | SearchFiles |           4.8.0-beta00012 |       Lucene.Net.Analysis.Common 4.8.0-beta00012,Lucene.Net.QueryParser
4.8.0-beta00012 |  97.76 ms |  3.418 ms |  4.903 ms |  96.53 ms | 8833.3333 |  333.3333 |
    - |  40.81 MB |
   | SearchFiles | 4.8.0-wip00_before_GH-383 | Lucene.Net.Analysis.Common 4.8.0-ci0000002206,Lucene.Net.QueryParser
4.8.0-ci0000002206 |  96.67 ms |  3.957 ms |  5.800 ms |  94.47 ms | 9000.0000 | 2000.0000
|     - |  40.79 MB |
   | SearchFiles |  4.8.0-wip01_after_GH-383 | Lucene.Net.Analysis.Common 4.8.0-ci0000002207,Lucene.Net.QueryParser
4.8.0-ci0000002207 |  97.11 ms |  2.398 ms |  3.589 ms |  96.91 ms | 8666.6667 |  333.3333
|     - |  40.17 MB |
   
   With these changes, in both `IndexFiles` and `SearchFiles` RAM consumption was reduced
lower than any previously released version and raw performance of `IndexFiles` has also improved.
   
   This basically gives us as good or better performance than we had when we compiled the
asserts out of the application.


----------------------------------------------------------------
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



Mime
View raw message