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

Check whether liveDoc is null out of loop in Weight.scoreAll #13557

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

vsop-479
Copy link
Contributor

Description

I am not sure whether it is worth to do that, or whether JIT will do similar optimization.

@jpountz
Copy link
Contributor

jpountz commented Jul 10, 2024

Can you check if this helps with luceneutil on wikimedium10m or wikibigall?

@vsop-479
Copy link
Contributor Author

Can you check if this helps with luceneutil on wikimedium10m or wikibigall?

Sure, I will do that soon.

@vsop-479
Copy link
Contributor Author

@jpountz

I measured it with luceneutil on wikimedium10m:

TaskQPS baseline      StdDevQPS my_modified_version      StdDev                Pct diff p-value
               HighTermMonthSort     4422.96      (6.3%)     4272.29      (5.8%)   -3.4% ( -14% -    9%) 0.076
       BrowseDayOfYearTaxoFacets       38.19     (28.4%)       37.06     (33.2%)   -3.0% ( -50% -   81%) 0.762
            BrowseDateTaxoFacets       37.85     (28.4%)       36.78     (33.4%)   -2.8% ( -50% -   82%) 0.773
     BrowseRandomLabelSSDVFacets       22.71      (9.6%)       22.27      (7.9%)   -1.9% ( -17% -   17%) 0.484
                    OrNotHighLow     2643.42      (4.9%)     2596.34      (5.3%)   -1.8% ( -11% -    8%) 0.271
       BrowseDayOfYearSSDVFacets       27.46      (9.6%)       27.22      (4.4%)   -0.9% ( -13% -   14%) 0.706
                          IntNRQ       81.34      (9.3%)       80.63     (10.3%)   -0.9% ( -18% -   20%) 0.777
                   OrHighNotHigh      562.10      (3.2%)      558.03      (3.4%)   -0.7% (  -7% -    6%) 0.488
                HighSloppyPhrase       16.47      (2.6%)       16.36      (2.9%)   -0.7% (  -6% -    4%) 0.448
               HighTermTitleSort      138.98      (5.4%)      138.26      (5.3%)   -0.5% ( -10% -   10%) 0.761
                    OrNotHighMed      594.27      (3.2%)      591.52      (3.1%)   -0.5% (  -6% -    6%) 0.646
                       LowPhrase      104.35      (3.3%)      103.94      (3.0%)   -0.4% (  -6% -    6%) 0.695
                      AndHighLow     1913.21      (2.8%)     1906.77      (3.0%)   -0.3% (  -5% -    5%) 0.715
                      OrHighHigh       80.80      (2.1%)       80.58      (3.1%)   -0.3% (  -5% -    5%) 0.748
         AndHighMedDayTaxoFacets      164.44      (2.2%)      164.00      (1.8%)   -0.3% (  -4% -    3%) 0.672
                        PKLookup      361.45      (2.7%)      360.51      (2.5%)   -0.3% (  -5% -    5%) 0.749
                      AndHighMed      164.72      (1.3%)      164.31      (2.6%)   -0.2% (  -4% -    3%) 0.703
                     AndHighHigh      115.25      (1.4%)      115.04      (2.7%)   -0.2% (  -4% -    3%) 0.787
                 MedSloppyPhrase       53.74      (2.0%)       53.66      (1.9%)   -0.1% (  -3% -    3%) 0.812
                       MedPhrase      219.79      (2.3%)      219.48      (3.0%)   -0.1% (  -5% -    5%) 0.868
                    OrHighNotLow      783.90      (5.0%)      783.58      (4.8%)   -0.0% (  -9% -   10%) 0.978
                          Fuzzy2       34.75      (2.1%)       34.76      (1.6%)    0.0% (  -3% -    3%) 0.960
                      HighPhrase      176.79      (3.3%)      176.90      (4.1%)    0.1% (  -7% -    7%) 0.956
                         Respell      146.62      (2.6%)      146.83      (2.2%)    0.1% (  -4% -    5%) 0.846
                 LowSloppyPhrase      144.71      (1.6%)      144.93      (1.6%)    0.1% (  -2% -    3%) 0.766
                   OrNotHighHigh      673.32      (3.7%)      674.49      (2.8%)    0.2% (  -6% -    6%) 0.868
                       OrHighMed      329.23      (2.7%)      330.13      (2.9%)    0.3% (  -5% -    6%) 0.758
                       OrHighLow      766.63      (2.8%)      768.92      (3.7%)    0.3% (  -6% -    7%) 0.775
            MedTermDayTaxoFacets      106.35      (2.2%)      106.74      (3.0%)    0.4% (  -4% -    5%) 0.660
          OrHighMedDayTaxoFacets       24.88      (4.9%)       24.97      (5.7%)    0.4% (  -9% -   11%) 0.825
                          Fuzzy1      166.68      (2.3%)      167.39      (2.1%)    0.4% (  -3% -    4%) 0.540
                     MedSpanNear       15.57      (1.6%)       15.64      (1.6%)    0.4% (  -2% -    3%) 0.374
                    OrHighNotMed      723.31      (3.9%)      726.73      (4.2%)    0.5% (  -7% -    8%) 0.715
                    HighSpanNear       11.64      (2.0%)       11.70      (1.4%)    0.5% (  -2% -    3%) 0.366
             LowIntervalsOrdered       38.55      (2.3%)       38.75      (3.6%)    0.5% (  -5% -    6%) 0.598
                        Wildcard      358.09      (4.1%)      359.94      (2.7%)    0.5% (  -6% -    7%) 0.637
                         Prefix3      558.81      (2.2%)      562.08      (2.2%)    0.6% (  -3% -    5%) 0.397
                         LowTerm     1284.45      (4.0%)     1292.67      (4.8%)    0.6% (  -7% -    9%) 0.648
            HighTermTitleBDVSort       15.89      (6.3%)       15.99      (5.3%)    0.7% ( -10% -   13%) 0.716
                     LowSpanNear      131.68      (1.8%)      132.65      (2.1%)    0.7% (  -3% -    4%) 0.234
             MedIntervalsOrdered      147.08      (5.7%)      148.26      (7.1%)    0.8% ( -11% -   14%) 0.694
        AndHighHighDayTaxoFacets       30.27      (2.4%)       30.52      (2.5%)    0.8% (  -4% -    5%) 0.290
                        HighTerm      997.31      (4.2%)     1007.39      (5.6%)    1.0% (  -8% -   11%) 0.517
            HighIntervalsOrdered       45.58      (7.3%)       46.10      (8.9%)    1.1% ( -14% -   18%) 0.659
                         MedTerm     1346.48      (4.1%)     1362.76      (4.6%)    1.2% (  -7% -   10%) 0.377
           BrowseMonthTaxoFacets       33.39     (39.0%)       33.80     (42.3%)    1.2% ( -57% -  135%) 0.924
           BrowseMonthSSDVFacets       27.50      (6.0%)       27.85      (4.4%)    1.3% (  -8% -   12%) 0.448
                      TermDTSort      390.29      (6.8%)      397.80      (7.1%)    1.9% ( -11% -   16%) 0.382
            BrowseDateSSDVFacets        5.50     (18.1%)        5.61     (20.3%)    2.1% ( -30% -   49%) 0.727
           HighTermDayOfYearSort      853.40      (4.4%)      875.72      (4.4%)    2.6% (  -5% -   11%) 0.060
     BrowseRandomLabelTaxoFacets       39.50     (44.1%)       40.98     (51.4%)    3.7% ( -63% -  177%) 0.805
@jpountz
Copy link
Contributor

jpountz commented Jul 11, 2024

It looks like it doesn't make a difference? HighTermDayOfYearSort has a speedup with a low p-value, but then HighTermMonthSort has a slowdown with a low p-value as well, so I suspect it's still noise as the change should affect these two queries in a similar way.

@vsop-479
Copy link
Contributor Author

I think I could dig more by printing assembly code.

@vsop-479
Copy link
Contributor Author

FWIW, I also measured performance with luceneutil on wikimediumall:

                            TaskQPS baseline      StdDevQPS my_modified_version      StdDev                Pct diff p-value
           BrowseMonthTaxoFacets        9.14     (37.7%)        8.26     (37.2%)   -9.6% ( -61% -  104%) 0.417
                      TermDTSort      287.26      (5.0%)      275.16      (4.6%)   -4.2% ( -13% -    5%) 0.005
                        HighTerm      600.85      (7.3%)      586.62      (5.0%)   -2.4% ( -13% -   10%) 0.230
                         MedTerm      810.95      (7.0%)      797.22      (4.3%)   -1.7% ( -12% -   10%) 0.357
                         LowTerm      720.16      (3.3%)      711.89      (3.8%)   -1.1% (  -8% -    6%) 0.310
                          Fuzzy2       40.88      (1.6%)       40.44      (2.5%)   -1.1% (  -5% -    3%) 0.106
                     AndHighHigh       44.49      (7.3%)       44.03      (7.4%)   -1.0% ( -14% -   14%) 0.660
                      HighPhrase       23.40      (4.5%)       23.16      (3.2%)   -1.0% (  -8% -    6%) 0.418
                       LowPhrase       11.92      (4.1%)       11.81      (3.1%)   -0.9% (  -7% -    6%) 0.415
                       OrHighMed      146.50      (3.9%)      145.26      (3.7%)   -0.8% (  -8% -    7%) 0.487
                    OrHighNotMed      586.89      (4.5%)      582.26      (3.0%)   -0.8% (  -7% -    7%) 0.516
     BrowseRandomLabelSSDVFacets        6.02      (7.9%)        5.97      (8.0%)   -0.8% ( -15% -   16%) 0.764
          OrHighMedDayTaxoFacets        3.14      (4.6%)        3.11     (10.3%)   -0.7% ( -14% -   14%) 0.767
                      AndHighMed      149.15      (6.1%)      148.05      (5.7%)   -0.7% ( -11% -   11%) 0.693
               HighTermTitleSort      228.51      (2.1%)      227.11      (1.7%)   -0.6% (  -4% -    3%) 0.309
                         Respell       71.57      (1.5%)       71.14      (2.4%)   -0.6% (  -4% -    3%) 0.340
           HighTermDayOfYearSort      477.62      (4.9%)      474.75      (5.1%)   -0.6% ( -10% -    9%) 0.703
                      AndHighLow      671.48      (5.2%)      667.92      (4.8%)   -0.5% ( -10% -    9%) 0.737
                      OrHighHigh       51.74      (3.0%)       51.48      (3.4%)   -0.5% (  -6% -    6%) 0.610
                        Wildcard       68.64      (2.9%)       68.31      (3.0%)   -0.5% (  -6% -    5%) 0.608
                   OrHighNotHigh      390.49      (5.3%)      388.66      (3.3%)   -0.5% (  -8% -    8%) 0.736
                       MedPhrase       59.57      (3.4%)       59.34      (2.6%)   -0.4% (  -6% -    5%) 0.692
                   OrNotHighHigh      612.50      (3.4%)      610.26      (2.8%)   -0.4% (  -6% -    6%) 0.710
                          Fuzzy1      112.10      (1.9%)      111.83      (2.3%)   -0.2% (  -4% -    3%) 0.708
                       OrHighLow      514.72      (3.0%)      513.46      (3.1%)   -0.2% (  -6% -    6%) 0.803
                         Prefix3      270.57      (1.6%)      270.06      (2.0%)   -0.2% (  -3% -    3%) 0.749
                    OrHighNotLow      493.27      (6.0%)      492.41      (3.7%)   -0.2% (  -9% -   10%) 0.913
               HighTermMonthSort     3485.92      (3.2%)     3482.83      (6.2%)   -0.1% (  -9% -    9%) 0.955
                    OrNotHighMed      268.56      (2.5%)      268.39      (2.1%)   -0.1% (  -4% -    4%) 0.931
            HighTermTitleBDVSort       12.55      (1.1%)       12.55      (1.2%)   -0.0% (  -2% -    2%) 0.933
                HighSloppyPhrase       12.47      (1.9%)       12.48      (1.3%)    0.1% (  -3% -    3%) 0.891
                    OrNotHighLow      772.28      (2.7%)      773.69      (2.4%)    0.2% (  -4% -    5%) 0.822
         AndHighMedDayTaxoFacets       22.12      (1.8%)       22.17      (1.6%)    0.2% (  -3% -    3%) 0.701
            MedTermDayTaxoFacets        9.58      (2.0%)        9.61      (3.0%)    0.3% (  -4% -    5%) 0.679
       BrowseDayOfYearSSDVFacets        7.27      (9.9%)        7.30      (9.5%)    0.5% ( -17% -   22%) 0.878
                        PKLookup      301.97      (2.6%)      303.50      (2.2%)    0.5% (  -4% -    5%) 0.501
        AndHighHighDayTaxoFacets        6.02      (4.2%)        6.05      (3.4%)    0.6% (  -6% -    8%) 0.629
            BrowseDateSSDVFacets        1.52     (13.1%)        1.53     (18.1%)    0.8% ( -26% -   36%) 0.873
                     MedSpanNear       13.30      (2.3%)       13.42      (1.8%)    0.9% (  -3% -    5%) 0.162
                     LowSpanNear      100.75      (2.5%)      101.71      (2.1%)    1.0% (  -3% -    5%) 0.185
                    HighSpanNear       18.34      (2.6%)       18.55      (2.2%)    1.2% (  -3% -    6%) 0.127
                 MedSloppyPhrase       12.38      (2.9%)       12.54      (2.1%)    1.3% (  -3% -    6%) 0.108
                 LowSloppyPhrase       74.43      (3.1%)       75.64      (2.5%)    1.6% (  -3% -    7%) 0.068
            HighIntervalsOrdered        2.36     (13.2%)        2.40     (12.8%)    1.8% ( -21% -   31%) 0.670
             MedIntervalsOrdered       18.99     (11.5%)       19.38     (10.9%)    2.0% ( -18% -   27%) 0.567
             LowIntervalsOrdered        7.53     (12.3%)        7.73     (11.1%)    2.6% ( -18% -   29%) 0.480
                          IntNRQ       31.23     (14.1%)       32.16     (15.5%)    3.0% ( -23% -   37%) 0.525
           BrowseMonthSSDVFacets        7.41     (14.8%)        7.64     (19.2%)    3.1% ( -26% -   43%) 0.573
       BrowseDayOfYearTaxoFacets        7.93     (25.0%)        8.67     (41.3%)    9.3% ( -45% -  100%) 0.388
            BrowseDateTaxoFacets        7.85     (25.4%)        8.62     (41.7%)    9.8% ( -45% -  103%) 0.368
     BrowseRandomLabelTaxoFacets        7.25     (45.5%)        8.53     (68.1%)   17.6% ( -65% -  240%) 0.337
@vsop-479
Copy link
Contributor Author

I also tested it by adding simulation code under jmh ( just ensure they get right optimization), there is no difference neither :

Benchmark                       (size)   Mode  Cnt  Score   Error   Units
VectorUtilBenchmark.score1         256  thrpt   15  1.980 ± 0.010  ops/us
VectorUtilBenchmark.score1:asm     256  thrpt         NaN             ---
VectorUtilBenchmark.score2         256  thrpt   15  1.987 ± 0.004  ops/us
VectorUtilBenchmark.score2:asm     256  thrpt         NaN             ---

But, there Hottest Region in the check line is different (1.17% vs 0.04%).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants