Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kvs: add more kvs stats #1310

Merged
merged 3 commits into from
Dec 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/modules/kvs/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/modules/kvs/commit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 9 additions & 2 deletions src/modules/kvs/kvs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -1925,8 +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 }",
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;
Expand Down
12 changes: 12 additions & 0 deletions src/modules/kvs/test/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -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");

Expand All @@ -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");

Expand Down