linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Zhuravlev <azhuravlev@whamcloud.com>
To: "linux-ext4@vger.kernel.org" <linux-ext4@vger.kernel.org>
Subject: Re: [RFC] improve malloc for large filesystems
Date: Thu, 21 Nov 2019 14:41:49 +0000	[thread overview]
Message-ID: <BCFC8274-0A4E-42E7-9D11-647D47316BD2@whamcloud.com> (raw)
In-Reply-To: <43DA6456-AAF9-4225-A79F-CF632AC5241B@gmail.com>



> On 21 Nov 2019, at 12:18, Artem Blagodarenko <artem.blagodarenko@gmail.com> wrote:
> 
> cr=0 and cr=1 are also important. They allow to accelerate allocator, by increasing allocation window.
> Step by step from smallest to the biggest value in preallocation table.
> Your optimisation can reset this allocation window grow.

Does it?
If allocated chunk is smaller than goal one (to predicted filesize), then next allocation will try to allocate the remained, AFAIR.
But prediction doesn’t depend on the previous allocation, essentially it just align current file size + allocation to the next 2^n
(or from the table in other versions).

cr=0 is an optimisation on its own as it checks only 2^n chunks which is cheap in terms of cycles.
cr=1 is a more expensive, we skip groups likely having no good extents (using average), but we still search for the goal size.

> Assume we have one fragmented part of disk and all other parts are quite free.
> Allocator will spend a lot of time to go through this fragmented part, because  will brake cr0 and cr1 and get
> range that satisfy c3. 

Even at cr=3 we still search for the goal size.

Thus we shouldn’t really allocate bad chunks because we break cr=0 and cr=1, we just stop to look for nicely looking groups
and fallback to regular (more expensive) search for free extents.

> 
> c3 requirement is quite simple “get first group that have enough free blocks to allocate requested range”.

This is only group selection, then we try to find that extent within that group, can fail and move to the next group.
EXT4_MB_HINT_FIRST is set outside of the main cr=0..3 loop.

> With hight probability allocator find such group at the start of c3 loop, so goal (allocator starts its searching from goal) will not significantly changed.
> Thus allocator go through this fragmented range using small steps.
> 
> Without suggested optimisation, allocator skips this fragmented range at moment and continue to allocate blocks.

1000 groups * 5ms avg.time = 5 seconds to skip 1000 bad uninitialized groups. This is the real problem.
You mentioned 4M groups...

Thanks, Alex
 

  reply	other threads:[~2019-11-21 14:41 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-20 10:35 [RFC] improve malloc for large filesystems Alex Zhuravlev
2019-11-20 11:56 ` Artem Blagodarenko
2019-11-20 18:33   ` Alex Zhuravlev
2019-11-20 18:13 ` Theodore Y. Ts'o
2019-11-20 18:22   ` Alex Zhuravlev
2019-11-21  7:03   ` Alex Zhuravlev
2019-11-21  8:30     ` Artem Blagodarenko
2019-11-21  8:52       ` Alex Zhuravlev
2019-11-21  9:18         ` Artem Blagodarenko
2019-11-21 14:41           ` Alex Zhuravlev [this message]
2019-11-25 21:39             ` Andreas Dilger
2019-12-02  8:46               ` Alex Zhuravlev
2019-11-21  7:03   ` Alex Zhuravlev

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=BCFC8274-0A4E-42E7-9D11-647D47316BD2@whamcloud.com \
    --to=azhuravlev@whamcloud.com \
    --cc=linux-ext4@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).