Optimize equalTopologies to reduce or eliminate allocations

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Works as Designed
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Go Drivers
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      Context

      The existing equalTopologies implementation builds two temporary maps on every invocation to check that two description.Topology instances contain the same set of servers. In a busy topology monitor this could translate into millions of small heap allocations. The profile on the associate PR noted ~1GB per 2 hours.

      Definition of done

      Either replace the comparison with an O(n^2) solution that does not allocate the temporary maps or consider using maps to pointers of the servers.

      Pitfalls

      Creating a map to pointers of the servers could be risky, for example what happens when we re-allocate the underlying slice?

            Assignee:
            Preston Vasquez
            Reporter:
            Preston Vasquez
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: