Uploaded image for project: 'Snowstorm'
  1. Snowstorm
  2. STORM-1075

Optimization: Squared vector distance comparisons

    XMLWordPrintableJSON

    Details

    • Type: Story
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Sprint 15
    • Labels:
      None
    • Environment:
      N/A

      Description

      Scattered throughout the code are calls akin to this: dist_vec(a, b) < SOME_VALUE. Each call to dist_vec requires the use of a square root function, and as the majority of these calls are in multiple-levels-deep loops, this is likely a fair amount of time wasted when a squared comparison would do: dist_vec_squared(a, b) < SOME_VALUE_SQUARED, or even dist_vec_squared(a, b) < SOME_VALUE * SOME_VALUE.

      While testing the speed differences between the existing code and the one modified to use squared logic is likely to be complicated in this environment, a simple test (attached) was able to demonstrate that dist_vec_squared() is at least 20% faster than dist_vec().

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            cron.stardust Cron Stardust
            Prod Owner Approved:
            Grumpity ProductEngine Grumpity ProductEngine
            Extended Group Visibility:
            jira-users
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                PagerDuty