主从同步性能优化,主从同步性能测试。
This commit is contained in:
21
reactor.c
21
reactor.c
@@ -336,7 +336,9 @@ void sync_wakeup() {
|
||||
ssize_t n = write(wakeup_fd, &one, sizeof(one));
|
||||
}
|
||||
|
||||
|
||||
// #include "diskuring/diskuring.h"
|
||||
// extern iouring_ctx_t global_uring_ctx;
|
||||
// extern void iouring_tick(iouring_ctx_t *ctx);
|
||||
|
||||
// 定时器
|
||||
int handle_timer_fd_cb(int fd){
|
||||
@@ -349,14 +351,15 @@ int handle_timer_fd_cb(int fd){
|
||||
if (n < 0 && errno == EAGAIN) break;
|
||||
break;
|
||||
}
|
||||
// iouring_tick(&global_uring_ctx);
|
||||
}
|
||||
|
||||
int init_timer_fd(void){
|
||||
int tfd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC);
|
||||
|
||||
struct itimerspec its = {
|
||||
.it_interval = {1, 0}, // 每 1 秒
|
||||
.it_value = {1, 0}, // 1 秒后首次触发
|
||||
.it_interval = {0, 100 * 1000 * 1000}, // 100ms = 100,000,000 纳秒
|
||||
.it_value = {0, 100 * 1000 * 1000}, // 首次 100ms 后触发
|
||||
};
|
||||
timerfd_settime(tfd, 0, &its, NULL);
|
||||
|
||||
@@ -406,12 +409,12 @@ int reactor_start(unsigned short port, msg_handler handler) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// timer_fd = init_timer_fd();
|
||||
// if(timer_fd < 0){
|
||||
// close(epfd);
|
||||
// close(wakeup_fd);
|
||||
// return -1;
|
||||
// }
|
||||
timer_fd = init_timer_fd();
|
||||
if(timer_fd < 0){
|
||||
close(epfd);
|
||||
close(wakeup_fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user