Operation.createMsgWireMessage() allocates memory inefficiently

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Minor - P4
    • 1.11.0
    • Affects Version/s: 1.5.2
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      This loop in Operation.createMsgWireMessage() is inefficient:

      for _, doc := range op.Batches.Current {
          dst = append(dst, doc...)
      } 

      since dst is not at the required cap before the loop, it causes multiple allocations and the final cap of dst can be up to 2x larger than needed.

      Calculating the total length of batches in op.Batches.Current and resizing dst before the loop would be more efficient.

       

       

            Assignee:
            Qingyang Hu
            Reporter:
            Tim Fogarty
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: