-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat:协程替代doElectionTicker和doHeartBeatTicker线程 #29
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Message that will be displayed on users' first pull request
引入协程之后发现会存在leader在某几次定时时间为24ms的情况下睡眠了约300ms的时间,经过排查发现是doElectionTicker函数占用了太多时间导致定时不及时
578223592
changed the title
RAFT库使用协程替代线程
feat:协程替代doElectionTicker和doHeartBeatTicker线程
Feb 22, 2024
Closed
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
已经将协程库整合进入项目中,并将raft库中所有使用线程的地方替换为协程。
当前协程库为非对称式协程库,默认情况下,一个raft实例中存在两个线程 ,主线程作为caller thread, 子线程进行调度任务的执行,相较于之前减少了2个线程。 用户可以通过修改common/config.h文件来修改配置。
关于协程调度时间问题,经过简单的测试,并没有发现因为心跳任务处理延迟过大而导致的频繁选举问题。后续会通过测量心跳任务调度处理时间,来准确分析。
关于sleep唤醒时间问题,可以保证当sleep内注册的定时器到达时间后,立即触发epoll_wait退出,并进行调度处理。由于时间轮定时器,以及epoll,raft的超时时间均是ms级别,因此,可以保证触发的立即性。
一些问题: