summaryrefslogtreecommitdiffstats
path: root/xlators/performance
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2009-09-22 01:38:50 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-09-22 06:13:17 -0700
commitdb33e097111ca76f487f087d494984d45d4b3b64 (patch)
tree0e0f5d562c6617ca71c62d319b39169f5bf0b7b9 /xlators/performance
parent32a6898678686df1b2c82a37e548170ba5c3512b (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/performance')
-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 34a48809ef6..f4a3fe89c9c 100644
--- a/xlators/performance/write-behind/src/write-behind.c
+++ b/xlators/performance/write-behind/src/write-behind.c
@@ -1409,13 +1409,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)
{
@@ -1430,11 +1432,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;
}
@@ -1471,19 +1481,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;
}