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

add shared raft timer, default false #414

Merged
merged 9 commits into from
Apr 8, 2020
Merged

Conversation

fengjiachun
Copy link
Contributor

@fengjiachun fengjiachun commented Apr 1, 2020

Motivation:

Add shared raft timer based on ScheduledThreadPoolExecutor

Modification:

  1. Add RaftTimerFactory based on SPI
  2. default do not share the timer, users can shared every timer with NodeOptions
  3. shared timer based on ref count, will be destroyed when ref = 0
  4. shared TimerManager

Result:

Fixes #412

@fengjiachun
Copy link
Contributor Author

OS version (e.g. uname -a): Darwin ali-83454.local 18.7.0 Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64 x86_64

  1. default:
    image

  2. share timer:

NodeOptions#timerPoolSize=-1  // -1 mean use global scheduler pool
NodeOptions#sharedElectionTimer=true
NodeOptions#sharedVoteTimer=true
NodeOptions#sharedStepDownTimer=true
NodeOptions#sharedSnapshotTimer=true

image

private static final String GLOBAL_VOTE_TIMER_WORKERS = "jraft.timer.global_vote_timer_workers";
private static final String GLOBAL_STEP_DOWN_TIMER_WORKERS = "jraft.timer.global_step_down_timer_workers";
private static final String GLOBAL_SNAPSHOT_TIMER_WORKERS = "jraft.timer.global_snapshot_timer_workers";
private static final String GLOBAL_SCHEDULER_WORKERS = "jraft.timer.global_scheduler_workers";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个配置需要补充到文档

@killme2008
Copy link
Contributor

NodeOptions#timerPoolSize=-1 过于 trick,感觉加个明确的布尔选项更合适。

@fengjiachun
Copy link
Contributor Author

NodeOptions#timerPoolSize=-1 过于 trick,感觉加个明确的布尔选项更合适。

恩,已添加 sharedTimerPool 选项

@fengjiachun fengjiachun merged commit 5d47497 into master Apr 8, 2020
@fengjiachun fengjiachun deleted the feat/shared_raft_timer branch April 8, 2020 03:10
@fengjiachun fengjiachun mentioned this pull request Apr 9, 2020
@fengjiachun fengjiachun mentioned this pull request Apr 17, 2020
12 tasks
zongtanghu pushed a commit that referenced this pull request Apr 28, 2020
* add shared raft timer, default false

* more robust

* add shared scheduler

* clear necessary code

* minor change

* fix unit test

* add channel init low/high write buf water mark for bolt impl

* minor fix

* minor fix for CR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multi jraft Group CPU usage is high
2 participants