From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wu Fengguang Subject: [PATCH 1/9] readahead: make context readahead more conservative Date: Sat, 11 Feb 2012 12:31:41 +0800 Message-ID: <20120211043325.331352920@intel.com> References: <20120211043140.108656864@intel.com> Cc: Andi Kleen , Wu Fengguang To: Andrew Morton Return-path: cc: Linux Memory Management List , Cc: LKML Content-Disposition: inline; filename=readahead-context-tt Sender: owner-linux-mm@kvack.org List-Id: linux-fsdevel.vger.kernel.org Try to prevent negatively impact moderately dense random reads on SSD. Transaction-Per-Second numbers provided by Taobao: QPS case ------------------------------------------------------- 7536 disable context readahead totally w/ patch: 7129 slower size rampup and start RA on the 3rd read 6717 slower size rampup w/o patch: 5581 unmodified context readahead Before, readahead will be started whenever reading page N+1 when it happen to read N recently. After patch, we'll only start readahead when *three* random reads happen to access pages N, N+1, N+2. The probability of this happening is extremely low for pure random reads, unless they are very dense, which actually deserves some readahead. Also start with a smaller readahead window. The impact to interleaved sequential reads should be small, because for a long run stream, the the small readahead window rampup phase is negletable. The context readahead actually benefits clustered random reads on HDD whose seek cost is pretty high. However as SSD is increasingly used for random read workloads it's better for the context readahead to concentrate on interleaved sequential reads. Tested-by: Tao Ma Signed-off-by: Wu Fengguang --- mm/readahead.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- linux-next.orig/mm/readahead.c 2012-01-25 15:57:47.000000000 +0800 +++ linux-next/mm/readahead.c 2012-01-25 15:57:49.000000000 +0800 @@ -369,10 +369,10 @@ static int try_context_readahead(struct size = count_history_pages(mapping, ra, offset, max); /* - * no history pages: + * not enough history pages: * it could be a random read */ - if (!size) + if (size <= req_size) return 0; /* @@ -383,8 +383,8 @@ static int try_context_readahead(struct size *= 2; ra->start = offset; - ra->size = get_init_ra_size(size + req_size, max); - ra->async_size = ra->size; + ra->size = min(size + req_size, max); + ra->async_size = 1; return 1; } -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx103.postini.com [74.125.245.103]) by kanga.kvack.org (Postfix) with SMTP id D6D906B13F2 for ; Sat, 11 Feb 2012 04:51:07 -0500 (EST) Message-Id: <20120211043325.331352920@intel.com> Date: Sat, 11 Feb 2012 12:31:41 +0800 From: Wu Fengguang Subject: [PATCH 1/9] readahead: make context readahead more conservative References: <20120211043140.108656864@intel.com> Content-Disposition: inline; filename=readahead-context-tt Sender: owner-linux-mm@kvack.org List-ID: To: Andrew Morton Cc: Andi Kleen , Wu Fengguang , Linux Memory Management List , linux-fsdevel@vger.kernel.org, LKML Try to prevent negatively impact moderately dense random reads on SSD. Transaction-Per-Second numbers provided by Taobao: QPS case ------------------------------------------------------- 7536 disable context readahead totally w/ patch: 7129 slower size rampup and start RA on the 3rd read 6717 slower size rampup w/o patch: 5581 unmodified context readahead Before, readahead will be started whenever reading page N+1 when it happen to read N recently. After patch, we'll only start readahead when *three* random reads happen to access pages N, N+1, N+2. The probability of this happening is extremely low for pure random reads, unless they are very dense, which actually deserves some readahead. Also start with a smaller readahead window. The impact to interleaved sequential reads should be small, because for a long run stream, the the small readahead window rampup phase is negletable. The context readahead actually benefits clustered random reads on HDD whose seek cost is pretty high. However as SSD is increasingly used for random read workloads it's better for the context readahead to concentrate on interleaved sequential reads. Tested-by: Tao Ma Signed-off-by: Wu Fengguang --- mm/readahead.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- linux-next.orig/mm/readahead.c 2012-01-25 15:57:47.000000000 +0800 +++ linux-next/mm/readahead.c 2012-01-25 15:57:49.000000000 +0800 @@ -369,10 +369,10 @@ static int try_context_readahead(struct size = count_history_pages(mapping, ra, offset, max); /* - * no history pages: + * not enough history pages: * it could be a random read */ - if (!size) + if (size <= req_size) return 0; /* @@ -383,8 +383,8 @@ static int try_context_readahead(struct size *= 2; ra->start = offset; - ra->size = get_init_ra_size(size + req_size, max); - ra->async_size = ra->size; + ra->size = min(size + req_size, max); + ra->async_size = 1; return 1; } -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756640Ab2BKJx1 (ORCPT ); Sat, 11 Feb 2012 04:53:27 -0500 Received: from mga14.intel.com ([143.182.124.37]:32463 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754325Ab2BKJvH (ORCPT ); Sat, 11 Feb 2012 04:51:07 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.71,315,1320652800"; d="scan'208";a="105714170" Message-Id: <20120211043325.331352920@intel.com> User-Agent: quilt/0.48-1 Date: Sat, 11 Feb 2012 12:31:41 +0800 From: Wu Fengguang To: Andrew Morton cc: Andi Kleen , Wu Fengguang cc: Linux Memory Management List , Cc: LKML Subject: [PATCH 1/9] readahead: make context readahead more conservative References: <20120211043140.108656864@intel.com> Content-Disposition: inline; filename=readahead-context-tt Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Try to prevent negatively impact moderately dense random reads on SSD. Transaction-Per-Second numbers provided by Taobao: QPS case ------------------------------------------------------- 7536 disable context readahead totally w/ patch: 7129 slower size rampup and start RA on the 3rd read 6717 slower size rampup w/o patch: 5581 unmodified context readahead Before, readahead will be started whenever reading page N+1 when it happen to read N recently. After patch, we'll only start readahead when *three* random reads happen to access pages N, N+1, N+2. The probability of this happening is extremely low for pure random reads, unless they are very dense, which actually deserves some readahead. Also start with a smaller readahead window. The impact to interleaved sequential reads should be small, because for a long run stream, the the small readahead window rampup phase is negletable. The context readahead actually benefits clustered random reads on HDD whose seek cost is pretty high. However as SSD is increasingly used for random read workloads it's better for the context readahead to concentrate on interleaved sequential reads. Tested-by: Tao Ma Signed-off-by: Wu Fengguang --- mm/readahead.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- linux-next.orig/mm/readahead.c 2012-01-25 15:57:47.000000000 +0800 +++ linux-next/mm/readahead.c 2012-01-25 15:57:49.000000000 +0800 @@ -369,10 +369,10 @@ static int try_context_readahead(struct size = count_history_pages(mapping, ra, offset, max); /* - * no history pages: + * not enough history pages: * it could be a random read */ - if (!size) + if (size <= req_size) return 0; /* @@ -383,8 +383,8 @@ static int try_context_readahead(struct size *= 2; ra->start = offset; - ra->size = get_init_ra_size(size + req_size, max); - ra->async_size = ra->size; + ra->size = min(size + req_size, max); + ra->async_size = 1; return 1; }