kezhenxu94 commented on a change in pull request #2930: One more time for
heigher performance
URL: https://github.com/apache/skywalking/pull/2930#discussion_r296446485
##########
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:
> sorry, I have make some tests to find my first version is right. so I'm
roll back the code.
> Use an array ensure the value load in CPU's cache and cached in one line
without other variable.
>
> We can learn the Disruptor how to do this in this article
>
> https://tech.meituan.com/2016/11/18/disruptor.html
>
> The Unsafe is used in the Disruptor, and it worked well. So we don't worry
about Unsafe will change in the future.
@wu-sheng the unsafe is also used in netty too, I don't think it's a concern
herr
----------------------------------------------------------------
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