geode-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dick Cavender (Jira)" <j...@apache.org>
Subject [jira] [Closed] (GEODE-6890) sentMessagesMaxTime stat calculation needs improvement
Date Thu, 26 Sep 2019 18:04:07 GMT

     [ https://issues.apache.org/jira/browse/GEODE-6890?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Dick Cavender closed GEODE-6890.
--------------------------------

> sentMessagesMaxTime stat calculation needs improvement
> ------------------------------------------------------
>
>                 Key: GEODE-6890
>                 URL: https://issues.apache.org/jira/browse/GEODE-6890
>             Project: Geode
>          Issue Type: Improvement
>          Components: statistics
>            Reporter: Darrel Schneider
>            Assignee: Murtuza Boxwala
>            Priority: Major
>             Fix For: 1.10.0
>
>
> The sentMessagesMaxTime stat is calculated by reading the old value. This read is an
expensive synchronized operation.
> The following is a prototype fix that uses a local atomic:
> {noformat}
> diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionStats.java
b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionStats.java
> index d591e35570..0b5017b857 100644
> --- a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionStats.java
> +++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionStats.java
> @@ -1035,6 +1035,8 @@ public class DistributionStats implements DMStats {
>      return this.stats.getLong(sentMessagesTimeId);
>    }
>  
> +  private final AtomicLong sentMessagesMaxTime = new AtomicLong();
> +
>    /**
>     * Increments the total number of nanoseconds spend sending messages.
>     * <p>
> @@ -1045,8 +1047,17 @@ public class DistributionStats implements DMStats {
>      if (enableClockStats) {
>        this.stats.incLong(sentMessagesTimeId, nanos);
>        long millis = nanos / 1000000;
> -      if (getSentMessagesMaxTime() < millis) {
> -        this.stats.setLong(sentMessagesMaxTimeId, millis);
> +      boolean done = false;
> +      while (!done) {
> +        long currentSentMessagesMaxTime = sentMessagesMaxTime.get();
> +        if (millis > currentSentMessagesMaxTime) {
> +          done = sentMessagesMaxTime.compareAndSet(currentSentMessagesMaxTime, millis);
> +          if (done) {
> +            stats.setLong(sentMessagesMaxTimeId, millis);
> +          }
> +        } else {
> +          done = true;
> +        }
>        }
>      }
>    }
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Mime
View raw message