[jira] [Assigned] (GEODE-6890) sentMessagesMaxTime stat calculation needs improvement
[ https://issues.apache.org/jira/browse/GEODE-6890?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Murtuza Boxwala reassigned GEODE-6890: -- Assignee: Murtuza Boxwala (was: Darrel Schneider) > 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. > * > @@ -1045,8 +1047,17 @@ public class DistributionStats implements DMStats { > if (enableClockStats) { >this.stats.incLong(sentMessagesTimeId, nanos); >long millis = nanos / 100; > - 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)
[jira] [Assigned] (GEODE-6890) sentMessagesMaxTime stat calculation needs improvement
[ https://issues.apache.org/jira/browse/GEODE-6890?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Darrel Schneider reassigned GEODE-6890: --- Assignee: Darrel Schneider > 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: Darrel Schneider >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. > * > @@ -1045,8 +1047,17 @@ public class DistributionStats implements DMStats { > if (enableClockStats) { >this.stats.incLong(sentMessagesTimeId, nanos); >long millis = nanos / 100; > - if (getSentMessagesMaxTime() < millis) { > -this.stats.setLong(sentMessagesMaxTimeId, millis); > + boolean done = false; > + while (!done) { > +long currentSentMessagesMaxTime = sentMessagesMaxTime.get(); > +if (millis > currentSentMessagesMaxTime) { > + done = replyWaitMaxTime.compareAndSet(currentSentMessagesMaxTime, > millis); > + if (done) { > +stats.setLong(sentMessagesMaxTimeId, millis); > + } > +} else { > + done = true; > +} >} > } >} > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)