public inbox for cluster-cvs@sourceware.org help / color / mirror / Atom feed
From: Lon Hohberger <lon@fedoraproject.org> To: cluster-cvs-relay@redhat.com Subject: rgmanager: master - rgmanager: Status check tuning/optimization Date: Fri, 27 Mar 2009 19:06:00 -0000 [thread overview] Message-ID: <20090327190547.6B7A212020C@lists.fedorahosted.org> (raw) Gitweb: http://git.fedorahosted.org/git/rgmanager.git?p=rgmanager.git;a=commitdiff;h=e7df0b0c6ad261f9f718c9f7854751a9342615cb Commit: e7df0b0c6ad261f9f718c9f7854751a9342615cb Parent: 1114b96b1c4de1ee929851d6ccd200f6ecf693cb Author: Lon Hohberger <lhh@redhat.com> AuthorDate: Tue Mar 24 12:49:59 2009 -0400 Committer: Lon Hohberger <lhh@redhat.com> CommitterDate: Fri Mar 27 15:05:32 2009 -0400 rgmanager: Status check tuning/optimization * Spread status checks out based on completion time instead of initiation time. * Allow administrators to cap simultaneous status checks to prevent load spikes. Signed-off-by: Lon Hohberger <lhh@redhat.com> --- rgmanager/include/rg_locks.h | 4 +++ rgmanager/src/daemons/main.c | 17 ++++++++++++- rgmanager/src/daemons/restree.c | 10 +++++-- rgmanager/src/daemons/rg_locks.c | 48 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+), 4 deletions(-) diff --git a/rgmanager/include/rg_locks.h b/rgmanager/include/rg_locks.h index 50b181e..a427749 100644 --- a/rgmanager/include/rg_locks.h +++ b/rgmanager/include/rg_locks.h @@ -27,6 +27,10 @@ int rg_inc_status(void); int rg_dec_status(void); int rg_set_statusmax(int max); +int rg_inc_children(void); +int rg_dec_children(void); +int rg_set_childmax(int max); + int ccs_lock(void); int ccs_unlock(int fd); diff --git a/rgmanager/src/daemons/main.c b/rgmanager/src/daemons/main.c index af55987..3106b0e 100644 --- a/rgmanager/src/daemons/main.c +++ b/rgmanager/src/daemons/main.c @@ -833,6 +833,7 @@ configure_rgmanager(int ccsfd, int dbg) { char *v; char internal = 0; + int status_child_max = 0; if (ccsfd < 0) { internal = 1; @@ -865,12 +866,26 @@ configure_rgmanager(int ccsfd, int dbg) } else { logt_print(LOG_WARNING, "Ignoring illegal " "status_poll_interval of %s\n", v); - status_poll_interval = 10; + status_poll_interval = DEFAULT_CHECK_INTERVAL; } free(v); } + if (ccs_get(ccsfd, "/cluster/rm/@status_child_max", &v) == 0) { + status_child_max = atoi(v); + if (status_child_max >= 1) { + logt_print(LOG_NOTICE, + "Status Child Max set to %d\n", + status_poll_interval); + rg_set_childmax(status_child_max); + } else { + logt_print(LOG_WARNING, "Ignoring illegal " + "status_child_max of %s\n", v); + } + + free(v); + } if (internal) ccs_disconnect(ccsfd); diff --git a/rgmanager/src/daemons/restree.c b/rgmanager/src/daemons/restree.c index 1cec468..c80128a 100644 --- a/rgmanager/src/daemons/restree.c +++ b/rgmanager/src/daemons/restree.c @@ -1151,15 +1151,19 @@ do_status(resource_node_t *node) } /* No check levels ready at the moment. */ - if (idx == -1) { + /* Cap status check children if configured to do so */ + if (idx == -1 || rg_inc_children() < 0) { if (node->rn_checked) return node->rn_last_status; return 0; } - - node->rn_actions[idx].ra_last = now; x = res_exec(node, RS_STATUS, NULL, node->rn_actions[idx].ra_depth); + rg_dec_children(); + + /* Record status check result *after* the status check has + * completed. */ + node->rn_actions[idx].ra_last = time(NULL); node->rn_last_status = x; node->rn_last_depth = node->rn_actions[idx].ra_depth; diff --git a/rgmanager/src/daemons/rg_locks.c b/rgmanager/src/daemons/rg_locks.c index e66cf1c..def034a 100644 --- a/rgmanager/src/daemons/rg_locks.c +++ b/rgmanager/src/daemons/rg_locks.c @@ -1,5 +1,6 @@ #include <pthread.h> #include <stdio.h> +#include <assert.h> #ifdef NO_CCS #include <libxml/xmlmemory.h> #include <libxml/parser.h> @@ -18,6 +19,9 @@ static int __rg_initialized = 0; static int _rg_statuscnt = 0; static int _rg_statusmax = 5; /* XXX */ +static int _rg_childcnt = 0; +static int _rg_childmax = 0; /* XXX */ + static pthread_cond_t unlock_cond = PTHREAD_COND_INITIALIZER; static pthread_cond_t zero_cond = PTHREAD_COND_INITIALIZER; static pthread_cond_t init_cond = PTHREAD_COND_INITIALIZER; @@ -308,6 +312,50 @@ rg_dec_status(void) int +rg_set_childmax(int max) +{ + int old; + + if (max <= 1) + max = 1; + + pthread_mutex_lock(&locks_mutex); + old = _rg_childmax; + _rg_childmax = max; + pthread_mutex_unlock(&locks_mutex); + return old; +} + + +int +rg_inc_children(void) +{ + pthread_mutex_lock(&locks_mutex); + if (_rg_childmax && (_rg_childcnt >= _rg_childmax)) { + pthread_mutex_unlock(&locks_mutex); + return -1; + } + ++_rg_childcnt; + pthread_mutex_unlock(&locks_mutex); + return 0; +} + + +int +rg_dec_children(void) +{ + pthread_mutex_lock(&locks_mutex); + --_rg_childcnt; + if (_rg_childcnt < 0) { + assert(0); + _rg_childcnt = 0; + } + pthread_mutex_unlock(&locks_mutex); + return 0; +} + + +int rg_wait_threads(void) { pthread_mutex_lock(&locks_mutex);
reply other threads:[~2009-03-27 19:06 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20090327190547.6B7A212020C@lists.fedorahosted.org \ --to=lon@fedoraproject.org \ --cc=cluster-cvs-relay@redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).