summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2020-06-11 16:12:42 +0200
committerDavid Härdeman <david@hardeman.nu>2020-06-11 16:12:42 +0200
commit684ce94729d68e84fd7ab6067998781fdc891358 (patch)
tree55c3f207041aac45c23a69db6af8475767a463bd
parentafa80c32554dcd02737e2c341c27b6a9fa7f3e80 (diff)
Track cqe and sqe usage
-rw-r--r--uring.c6
-rw-r--r--uring.h3
-rw-r--r--utils.c5
3 files changed, 14 insertions, 0 deletions
diff --git a/uring.c b/uring.c
index 78a084a..9075327 100644
--- a/uring.c
+++ b/uring.c
@@ -16,6 +16,9 @@ struct uring_ev {
struct uring_task task;
};
+uint64_t sqe_count = 0;
+uint64_t cqe_count = 0;
+
static struct io_uring_sqe *
get_sqe(struct cfg *cfg, struct uring_task *task)
{
@@ -32,6 +35,7 @@ get_sqe(struct cfg *cfg, struct uring_task *task)
perrordie("Failed to get an sqe!\n");
}
+ sqe_count++;
uring_task_get(cfg, task);
return sqe;
}
@@ -548,6 +552,8 @@ uring_event_loop(struct cfg *cfg)
struct uring_task *task = io_uring_cqe_get_data(cqe);
bool do_callback;
+ cqe_count++;
+
if (!task)
die("%s: null task\n", __func__);
diff --git a/uring.h b/uring.h
index 11fd656..680684a 100644
--- a/uring.h
+++ b/uring.h
@@ -1,6 +1,9 @@
#ifndef foouringhfoo
#define foouringhfoo
+extern uint64_t sqe_count;
+extern uint64_t cqe_count;
+
void uring_task_refdump(struct uring_task *task);
void uring_task_destroy(struct cfg *cfg, struct uring_task *task);
diff --git a/utils.c b/utils.c
index 93bc0b8..0718ea9 100644
--- a/utils.c
+++ b/utils.c
@@ -11,9 +11,11 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
+#include <inttypes.h>
#include "main.h"
#include "utils.h"
+#include "uring.h"
static unsigned total_malloc_count = 0;
static int malloc_count = 0;
@@ -156,6 +158,9 @@ debug_resource_usage()
fprintf(stderr, "Lost file descriptor(s)\n");
exit(EXIT_FAILURE);
}
+
+ fprintf(stderr, "CQEs used: %" PRIu64 ", SQEs used: %" PRIu64 "\n",
+ cqe_count, sqe_count);
}
void