[
https://issues.apache.org/jira/browse/GEODE-6890?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16869660#comment-16869660
]
ASF subversion and git services commented on GEODE-6890:
--------------------------------------------------------
Commit 0b15a8119b7b42df3b69825f42b9e096556c91a0 in geode's branch
refs/heads/develop from Murtuza Boxwala
[ https://gitbox.apache.org/repos/asf?p=geode.git;h=0b15a81 ]
GEODE-6889, GEODE-6890: remove sync when updating max stats (#3728)
* GEODE-6889: Ensure the highest value is recorded to replyWaitMaxTime
* GEODE-6890: Ensure the highest value is recorded to maxSentMessagesTime
Co-authored-by: Murtuza Boxwala <[email protected]>
> 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
>
> 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
(v7.6.3#76005)