summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2009-09-21 09:51:21 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-09-22 06:14:22 -0700
commit6d6e22cf3cdb4f2f1f21863ab19f9b36750bba04 (patch)
treedf039092bdd75d95be2a943b9fce85572fa8034d /xlators
parent4749db6e47ad0fa624e49c5ed3766c77335f68c7 (diff)
performance/write-behind: reduce list-traversal during wb_mark_unwinds
- don't traverse entire request list to get the window-size, instead break when current window size becomes greater than configured limit. Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 276 (write behind needs to be optimized.) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=276
Diffstat (limited to 'xlators')
-rw-r--r--xlators/performance/write-behind/src/write-behind.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c
index 27f824d07fc..2869405dc9a 100644
--- a/xlators/performance/write-behind/src/write-behind.c
+++ b/xlators/performance/write-behind/src/write-behind.c
@@ -1177,13 +1177,15 @@ __wb_mark_winds (list_head_t *list, list_head_t *winds, size_t aggregate_conf,
}
-size_t
-__wb_get_window_size (list_head_t *list)
+char
+__wb_can_unwind (list_head_t *list, size_t window_conf,
+ size_t *window_current_ptr)
{
wb_request_t *request = NULL;
- size_t size = 0;
+ size_t window_current = 0;
struct iovec *vector = NULL;
int32_t count = 0;
+ char can_unwind = 1;
list_for_each_entry (request, list, list)
{
@@ -1198,11 +1200,19 @@ __wb_get_window_size (list_head_t *list)
if (request->flags.write_request.write_behind
&& !request->flags.write_request.got_reply)
{
- size += iov_length (vector, count);
+ window_current += iov_length (vector, count);
+ if (window_current > window_conf) {
+ can_unwind = 0;
+ break;
+ }
}
}
- return size;
+ if (can_unwind && (window_current_ptr != NULL)) {
+ *window_current_ptr = window_current;
+ }
+
+ return can_unwind;
}
@@ -1239,19 +1249,15 @@ __wb_mark_unwind_till (list_head_t *list, list_head_t *unwinds, size_t size)
}
-int32_t
+void
__wb_mark_unwinds (list_head_t *list, list_head_t *unwinds, size_t window_conf)
{
size_t window_current = 0;
- window_current = __wb_get_window_size (list);
- if (window_current <= window_conf)
- {
- window_current += __wb_mark_unwind_till (list, unwinds,
- window_conf - window_current);
+ if (__wb_can_unwind (list, window_conf, &window_current)) {
+ __wb_mark_unwind_till (list, unwinds,
+ window_conf - window_current);
}
-
- return window_current;
}