From 8790bddbcc0db1817fa433996bc634ef7b7ff52f Mon Sep 17 00:00:00 2001 From: Albert Chu Date: Mon, 11 Dec 2017 15:38:17 -0800 Subject: [PATCH 1/3] modules/kvs: Add new commit stat get functions Support commit_mgr_fences_count() and commit_mgr_ready_commit_count() to retrieve fences and ready commit counts. Will be needed for namespace removal and general stat checking. Add new unit tests appropriately. --- src/modules/kvs/commit.c | 10 ++++++++++ src/modules/kvs/commit.h | 6 ++++++ src/modules/kvs/test/commit.c | 12 ++++++++++++ 3 files changed, 28 insertions(+) diff --git a/src/modules/kvs/commit.c b/src/modules/kvs/commit.c index 187a43fe89c7..3658a7d32179 100644 --- a/src/modules/kvs/commit.c +++ b/src/modules/kvs/commit.c @@ -1033,6 +1033,16 @@ void commit_mgr_clear_noop_stores (commit_mgr_t *cm) cm->noop_stores = 0; } +int commit_mgr_fences_count (commit_mgr_t *cm) +{ + return zhash_size (cm->fences); +} + +int commit_mgr_ready_commit_count (commit_mgr_t *cm) +{ + return zlist_size (cm->ready); +} + /* Merge ready commits that are mergeable, where merging consists of * popping the "donor" commit off the ready list, and appending its * ops to the top commit. The top commit can be appended to if it diff --git a/src/modules/kvs/commit.h b/src/modules/kvs/commit.h index 87942e30a2ad..84dc28ca32f0 100644 --- a/src/modules/kvs/commit.h +++ b/src/modules/kvs/commit.h @@ -139,6 +139,12 @@ void commit_mgr_remove_fence (commit_mgr_t *cm, const char *name); int commit_mgr_get_noop_stores (commit_mgr_t *cm); void commit_mgr_clear_noop_stores (commit_mgr_t *cm); +/* Get count of fences stored */ +int commit_mgr_fences_count (commit_mgr_t *cm); + +/* return count of ready commits */ +int commit_mgr_ready_commit_count (commit_mgr_t *cm); + /* In internally stored ready commits (moved to ready status via * commit_mgr_process_fence_request()), merge them if they are capable * of being merged. diff --git a/src/modules/kvs/test/commit.c b/src/modules/kvs/test/commit.c index ccb8be13818d..5f312b065fd7 100644 --- a/src/modules/kvs/test/commit.c +++ b/src/modules/kvs/test/commit.c @@ -157,6 +157,9 @@ void commit_mgr_basic_tests (void) commit_mgr_clear_noop_stores (cm); + ok (commit_mgr_fences_count (cm) == 0, + "commit_mgr_fences_count returns 0 when no fences submitted"); + ok ((f = fence_create ("fence1", 1, 0)) != NULL, "fence_create works"); @@ -175,9 +178,15 @@ void commit_mgr_basic_tests (void) ok (commit_mgr_lookup_fence (cm, "invalid") == NULL, "commit_mgr_lookup_fence can't find invalid fence"); + ok (commit_mgr_fences_count (cm) == 1, + "commit_mgr_fences_count returns 1 when fence submitted"); + ok (commit_mgr_process_fence_request (cm, f) == 0, "commit_mgr_process_fence_request works"); + ok (commit_mgr_ready_commit_count (cm) == 0, + "commit_mgr_ready_commit_count is 0"); + ok (commit_mgr_commits_ready (cm) == false, "commit_mgr_commits_ready says no fences are ready"); @@ -195,6 +204,9 @@ void commit_mgr_basic_tests (void) ok (commit_mgr_process_fence_request (cm, f) == 0, "commit_mgr_process_fence_request works"); + ok (commit_mgr_ready_commit_count (cm) == 1, + "commit_mgr_ready_commit_count is 1"); + ok (commit_mgr_commits_ready (cm) == true, "commit_mgr_commits_ready says a fence is ready"); From a32dda605ac9b69e7eeab3c86b0bf18f43a40b5a Mon Sep 17 00:00:00 2001 From: Albert Chu Date: Fri, 15 Dec 2017 08:53:06 -0800 Subject: [PATCH 2/3] modules/kvs: Add missing stat to kvs stats --- src/modules/kvs/kvs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/kvs/kvs.c b/src/modules/kvs/kvs.c index b6d0a63e9ef0..0a487aec93e1 100644 --- a/src/modules/kvs/kvs.c +++ b/src/modules/kvs/kvs.c @@ -1925,8 +1925,9 @@ static void stats_get_cb (flux_t *h, flux_msg_handler_t *mh, else { json_t *s; - if (!(s = json_pack ("{ s:i s:i }", + if (!(s = json_pack ("{ s:i s:i s:i }", "#watchers", 0, + "#no-op stores", 0, "store revision", 0))) { errno = ENOMEM; goto done; From 6cdb269cd54518ecc27cc84575fce656fad81ad0 Mon Sep 17 00:00:00 2001 From: Albert Chu Date: Fri, 15 Dec 2017 08:56:07 -0800 Subject: [PATCH 3/3] modules/kvs: Add new stats to kvs stats Get commit mgr fence count and ready commit count. --- src/modules/kvs/kvs.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/modules/kvs/kvs.c b/src/modules/kvs/kvs.c index 0a487aec93e1..d38436854bf7 100644 --- a/src/modules/kvs/kvs.c +++ b/src/modules/kvs/kvs.c @@ -1907,11 +1907,15 @@ static void stats_get_cb (flux_t *h, flux_msg_handler_t *mh, while (root) { json_t *s; - if (!(s = json_pack ("{ s:i s:i s:i }", + if (!(s = json_pack ("{ s:i s:i s:i s:i s:i }", "#watchers", wait_queue_length (root->watchlist), "#no-op stores", commit_mgr_get_noop_stores (root->cm), + "#fences", + commit_mgr_fences_count (root->cm), + "#readycommits", + commit_mgr_ready_commit_count (root->cm), "store revision", root->seq))) { errno = ENOMEM; goto done; @@ -1925,9 +1929,11 @@ static void stats_get_cb (flux_t *h, flux_msg_handler_t *mh, else { json_t *s; - if (!(s = json_pack ("{ s:i s:i s:i }", + if (!(s = json_pack ("{ s:i s:i s:i s:i s:i }", "#watchers", 0, "#no-op stores", 0, + "#fences", 0, + "#readycommits", 0, "store revision", 0))) { errno = ENOMEM; goto done;