nickwongwong commented on issue #6728:
URL: https://github.com/apache/skywalking/issues/6728#issuecomment-817349195


   > > It may be confusing and ugly.
   > 
   > I am not sure what is confusing. Every agent could use a different trace 
id generating rule. Java is complex one, others use maybe UUID directly.
   > 
   > > It may produce a conflict timestamp while using random.
   > 
   > If we are going to discuss conflict, then, I would say negative is even 
better? Because we would have a negative value in a normal case.
   > 
   > > I have a new solution for the time-shift-back, inspiring by sonyflake.
   > 
   > I don't think we need to resolve this complex issue. And more importantly, 
why are you doing time shifting? Or it is just because of OS timestamp 
adjusting?
   
   我们的目标先统一一下:在保证性能的前提下,使`globalId`的全局唯一
   Our goal is to unify first: under the premise of ensuring performance, make 
the `globalId` globally unique
   
   >  It may be confusing and ugly.
   
   
![image](https://user-images.githubusercontent.com/16626084/114315320-0e446c00-9b31-11eb-835b-8c6b7a058b65.png)
   
![image](https://user-images.githubusercontent.com/16626084/114315963-00441a80-9b34-11eb-9c75-da1f9a074b87.png)
   
   文档中说明是用`timestamp`, 显然`timestamp`不可能是负数的。
   函数名是`nextSeq`, `sequence` 作为负数也很奇怪。
   另外“-”在很多情况下被当做是分隔符,突然在这里出现会很奇怪
   The document states that `timestamp` is used. Obviously, `timestamp` cannot 
be a negative number.
   The function name is `nextSeq`, and it is strange that `sequence` is a 
negative number.
   In addition, "-" is used as a separator in many cases, it would be strange 
to suddenly appear here
   
   > It may produce a conflict timestamp while using random.
   > If we are going to discuss conflict, then, I would say negative is even 
better? Because we would have a negative value in a normal case.
   
   如果时间回拨多次,使用随机数,这有一定的概率会冲突(虽然很小).
   现在的时间戳是1618164032218,已经超出了Integer的范围,所以随机数 `nextInt(0, Integer.MAX_VALUE)` 
不会和正常的时间戳冲突.
   If the time is called back multiple times and a random number is used, there 
is a certain probability that it will conflict (albeit very small).
   The current timestamp is 1618164032218, which has exceeded the range of 
Integer, so the random number `nextInt(0, Integer.MAX_VALUE)` will not conflict 
with the normal timestamp.
   
![image](https://user-images.githubusercontent.com/16626084/114315812-303eee00-9b33-11eb-8c49-8543550b1ed0.png)
   
   
   > why are you doing time shifting? Or it is just because OS timestamp 
adjusting?
   
   OS时间变更或者时间校对是很难完全避免的。既然我们代码里面处理了时间回拨问题,是可以做进一步的优化的。
   It is difficult to completely avoid OS time changes or time proofreading. 
Since our code handles the time-callback problem, it can be further optimized.
   


-- 
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]


Reply via email to