From: Fengguang Wu <fengguang.wu@intel.com>
To: Martin Liu <liumartin@google.com>
Cc: Mark Salyzyn <salyzyn@android.com>,
akpm@linux-foundation.org, axboe@kernel.dk, dchinner@redhat.com,
jenhaochen@google.com, salyzyn@google.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, linux-block@vger.kernel.org
Subject: Re: [RFC PATCH] mm: readahead: add readahead_shift into backing device
Date: Wed, 27 Mar 2019 20:43:15 +0800 [thread overview]
Message-ID: <20190327124315.eounujow5rvqaaq2@wfg-t540p.sh.intel.com> (raw)
In-Reply-To: <20190326081233.GA175058@google.com>
On Tue, Mar 26, 2019 at 04:12:33PM +0800, Martin Liu wrote:
>On Tue, Mar 26, 2019 at 09:30:58AM +0800, Fengguang Wu wrote:
>> On Mon, Mar 25, 2019 at 09:59:31AM -0700, Mark Salyzyn wrote:
>> > On 03/25/2019 05:16 AM, Fengguang Wu wrote:
>> > > Martin,
>> > >
>> > > On Fri, Mar 22, 2019 at 11:46:11PM +0800, Martin Liu wrote:
>> > > > As the discussion https://lore.kernel.org/patchwork/patch/334982/
>> > > > We know an open file's ra_pages might run out of sync from
>> > > > bdi.ra_pages since sequential, random or error read. Current design
>> > > > is we have to ask users to reopen the file or use fdavise system
>> > > > call to get it sync. However, we might have some cases to change
>> > > > system wide file ra_pages to enhance system performance such as
>> > > > enhance the boot time by increasing the ra_pages or decrease it to
>> > >
>> > > Do you have examples that some distro making use of larger ra_pages
>> > > for boot time optimization?
>> >
>> > Android (if you are willing to squint and look at android-common AOSP
>> > kernels as a Distro).
>>
>> OK. I wonder how exactly Android makes use of it. Since phones are not
>> using hard disks, so should benefit less from large ra_pages. Would
>> you kindly point me to the code?
>>
>Yes, one of the example is as below.
>https://source.android.com/devices/tech/perf/boot-times#optimizing-i-o-efficiency
Thanks. It says
on late-fs
write /sys/block/sda/queue/read_ahead_kb 2048
on property:sys.boot_completed=1
# end boot time fs tune
write /sys/block/sda/queue/read_ahead_kb 512
I tried fio randread test on Sandisk A1 SD card with cmdline
% fio --name=randread --rw=randread --direct=1 --ioengine=libaio --bs=8k --numjobs=1 --size=1G --runtime=60 --group_reporting
And find results to be
8k READ: bw=16.2MiB/s
128k READ: bw=64.5MiB/s
512k READ: bw=83.4MiB/s <==
1M READ: bw=87.5MiB/s
2M READ: bw=89.8MiB/s <==
4M READ: bw=91.5MiB/s
8M READ: bw=91.9MiB/s
Here bs=512k looks good enough for I/O performance.
bs=2M just adds ~8% performance. Though this is measured on
my SD card. Different phones may have varied numbers.
>> > > Suppose N read streams with equal read speed. The thrash-free memory
>> > > requirement would be (N * 2 * ra_pages).
>> > >
>> > > If N=1000 and ra_pages=1MB, it'd require 2GB memory. Which looks
>> > > affordable in mainstream servers.
>> > That is 50% of the memory on a high end Android device ...
>>
>> Yeah but I'm obviously not talking Android device here. Will a phone
>> serve 1000 concurrent read streams?
>>
>For Android, some important, persistent services and native HALs might
>hold fd for a long time unless request a restart action and then would
>impact overall user experience(guess more than 100). For some low end
>devices which is a big portion of Android devices, their memory size
>might be even smaller. Thus, when the device is under memory pressure,
>this might bring more overhead to impact the performance. As current
>design, we don't have a way to shrink readahead immediately. This
>interface gives the flexibility to an adiminstrator to decide how
>readahed to participate the mitigation level base on the metric it has.
Understand.
>> > > Sorry but it sounds like introducing an unnecessarily twisted new
>> > > interface. I'm afraid it fixes the pain for 0.001% users while
>> > > bringing more puzzle to the majority others.
>> > >2B Android devices on the planet is 0.001%?
>>
>> Nope. Sorry I didn't know about the Android usage.
>> Actually nobody mentioned it in the past discussions.
>>
>> > I am not defending the proposed interface though, if there is something
>> > better that can be used, then looking into:
>> > >
>> > > Then let fadvise() and shrink_readahead_size_eio() adjust that
>> > > per-file ra_pages_shift.
>> > Sounds like this would require a lot from init to globally audit and
>> > reduce the read-ahead for all open files?
>>
>> It depends. In theory it should be possible to create a standalone
>> kernel module to dump the page cache and get the current snapshot of
>> all cached file pages. It'd be a one-shot action and don't require
>> continuous auditing.
>>
>> [RFC] kernel facilities for cache prefetching
>> https://lwn.net/Articles/182128
>>
>> This tool may also work. It's quick to get the list of opened files by
>> walking /proc/*/fd/, however not as easy to get the list of cached
>> file names.
>>
>> https://github.com/tobert/pcstat
>>
>> Perhaps we can do a simplified /proc/filecache that only dumps the
>> list of cached file names. Then let mincore() based tools take care
>> of the rest work.
>>
>Thanks for the information, they are very useful. For Android, it would
>keep updating pretty frequently and the lists might need to be updated
>as the end users install apps, runtime optimization or get new OTA.
>Therefore, this might request pretty much effort to maintain this.
>Please kindly correct me if any misunderstanding. Thanks.
We don't need to keep track of all the system updates.
This should be enough.
on each boot:
load file_and_page.list
readahead the files/pages
wait for boot_completed
query kernel to get the cached files and _referenced_ pages
save to new file_and_page.list for next boot time readahead
When there are new apps installed, they may not be immediately
reflected in the next boot, but next next boot will be able to
do proper readahead for them.
Thanks,
Fengguang
next prev parent reply other threads:[~2019-03-27 12:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-22 15:46 Martin Liu
2019-03-25 12:16 ` Fengguang Wu
2019-03-25 16:59 ` Mark Salyzyn
2019-03-26 1:30 ` Fengguang Wu
2019-03-26 8:12 ` Martin Liu
2019-03-27 12:43 ` Fengguang Wu [this message]
2019-03-29 0:33 ` [mm] 71ee870ccb: will-it-scale.per_process_ops -2.9% regression kernel test robot
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=20190327124315.eounujow5rvqaaq2@wfg-t540p.sh.intel.com \
--to=fengguang.wu@intel.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=dchinner@redhat.com \
--cc=jenhaochen@google.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=liumartin@google.com \
--cc=salyzyn@android.com \
--cc=salyzyn@google.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: link
Be 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