From 5fc35874ace4a92b0b9c4df3ed1f057190585de1 Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Mon, 24 Apr 2023 22:03:57 -0400 Subject: [PATCH] checkpoint --- libfuse/lib/fuse.c | 7 ++++--- libfuse/lib/fuse_msgbuf.cpp | 10 ++++++++-- libfuse/lib/fuse_msgbuf.hpp | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/libfuse/lib/fuse.c b/libfuse/lib/fuse.c index 8f76d53e..f5729c17 100644 --- a/libfuse/lib/fuse.c +++ b/libfuse/lib/fuse.c @@ -3751,7 +3751,7 @@ metrics_log_nodes_info(struct fuse *f_, "node memory pool avail objs: %"PRIu64"\n" "node memory pool total allocated memory: %"PRIu64"\n" "msgbuf allocation count: %"PRIu64"\n" - "msgbuf total allocated memory: %"PRIu64"\n" + "msgbuf available count: %"PRIu64"\n" "\n" , (uint64_t)time_now, @@ -3767,7 +3767,7 @@ metrics_log_nodes_info(struct fuse *f_, (uint64_t)fmp_avail_objs(&f_->node_fmp.fmp), (uint64_t)fmp_total_allocated_memory(&f_->node_fmp.fmp), (uint64_t)msgbuf_alloc_count(), - (uint64_t)msgbuf_alloc_count() * msgbuf_get_bufsize() + msgbuf_avail_count() ); lfmp_unlock(&f_->node_fmp); @@ -3829,9 +3829,10 @@ fuse_maintenance_loop(void *fuse_) if(!f->conf.nogc && gc) { gc = lfmp_gc(&f->node_fmp); - // msgbuf_gc(); } + msgbuf_gc(); + if(g_LOG_METRICS) metrics_log_nodes_info_to_tmp_dir(f); diff --git a/libfuse/lib/fuse_msgbuf.cpp b/libfuse/lib/fuse_msgbuf.cpp index b7c2cb7c..c90594af 100644 --- a/libfuse/lib/fuse_msgbuf.cpp +++ b/libfuse/lib/fuse_msgbuf.cpp @@ -30,7 +30,6 @@ static std::uint32_t g_PAGESIZE = 0; static std::uint32_t g_BUFSIZE = 0; -//static std::atomic_uint g_TOTAL_ALLOCED; static std::mutex g_MUTEX; static std::vector g_MSGBUF_STACK; @@ -51,7 +50,7 @@ __attribute__((destructor)) void msgbuf_destroy() { - // TODO: cleanup? + msgbuf_gc(); } uint32_t @@ -134,6 +133,12 @@ msgbuf_alloc_count() return g_MSGBUF_ALLOCED.size(); } +uint64_t +msgbuf_avail_count() +{ + return g_MSGBUF_STACK.size(); +} + void msgbuf_gc() { @@ -144,6 +149,7 @@ msgbuf_gc() oldstack.swap(g_MSGBUF_STACK); } + fprintf(stderr,"freeing %lu msgbufs\n",oldstack.size()); for(auto msgbuf: oldstack) { g_MSGBUF_ALLOCED.erase(msgbuf); diff --git a/libfuse/lib/fuse_msgbuf.hpp b/libfuse/lib/fuse_msgbuf.hpp index 348b2698..a937d3e8 100644 --- a/libfuse/lib/fuse_msgbuf.hpp +++ b/libfuse/lib/fuse_msgbuf.hpp @@ -32,5 +32,6 @@ void msgbuf_free(fuse_msgbuf_t *msgbuf); void msgbuf_gc(); uint64_t msgbuf_alloc_count(); +uint64_t msgbuf_avail_count(); EXTERN_C_END