From db33e097111ca76f487f087d494984d45d4b3b64 Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Tue, 22 Sep 2009 01:38:50 +0000 Subject: 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 BUG: 276 (write behind needs to be optimized.) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=276 --- .../performance/write-behind/src/write-behind.c | 32 +++++++++++++--------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'xlators') 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; } -- cgit