Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduced FieldCacheImpl casting/boxing #348

Merged
merged 6 commits into from
Sep 26, 2020

Conversation

NightOwl888
Copy link
Contributor

@NightOwl888 NightOwl888 commented Sep 23, 2020

This refactors FieldCacheImpl and FieldCache to take advantage of generics to reduce casting and also eliminates a particular boxing issue with the acceptableOverheadRatio value of BinaryDocValuesImpl and SortedDocValuesImpl.

The impact seems negligible on the simple case benchmarks we are using. However, we are now seeing the test times on Windows dip to lower levels than seen before.

FacetsSimple

BenchmarkDotNet=v0.12.1, OS=Windows 10.0.18363.1016 (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.301
  [Host]                      : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-beta00005             : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-beta00006             : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-beta00007             : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-beta00008             : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-beta00009             : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-beta00010             : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-beta00011             : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-beta00012             : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-ci0000002161-w-GH-344 : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-ci0000002035-w-GH-348 : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT

IterationCount=15  LaunchCount=2  WarmupCount=10  
Method Job NuGetReferences Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
RunFacetOnly 4.8.0-beta00005 Lucene.Net.Analysis.Common 4.8.0-beta00005,Lucene.Net.Facet 4.8.0-beta00005 5.409 ms 0.6411 ms 0.8987 ms - - - 2.15 MB
RunSearch 4.8.0-beta00005 Lucene.Net.Analysis.Common 4.8.0-beta00005,Lucene.Net.Facet 4.8.0-beta00005 5.240 ms 0.6124 ms 0.8783 ms - - - 2.15 MB
RunDrillDown 4.8.0-beta00005 Lucene.Net.Analysis.Common 4.8.0-beta00005,Lucene.Net.Facet 4.8.0-beta00005 7.973 ms 2.2700 ms 3.2556 ms - - - 2.25 MB
RunDrillSideways 4.8.0-beta00005 Lucene.Net.Analysis.Common 4.8.0-beta00005,Lucene.Net.Facet 4.8.0-beta00005 3.217 ms 0.4605 ms 0.6604 ms - - - 2.62 MB
RunFacetOnly 4.8.0-beta00006 Lucene.Net.Analysis.Common 4.8.0-beta00006,Lucene.Net.Facet 4.8.0-beta00006 2.944 ms 0.2626 ms 0.3766 ms - - - 2.15 MB
RunSearch 4.8.0-beta00006 Lucene.Net.Analysis.Common 4.8.0-beta00006,Lucene.Net.Facet 4.8.0-beta00006 2.820 ms 0.2576 ms 0.3694 ms - - - 2.15 MB
RunDrillDown 4.8.0-beta00006 Lucene.Net.Analysis.Common 4.8.0-beta00006,Lucene.Net.Facet 4.8.0-beta00006 2.408 ms 0.2459 ms 0.3604 ms - - - 2.25 MB
RunDrillSideways 4.8.0-beta00006 Lucene.Net.Analysis.Common 4.8.0-beta00006,Lucene.Net.Facet 4.8.0-beta00006 2.478 ms 0.2063 ms 0.2959 ms - - - 2.62 MB
RunFacetOnly 4.8.0-beta00007 Lucene.Net.Analysis.Common 4.8.0-beta00007,Lucene.Net.Facet 4.8.0-beta00007 2.463 ms 0.3290 ms 0.4719 ms - - - 2.13 MB
RunSearch 4.8.0-beta00007 Lucene.Net.Analysis.Common 4.8.0-beta00007,Lucene.Net.Facet 4.8.0-beta00007 3.086 ms 0.5328 ms 0.7810 ms - - - 2.13 MB
RunDrillDown 4.8.0-beta00007 Lucene.Net.Analysis.Common 4.8.0-beta00007,Lucene.Net.Facet 4.8.0-beta00007 2.762 ms 0.3603 ms 0.5168 ms - - - 2.23 MB
RunDrillSideways 4.8.0-beta00007 Lucene.Net.Analysis.Common 4.8.0-beta00007,Lucene.Net.Facet 4.8.0-beta00007 2.301 ms 0.2218 ms 0.3181 ms - - - 2.6 MB
RunFacetOnly 4.8.0-beta00008 Lucene.Net.Analysis.Common 4.8.0-beta00008,Lucene.Net.Facet 4.8.0-beta00008 2.580 ms 0.2657 ms 0.3811 ms - - - 2.17 MB
RunSearch 4.8.0-beta00008 Lucene.Net.Analysis.Common 4.8.0-beta00008,Lucene.Net.Facet 4.8.0-beta00008 2.237 ms 0.2688 ms 0.3768 ms - - - 2.17 MB
RunDrillDown 4.8.0-beta00008 Lucene.Net.Analysis.Common 4.8.0-beta00008,Lucene.Net.Facet 4.8.0-beta00008 2.148 ms 0.2199 ms 0.3154 ms - - - 2.27 MB
RunDrillSideways 4.8.0-beta00008 Lucene.Net.Analysis.Common 4.8.0-beta00008,Lucene.Net.Facet 4.8.0-beta00008 2.343 ms 0.2433 ms 0.3489 ms - - - 2.64 MB
RunFacetOnly 4.8.0-beta00009 Lucene.Net.Analysis.Common 4.8.0-beta00009,Lucene.Net.Facet 4.8.0-beta00009 3.205 ms 0.4344 ms 0.6503 ms - - - 2.17 MB
RunSearch 4.8.0-beta00009 Lucene.Net.Analysis.Common 4.8.0-beta00009,Lucene.Net.Facet 4.8.0-beta00009 2.736 ms 0.2491 ms 0.3572 ms - - - 2.17 MB
RunDrillDown 4.8.0-beta00009 Lucene.Net.Analysis.Common 4.8.0-beta00009,Lucene.Net.Facet 4.8.0-beta00009 2.510 ms 0.3505 ms 0.5138 ms - - - 2.27 MB
RunDrillSideways 4.8.0-beta00009 Lucene.Net.Analysis.Common 4.8.0-beta00009,Lucene.Net.Facet 4.8.0-beta00009 2.188 ms 0.2712 ms 0.3975 ms - - - 2.64 MB
RunFacetOnly 4.8.0-beta00010 Lucene.Net.Analysis.Common 4.8.0-beta00010,Lucene.Net.Facet 4.8.0-beta00010 2.380 ms 0.3773 ms 0.5411 ms - - - 2.16 MB
RunSearch 4.8.0-beta00010 Lucene.Net.Analysis.Common 4.8.0-beta00010,Lucene.Net.Facet 4.8.0-beta00010 2.603 ms 0.2714 ms 0.3893 ms - - - 2.16 MB
RunDrillDown 4.8.0-beta00010 Lucene.Net.Analysis.Common 4.8.0-beta00010,Lucene.Net.Facet 4.8.0-beta00010 2.213 ms 0.2396 ms 0.3279 ms - - - 2.26 MB
RunDrillSideways 4.8.0-beta00010 Lucene.Net.Analysis.Common 4.8.0-beta00010,Lucene.Net.Facet 4.8.0-beta00010 2.162 ms 0.2293 ms 0.3288 ms - - - 2.63 MB
RunFacetOnly 4.8.0-beta00011 Lucene.Net.Analysis.Common 4.8.0-beta00011,Lucene.Net.Facet 4.8.0-beta00011 2.570 ms 0.2390 ms 0.3427 ms - - - 2.16 MB
RunSearch 4.8.0-beta00011 Lucene.Net.Analysis.Common 4.8.0-beta00011,Lucene.Net.Facet 4.8.0-beta00011 2.574 ms 0.2493 ms 0.3576 ms - - - 2.16 MB
RunDrillDown 4.8.0-beta00011 Lucene.Net.Analysis.Common 4.8.0-beta00011,Lucene.Net.Facet 4.8.0-beta00011 2.168 ms 0.2882 ms 0.4134 ms - - - 2.26 MB
RunDrillSideways 4.8.0-beta00011 Lucene.Net.Analysis.Common 4.8.0-beta00011,Lucene.Net.Facet 4.8.0-beta00011 2.143 ms 0.2106 ms 0.3020 ms - - - 2.63 MB
RunFacetOnly 4.8.0-beta00012 Lucene.Net.Analysis.Common 4.8.0-beta00012,Lucene.Net.Facet 4.8.0-beta00012 2.579 ms 0.3045 ms 0.4367 ms - - - 2.19 MB
RunSearch 4.8.0-beta00012 Lucene.Net.Analysis.Common 4.8.0-beta00012,Lucene.Net.Facet 4.8.0-beta00012 2.748 ms 0.2675 ms 0.3837 ms - - - 2.2 MB
RunDrillDown 4.8.0-beta00012 Lucene.Net.Analysis.Common 4.8.0-beta00012,Lucene.Net.Facet 4.8.0-beta00012 2.539 ms 0.2266 ms 0.3250 ms - - - 2.29 MB
RunDrillSideways 4.8.0-beta00012 Lucene.Net.Analysis.Common 4.8.0-beta00012,Lucene.Net.Facet 4.8.0-beta00012 2.607 ms 0.2412 ms 0.3381 ms - - - 2.67 MB
RunFacetOnly 4.8.0-ci0000002161-w-GH-344 Lucene.Net.Analysis.Common 4.8.0-ci0000002161,Lucene.Net.Facet 4.8.0-ci0000002161 1.955 ms 0.1874 ms 0.2687 ms - - - 2.2 MB
RunSearch 4.8.0-ci0000002161-w-GH-344 Lucene.Net.Analysis.Common 4.8.0-ci0000002161,Lucene.Net.Facet 4.8.0-ci0000002161 2.080 ms 0.2780 ms 0.4075 ms - - - 2.2 MB
RunDrillDown 4.8.0-ci0000002161-w-GH-344 Lucene.Net.Analysis.Common 4.8.0-ci0000002161,Lucene.Net.Facet 4.8.0-ci0000002161 2.094 ms 0.2216 ms 0.3178 ms - - - 2.29 MB
RunDrillSideways 4.8.0-ci0000002161-w-GH-344 Lucene.Net.Analysis.Common 4.8.0-ci0000002161,Lucene.Net.Facet 4.8.0-ci0000002161 2.267 ms 0.2729 ms 0.3914 ms - - - 2.67 MB
RunFacetOnly 4.8.0-ci0000002035-w-GH-348 Lucene.Net.Analysis.Common 4.8.0-ci0000002035,Lucene.Net.Facet 4.8.0-ci0000002035 2.011 ms 0.1991 ms 0.2855 ms - - - 2.2 MB
RunSearch 4.8.0-ci0000002035-w-GH-348 Lucene.Net.Analysis.Common 4.8.0-ci0000002035,Lucene.Net.Facet 4.8.0-ci0000002035 2.067 ms 0.2341 ms 0.3282 ms - - - 2.2 MB
RunDrillDown 4.8.0-ci0000002035-w-GH-348 Lucene.Net.Analysis.Common 4.8.0-ci0000002035,Lucene.Net.Facet 4.8.0-ci0000002035 2.260 ms 0.2747 ms 0.3940 ms - - - 2.29 MB
RunDrillSideways 4.8.0-ci0000002035-w-GH-348 Lucene.Net.Analysis.Common 4.8.0-ci0000002035,Lucene.Net.Facet 4.8.0-ci0000002035 2.438 ms 0.2855 ms 0.4095 ms - - - 2.67 MB

IndexFiles

BenchmarkDotNet=v0.12.1, OS=Windows 10.0.18363.1016 (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.301
  [Host]                      : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-beta00005             : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-beta00006             : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-beta00007             : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-beta00008             : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-beta00009             : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-beta00010             : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-beta00011             : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-beta00012             : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-ci0000002161-w-GH-344 : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-ci0000002035-w-GH-348 : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), 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 697.2 ms 13.89 ms 19.92 ms 44000.0000 8000.0000 7000.0000 220.95 MB
IndexFiles 4.8.0-beta00006 Lucene.Net.Analysis.Common 4.8.0-beta00006 698.9 ms 20.54 ms 30.11 ms 44000.0000 8000.0000 7000.0000 221.01 MB
IndexFiles 4.8.0-beta00007 Lucene.Net.Analysis.Common 4.8.0-beta00007 693.7 ms 16.44 ms 22.51 ms 44000.0000 8000.0000 7000.0000 220.8 MB
IndexFiles 4.8.0-beta00008 Lucene.Net.Analysis.Common 4.8.0-beta00008 695.1 ms 16.57 ms 24.29 ms 44000.0000 8000.0000 7000.0000 221.12 MB
IndexFiles 4.8.0-beta00009 Lucene.Net.Analysis.Common 4.8.0-beta00009 712.7 ms 16.01 ms 23.47 ms 44000.0000 8000.0000 7000.0000 221.2 MB
IndexFiles 4.8.0-beta00010 Lucene.Net.Analysis.Common 4.8.0-beta00010 704.8 ms 14.72 ms 22.03 ms 44000.0000 8000.0000 7000.0000 221.32 MB
IndexFiles 4.8.0-beta00011 Lucene.Net.Analysis.Common 4.8.0-beta00011 705.1 ms 15.98 ms 22.40 ms 44000.0000 8000.0000 7000.0000 221.17 MB
IndexFiles 4.8.0-beta00012 Lucene.Net.Analysis.Common 4.8.0-beta00012 735.9 ms 12.89 ms 18.07 ms 56000.0000 7000.0000 6000.0000 286.82 MB
IndexFiles 4.8.0-ci0000002161-w-GH-344 Lucene.Net.Analysis.Common 4.8.0-ci0000002161 732.3 ms 16.84 ms 23.06 ms 56000.0000 7000.0000 6000.0000 286.76 MB
IndexFiles 4.8.0-ci0000002035-w-GH-348 Lucene.Net.Analysis.Common 4.8.0-ci0000002035 728.2 ms 12.59 ms 18.05 ms 56000.0000 7000.0000 6000.0000 286.78 MB

SearchFiles

BenchmarkDotNet=v0.12.1, OS=Windows 10.0.18363.1016 (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.301
  [Host]                      : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-beta00005             : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-beta00006             : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-beta00007             : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-beta00008             : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-beta00009             : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-beta00010             : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-beta00011             : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-beta00012             : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-ci0000002161-w-GH-344 : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT
  4.8.0-ci0000002035-w-GH-348 : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT

IterationCount=15  LaunchCount=2  WarmupCount=10  
Method Job NuGetReferences Mean Error StdDev 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 152.65 ms 3.971 ms 5.944 ms 8750.0000 250.0000 - 41.39 MB
SearchFiles 4.8.0-beta00006 Lucene.Net.Analysis.Common 4.8.0-beta00006,Lucene.Net.QueryParser 4.8.0-beta00006 152.97 ms 6.662 ms 9.766 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 149.74 ms 4.525 ms 6.489 ms 8000.0000 1000.0000 - 41.27 MB
SearchFiles 4.8.0-beta00008 Lucene.Net.Analysis.Common 4.8.0-beta00008,Lucene.Net.QueryParser 4.8.0-beta00008 88.69 ms 1.628 ms 2.387 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 86.05 ms 0.987 ms 1.478 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 87.25 ms 1.140 ms 1.522 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 85.76 ms 1.277 ms 1.872 ms 8666.6667 500.0000 - 40.19 MB
SearchFiles 4.8.0-beta00012 Lucene.Net.Analysis.Common 4.8.0-beta00012,Lucene.Net.QueryParser 4.8.0-beta00012 86.86 ms 0.862 ms 1.236 ms 8833.3333 333.3333 - 40.81 MB
SearchFiles 4.8.0-ci0000002161-w-GH-344 Lucene.Net.Analysis.Common 4.8.0-ci0000002161,Lucene.Net.QueryParser 4.8.0-ci0000002161 86.55 ms 0.442 ms 0.619 ms 8833.3333 333.3333 - 40.81 MB
SearchFiles 4.8.0-ci0000002035-w-GH-348 Lucene.Net.Analysis.Common 4.8.0-ci0000002035,Lucene.Net.QueryParser 4.8.0-ci0000002035 87.11 ms 1.224 ms 1.715 ms 8833.3333 333.3333 - 40.81 MB

… by making FieldCacheImpl.Cache and FieldCacheImpl.CacheKey classes generic. Removed unnecessary loops in PurgeByCacheKey() and GetCacheEntries().
…red Get methods inline using delegate methods
…eholder and changed CreationPlaceholder to CreationPlaceholder<TValue>. Changed FieldCacheImpl.Cache to use <TKey, TValue> to reduce casting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant