主从同步性能优化,主从同步性能测试。
This commit is contained in:
50
diskuring/diskuring.h.nothread
Normal file
50
diskuring/diskuring.h.nothread
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifndef __DISK_IOURING_H__
|
||||
#define __DISK_IOURING_H__
|
||||
|
||||
#include <liburing.h>
|
||||
#include <pthread.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define BATCH_SIZE 256
|
||||
typedef enum { TASK_READ, TASK_WRITE } task_op_t;
|
||||
|
||||
typedef struct task {
|
||||
task_op_t op;
|
||||
int fd;
|
||||
off_t off;
|
||||
|
||||
int res; // cqe->res
|
||||
int done; // 0/1
|
||||
|
||||
struct iovec *iovs; // iovec 数组
|
||||
int iovcnt; // iovec 数量
|
||||
|
||||
struct task *next;
|
||||
} task_t;
|
||||
|
||||
typedef struct {
|
||||
struct io_uring ring;
|
||||
int pending_count;
|
||||
|
||||
task_t *head;
|
||||
task_t *tail;
|
||||
} iouring_ctx_t;
|
||||
|
||||
void task_init(task_t *t);
|
||||
void task_finish(task_t *t, int res);
|
||||
void task_destroy(task_t *t);
|
||||
|
||||
int iouring_init(iouring_ctx_t *ctx, unsigned entries);
|
||||
void iouring_shutdown(iouring_ctx_t *ctx);
|
||||
|
||||
task_t* submit_write(iouring_ctx_t *ctx, int fd, void **bufs, size_t *lens, int count, off_t off);
|
||||
void iouring_tick(iouring_ctx_t *ctx);
|
||||
|
||||
extern iouring_ctx_t global_uring_ctx;
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user