Code Monkey home page Code Monkey logo

Comments (3)

guanchao-yang avatar guanchao-yang commented on August 25, 2024 2

@zhengjianglong915 欢迎一起学习讨论哈。

以上代码不断叠加,不考虑 long 的最大值问题。当值超过最大值以后会出现溢出问题。

Disrupor 在设计的时候已经考虑到这个问题哈,我们使用数组长度为 2^n(SOFATracer 中我们是 2^10=1024) ,通过位运算,加快定位的速度。index 是 long 型最大值为 9223372036854775807 ,假设我们有 100万 QPS 的处理速度,也大概需要 29.2 万年处理完成,虽然理论上存在溢出但是实际情况可以忽略哈。

至于你的截图中出现的赋值溢出的情况,推测是调式代码是,在如下这个地方:

image

在调试的时候,自己主动构造了一个这样的场景类似做了 cursor.addAndGet(Long.MAX_VALUE) 操作,而导致累加的 sequence 出现负数。

from sofa-tracer.

zhengjianglong915 avatar zhengjianglong915 commented on August 25, 2024

@guanchao-yang 嗯嗯,这边是debug 手动改动的。 因为看代码有疑问,验证是否有溢出问题,所以验证了下。 从您的计算上看是不可能出现这个溢出的问题, 我可能只考虑了代码变量边界问题,没考虑到您说的这个方面。 谢谢您。

from sofa-tracer.

guanchao-yang avatar guanchao-yang commented on August 25, 2024

@zhengjianglong915 不要客气哈,咱们互相学习,多多讨论。

from sofa-tracer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.