Skip to content

Adding benchmark for histogram collector over point range query #14622

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

Merged
merged 6 commits into from
May 9, 2025

Conversation

jainankitk
Copy link
Contributor

Description

Adding benchmark for histogram collection over point range query

@jainankitk jainankitk marked this pull request as ready for review May 7, 2025 02:09
@jainankitk
Copy link
Contributor Author

Running the benchmark showed significant regression for histogram collection over point range query:

  Benchmark                                             (bucketWidth)  (docCount)  (pointEnabled)   Mode  Cnt        Score         Error  Units 
  HistogramCollectorBenchmark.pointRangeQueryHistogram           5000      500000            true  thrpt    3      138.569 ±       9.962  ops/s 
  HistogramCollectorBenchmark.pointRangeQueryHistogram           5000      500000           false  thrpt    3  1337483.389 ± 1216305.085  ops/s 
  HistogramCollectorBenchmark.pointRangeQueryHistogram           5000     5000000            true  thrpt    3       13.192 ±       1.157  ops/s 
  HistogramCollectorBenchmark.pointRangeQueryHistogram           5000     5000000           false  thrpt    3   800590.737 ±  636745.705  ops/s 
  HistogramCollectorBenchmark.pointRangeQueryHistogram          25000      500000            true  thrpt    3      147.852 ±      24.356  ops/s 
  HistogramCollectorBenchmark.pointRangeQueryHistogram          25000      500000           false  thrpt    3  1390016.374 ± 1364214.885  ops/s 
  HistogramCollectorBenchmark.pointRangeQueryHistogram          25000     5000000            true  thrpt    3       12.907 ±       0.491  ops/s 
  HistogramCollectorBenchmark.pointRangeQueryHistogram          25000     5000000           false  thrpt    3  1254743.974 ± 1336923.037  ops/s

@jainankitk
Copy link
Contributor Author

Then, I realized that while CELL_OUTSIDE_QUERY was not possible for MATCH_ALL, it is possible for PointRangeQuery. Not having that condition, prevents early termination for cases the whole subtree is outside the desired range. After adding the condition, benchmark significantly improved (more than 10x), but still worse than original:

Benchmark                                             (bucketWidth)  (docCount)  (pointEnabled)   Mode  Cnt        Score         Error  Units
  HistogramCollectorBenchmark.pointRangeQueryHistogram           5000      500000            true  thrpt    3     6076.706 ±    2409.983  ops/s 
  HistogramCollectorBenchmark.pointRangeQueryHistogram           5000      500000           false  thrpt    3  1358382.893 ± 1334350.071  ops/s 
  HistogramCollectorBenchmark.pointRangeQueryHistogram           5000     5000000            true  thrpt    3      882.275 ±     116.196  ops/s 
  HistogramCollectorBenchmark.pointRangeQueryHistogram           5000     5000000           false  thrpt    3   795601.855 ±  674228.821  ops/s 
  HistogramCollectorBenchmark.pointRangeQueryHistogram          25000      500000            true  thrpt    3    14128.799 ±    6995.352  ops/s 
  HistogramCollectorBenchmark.pointRangeQueryHistogram          25000      500000           false  thrpt    3  1406723.413 ±  618403.154  ops/s
  HistogramCollectorBenchmark.pointRangeQueryHistogram          25000     5000000            true  thrpt    3     3439.462 ±     360.741  ops/s 
  HistogramCollectorBenchmark.pointRangeQueryHistogram          25000     5000000           false  thrpt    3  1247846.878 ± 1234125.682  ops/s 

@jainankitk
Copy link
Contributor Author

Okay, something weird going on here. Benchmark for matchAll query is as expected:

  Benchmark                                           (bucketWidth)  (docCount)  (pointEnabled)   Mode  Cnt     Score     Error  Units                                               
  HistogramCollectorBenchmark.matchAllQueryHistogram           5000      500000            true  thrpt    3   947.650 ±  36.350  ops/s                                               
  HistogramCollectorBenchmark.matchAllQueryHistogram           5000      500000           false  thrpt    3   180.365 ±   4.737  ops/s                                               
  HistogramCollectorBenchmark.matchAllQueryHistogram           5000     5000000            true  thrpt    3    97.463 ±  19.101  ops/s                                               
  HistogramCollectorBenchmark.matchAllQueryHistogram           5000     5000000           false  thrpt    3    19.030 ±   0.944  ops/s                                               
  HistogramCollectorBenchmark.matchAllQueryHistogram          25000      500000            true  thrpt    3  4640.059 ± 631.876  ops/s                                               
  HistogramCollectorBenchmark.matchAllQueryHistogram          25000      500000           false  thrpt    3   181.535 ±   3.220  ops/s                                               
  HistogramCollectorBenchmark.matchAllQueryHistogram          25000     5000000            true  thrpt    3   468.640 ±  57.924  ops/s                                               
  HistogramCollectorBenchmark.matchAllQueryHistogram          25000     5000000           false  thrpt    3    19.088 ±   1.099  ops/s

Even, when I changed the lower/upper bound to match all the documents in PointRangeQuery:

  Benchmark                                             (bucketWidth)  (docCount)  (pointEnabled)   Mode  Cnt        Score         Error  Units                                      
  HistogramCollectorBenchmark.pointRangeQueryHistogram           5000      500000            true  thrpt    3      949.155 ±      94.558  ops/s                                      
  HistogramCollectorBenchmark.pointRangeQueryHistogram           5000      500000           false  thrpt    3  1356118.125 ± 1468756.207  ops/s                                      
  HistogramCollectorBenchmark.pointRangeQueryHistogram           5000     5000000            true  thrpt    3      100.393 ±       7.364  ops/s                                      
  HistogramCollectorBenchmark.pointRangeQueryHistogram           5000     5000000           false  thrpt    3   814632.141 ±  547994.672  ops/s                                      
  HistogramCollectorBenchmark.pointRangeQueryHistogram          25000      500000            true  thrpt    3     4625.734 ±     979.925  ops/s                                      
  HistogramCollectorBenchmark.pointRangeQueryHistogram          25000      500000           false  thrpt    3  1362663.491 ± 3491626.784  ops/s                                      
  HistogramCollectorBenchmark.pointRangeQueryHistogram          25000     5000000            true  thrpt    3      454.742 ±      45.212  ops/s                                      
  HistogramCollectorBenchmark.pointRangeQueryHistogram          25000     5000000           false  thrpt    3  1249472.910 ± 1696940.142  ops/s

The results with pointsEnabled is fairly consistent, but much different for docValues case, even compared to MATCH_ALL which doesn't make sense at all, as docCount being iterated over is the same

@jainankitk
Copy link
Contributor Author

Okay, I was trying to use PointRangeQuery with NumericDocValuesField which is not correct. After fixing that, results are as expected:

  Benchmark                                             (bucketWidth)  (docCount)  (pointEnabled)   Mode  Cnt      Score      Error  Units                                           
  HistogramCollectorBenchmark.pointRangeQueryHistogram           5000      500000            true  thrpt    3   6379.911 ± 2605.358  ops/s                                           
  HistogramCollectorBenchmark.pointRangeQueryHistogram           5000      500000           false  thrpt    3    120.113 ±    6.797  ops/s                                           
  HistogramCollectorBenchmark.pointRangeQueryHistogram           5000     5000000            true  thrpt    3    868.640 ±  128.468  ops/s                                           
  HistogramCollectorBenchmark.pointRangeQueryHistogram           5000     5000000           false  thrpt    3     12.404 ±    0.100  ops/s                                           
  HistogramCollectorBenchmark.pointRangeQueryHistogram          25000      500000            true  thrpt    3  14202.749 ± 2581.651  ops/s                                           
  HistogramCollectorBenchmark.pointRangeQueryHistogram          25000      500000           false  thrpt    3    120.191 ±    7.646  ops/s                                           
  HistogramCollectorBenchmark.pointRangeQueryHistogram          25000     5000000            true  thrpt    3   3366.509 ±  134.193  ops/s                                           
  HistogramCollectorBenchmark.pointRangeQueryHistogram          25000     5000000           false  thrpt    3     12.409 ±    0.495  ops/s

This PR is in good shape for review now.

@jainankitk
Copy link
Contributor Author

Merging this change as it primarily adds new benchmark, and small bug fix with significant performance impact (more than 10x). Ran the unit tests locally for 10k iterations to confirm no regressions:

> Task :lucene:core:testClasses
> Task :lucene:core:test
> Task :lucene:core:wipeTaskTemp

> Task :lucene:sandbox:test
:lucene:sandbox:test (SUCCESS): 10000 test(s)

> Task :lucene:sandbox:wipeTaskTemp
The slowest suites (exceeding 1s) during this run:
  172.96s TestHistogramCollectorManager (:lucene:sandbox)

[Incubating] Problems report is available at: file:///Users/akjain/ws/lucene/build/reports/problems/problems-report.html

BUILD SUCCESSFUL in 3m 17s
246 actionable tasks: 242 executed, 4 up-to-date

@jainankitk jainankitk merged commit 22279df into apache:main May 9, 2025
7 checks passed
@jainankitk jainankitk deleted the mrt-bench branch May 9, 2025 17:19
jainankitk added a commit that referenced this pull request May 9, 2025
* Adding benchmark for histogram collector over point range query

* Fixing perf issue when subtree doesnt overlap query for histogram collection
weizijun added a commit to weizijun/lucene that referenced this pull request May 16, 2025
* main: (31 commits)
  Fix termination condition in TestStressNRTReplication. (apache#14665)
  deps(java): bump com.gradle.develocity from 3.19 to 3.19.2 (apache#14662)
  Build: remove hard-coded Java versions from ecj.javadocs.prefs (apache#14651)
  Update verifier comment to show label (apache#14658)
  Catch and re-throw Throwable rather than using a success boolean (apache#14633)
  Mention label in changelog verifier comment (apache#14656)
  Enable PR actions in changelog verifier (apache#14644)
  Fix FuzzySet#getEstimatedNumberUniqueValuesAllowingForCollisions to properly account for hashCount (apache#14614)
  Don't perform additional KNN querying after timeout, fixes apache#14639 (apache#14640)
  Add instructions to help/IDEs.txt for VSCode and Neovim (apache#14646)
  build(deps): bump ruff from 0.11.7 to 0.11.8 in /dev-tools/scripts (apache#14603)
  deps(java): bump de.jflex:jflex from 1.8.2 to 1.9.1 (apache#14583)
  Use the preload hint on completion fields and memory terms dictionaries. (apache#14634)
  Clean up FileTypeHint a bit. (apache#14635)
  Expressions: Improve test to use a fully private class or method
  Remove deprecations in expressions (apache#14641)
  removing constructor with deprecated attribute 'onlyLongestMatch (apache#14356)
  Moving CHANGES entry for apache#14609 from 11.0 to 10.3 (apache#14638)
  Overrides rewrite in PointRangeQuery to optimize AllDocs/NoDocs cases (apache#14609)
  Adding benchmark for histogram collector over point range query (apache#14622)
  ...

# Conflicts:
#	lucene/CHANGES.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant