Uploaded image for project: 'Qpid'
  1. Qpid
  2. QPID-3378

QPID python client API, bad performance about RangedSet.add

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 0.6, 0.8, 0.10
    • Fix Version/s: None
    • Component/s: Python Client
    • Labels:
    • Environment:

      winxp; intel E7500; 2G

      Description

      To feedback to server the mesages that client had been received, client should use:
      >>> session.message_accept(Range)
      while the Range is a qpid.datatypes.RangedSet object. My test shows that it has a bad performance when we want to feedback a batch at one time, test code as attachment.

      Compring to the original RangedSet.add, the function enhanceadd could have a much better performance. Also, in enhanceadd situation, some code in original RangedSet are useless as following:
      ---------------------------------code-----------
      def add_range(self, range):
      idx = 0
      while idx < len(self.ranges):
      r = self.ranges[idx]
      if range.touches(r):
      del self.ranges[idx]
      range = range.span(r)
      elif range.upper < r.lower:
      self.ranges.insert(idx, range)
      return
      else:
      idx += 1
      self.ranges.append(range)

      def add(self, lower, upper = None):
      self.add_range(Range(lower, upper))
      ---------------------------------code-----------
      it can be changed like with a further improvment:
      ---------------------------------code-----------
      def add(self, lower, upper = None):
      self.ranges.append((Range(lower, upper))
      ---------------------------------code-----------
      The comparing result on my computer:
      --withou code changing
      ordered, unique
      old time used: [0.030543205640406971]
      new time used: [0.000312459202400521]

      disordered, unique
      old time used: [6.1625172448676198]
      new time used: [0.00031574488299845882]

      disordered, duplicated
      old time used: [6.8560797353410585]
      new time used: [1.6444935113447237]

      --with code changing(original way will not work, so the result is not listed)
      ordered, unique
      new time used: [0.00029485411974586751]

      disordered, unique
      new time used: [0.00029566614149547331]

      disordered, duplicated
      new time used: [0.0015168716657040435]

      The possible patch code as attachment "PossiblePatch.py"

        Attachments

        1. PossiblePatch.py
          3 kB
          Yang XU
        2. test.py
          2 kB
          Yang XU

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              timer Yang XU
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:

                Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified