Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-10453

Speed up VectorUtil#squareDistance

Details

    • Task
    • Status: Reopened
    • Minor
    • Resolution: Fixed
    • None
    • 9.1
    • None
    • New

    Description

      VectorUtil#squareDistance is used in conjunction with VectorSimilarityFunction#EUCLIDEAN.

      It didn't get as much love as dot products (LUCENE-9837) yet there seems to be room for improvement. I wrote a quick JMH benchmark to run some comparisons: https://github.com/jpountz/vector-similarity-benchmarks.

      While it's not as fast as using the vector API (which makes squareDistance computations more than 2x faster), we can get a ~25% speedup by unrolling the loop in a similar way to what dot product does.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jpountz Adrien Grand
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m