Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-6682

Loss of precision under concurrent access on o.a.c.utils.EstimatedHistogram methods

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Low
    • Resolution: Fixed
    • 2.0.6
    • None
    • None
    • Low

    Description

      On method getBuckets(), under concurrent use of an instance, the value of a "buckets" variable element might change between its access on the 1st for cycle and its access on the 2nd, when it is reset to 0. This means that, if one collects metrics by repeatedly calling estHist.getBuckets(true), (e.g.: to sum its values) it will miss counting some values added to "buckets" entries between that 1st and 2nd access.

      On method mean(), if the i-th entry of "buckets" changes value between the 1st and 2nd access inside the for cycle, than the "elements" and "sum" accumulators are not working with the same values for that entry. It is more precise (and faster) to use a local variable to read the value just once.

      Not an error but a semantic improvement: at my initial read of this class, I thought the "buckets" and "bucketOffsets" fields could change length. Such perception can be avoided by making the "bucketOffsets" field final.

      Attachments

        1. 6682.txt
          3 kB
          Paulo Gaspar

        Activity

          People

            paulogaspar7 Paulo Gaspar
            paulogaspar7 Paulo Gaspar
            Paulo Gaspar
            Jonathan Ellis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: