Skip to content
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
merged 16 commits into from
Feb 22, 2024

Conversation

TiNnNnnn
Copy link
Contributor

@TiNnNnnn TiNnNnnn commented Feb 15, 2024

已经将协程库整合进入项目中,并将raft库中所有使用线程的地方替换为协程。

当前协程库为非对称式协程库,默认情况下,一个raft实例中存在两个线程 ,主线程作为caller thread, 子线程进行调度任务的执行,相较于之前减少了2个线程。 用户可以通过修改common/config.h文件来修改配置。

关于协程调度时间问题,经过简单的测试,并没有发现因为心跳任务处理延迟过大而导致的频繁选举问题。后续会通过测量心跳任务调度处理时间,来准确分析。

关于sleep唤醒时间问题,可以保证当sleep内注册的定时器到达时间后,立即触发epoll_wait退出,并进行调度处理。由于时间轮定时器,以及epoll,raft的超时时间均是ms级别,因此,可以保证触发的立即性。

一些问题:

  1. 我对于所有proto文件重新进行了生成,导致proto相关文件存在变化
  2. 没有给协程库统一的日志格式,比较随意杂乱,后续会进行整合修改
  3. 对于协程库本身的更多拓展

Copy link

@github-actions github-actions bot left a 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

@578223592
Copy link
Collaborator

578223592 commented Feb 20, 2024

@TiNnNnnn 统一代码风,方便后续的开发。
相关issue已经完成,代码格式化的方法为:

cd cmake-build-debug
rm -rf *
cmake ..
make format

应该可以看到如下输出:

➜  cmake-build-debug git:(format) ✗ make format
format done!
Built target format

#31

@578223592 578223592 changed the title RAFT库使用协程替代线程 feat:协程替代doElectionTicker和doHeartBeatTicker线程 Feb 22, 2024
@578223592 578223592 merged commit ade4d7c into youngyangyang04:main Feb 22, 2024
1 check passed
@578223592 578223592 linked an issue Feb 27, 2024 that may be closed by this pull request
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat:协程引入以减少线程数量
3 participants