kezhenxu94 commented on a change in pull request #2930: One more time for 
heigher performance
URL: https://github.com/apache/skywalking/pull/2930#discussion_r296446674
 
 

 ##########
 File path: 
apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/common/AtomicRangeInteger.java
 ##########
 @@ -18,23 +18,32 @@
 
 
 package org.apache.skywalking.apm.commons.datacarrier.common;
-
 import java.io.Serializable;
 import java.util.concurrent.atomic.AtomicInteger;
 
 /**
- * Created by wusheng on 2016/10/25.
+ * Created by lkxiaolou on 2019/06/22.
  */
 public class AtomicRangeInteger extends Number implements Serializable {
     private static final long serialVersionUID = -4099792402691141643L;
+
+    /**
+     * please dont't change the left and right Placeholders
+     * to disable false-sharing for more performance
+     */
+    private int[] leftPlaceholders;
     private AtomicInteger value;
+    private int[] rightPlaceholders;
+
     private int startValue;
     private int endValue;
 
     public AtomicRangeInteger(int startValue, int maxValue) {
         this.value = new AtomicInteger(startValue);
         this.startValue = startValue;
         this.endValue = maxValue - 1;
+        leftPlaceholders = new int[15];
+        rightPlaceholders = new int[15];
 
 Review comment:
   > > > I don't find the place to use `leftPlaceholders` and 
`rightPlaceholders`. And why the length is 15?
   > > 
   > > 
   > > It's indeed not used in the code because it's only declared to pad the 
cache line (64 bytes per line ), 15 * 4 = 60, plus the value to occupy the 
entire cache line to dismiss the false-sharing, am I right ? @lkxiaolou but why 
do we need padding right? Did I miss anything ?
   > 
   > The value may cached anywhere in one line,.
   > We must ensure one cache line cached the value and can not cache other 
variables.
   > So suppose that cache the value in the end slot of the cache line or start 
slot of the cache line, we need 15 left and 15 right.
   
   Got it, really interesting 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to