From: Jan Kara <jack@suse.cz>
To: "Ritesh Harjani (IBM)" <ritesh.list@gmail.com>
Cc: Jan Kara <jack@suse.cz>, Ted Tso <tytso@mit.edu>,
linux-ext4@vger.kernel.org,
Thorsten Leemhuis <regressions@leemhuis.info>,
Ojaswin Mujoo <ojaswin@linux.ibm.com>,
Stefan Wahren <stefan.wahren@i2se.com>,
Andreas Dilger <adilger.kernel@dilger.ca>
Subject: Re: [PATCH 5/5] ext4: Use buckets for cr 1 block scan instead of rbtree
Date: Thu, 8 Sep 2022 11:01:37 +0200 [thread overview]
Message-ID: <20220908090137.ojysovmucdmlfbti@quack3> (raw)
In-Reply-To: <20220907184110.wu2uqs7s3hggdtj2@riteshh-domain>
On Thu 08-09-22 00:11:10, Ritesh Harjani (IBM) wrote:
> On 22/09/06 05:29PM, Jan Kara wrote:
> > Using rbtree for sorting groups by average fragment size is relatively
> > expensive (needs rbtree update on every block freeing or allocation) and
> > leads to wide spreading of allocations because selection of block group
> > is very sentitive both to changes in free space and amount of blocks
> > allocated. Furthermore selecting group with the best matching average
> > fragment size is not necessary anyway, even more so because the
> > variability of fragment sizes within a group is likely large so average
> > is not telling much. We just need a group with large enough average
> > fragment size so that we have high probability of finding large enough
> > free extent and we don't want average fragment size to be too big so
> > that we are likely to find free extent only somewhat larger than what we
> > need.
> >
> > So instead of maintaing rbtree of groups sorted by fragment size keep
> > bins (lists) or groups where average fragment size is in the interval
> > [2^i, 2^(i+1)). This structure requires less updates on block allocation
> > / freeing, generally avoids chaotic spreading of allocations into block
> > groups, and still is able to quickly (even faster that the rbtree)
> > provide a block group which is likely to have a suitably sized free
> > space extent.
>
> This makes sense because we anyways maintain buddy bitmap for MB_NUM_ORDERS
> bitmaps. Hence our data structure to maintain different lists of groups, with
> their average fragments size can be bounded within MB_NUM_ORDERS lists.
> This also makes it for amortized O(1) search time for finding the right group
> in CR1 search.
>
> >
> > This patch reduces number of block groups used when untarring archive
> > with medium sized files (size somewhat above 64k which is default
> > mballoc limit for avoiding locality group preallocation) to about half
> > and thus improves write speeds for eMMC flash significantly.
> >
>
> Indeed a nice change. More inline with the how we maintain
> sbi->s_mb_largest_free_orders lists.
I didn't really find more comments than the one below?
> I think as you already noted there are few minor checkpatch errors,
> other than that one small query below.
Yep, some checkpatch errors + procfs file handling bugs + one bad unlock in
an error recovery path. All fixed up locally :)
> > -/*
> > - * Reinsert grpinfo into the avg_fragment_size tree with new average
> > - * fragment size.
> > - */
> > +/* Move group to appropriate avg_fragment_size list */
> > static void
> > mb_update_avg_fragment_size(struct super_block *sb, struct ext4_group_info *grp)
> > {
> > struct ext4_sb_info *sbi = EXT4_SB(sb);
> > + int new_order;
> >
> > if (!test_opt2(sb, MB_OPTIMIZE_SCAN) || grp->bb_free == 0)
> > return;
> >
> > - write_lock(&sbi->s_mb_rb_lock);
> > - if (!RB_EMPTY_NODE(&grp->bb_avg_fragment_size_rb)) {
> > - rb_erase(&grp->bb_avg_fragment_size_rb,
> > - &sbi->s_mb_avg_fragment_size_root);
> > - RB_CLEAR_NODE(&grp->bb_avg_fragment_size_rb);
> > - }
> > + new_order = mb_avg_fragment_size_order(sb,
> > + grp->bb_free / grp->bb_fragments);
>
> Previous rbtree change was always checking for if grp->bb_fragments for 0.
> Can grp->bb_fragments be 0 here?
Since grp->bb_free is greater than zero, there should be at least one
fragment...
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2022-09-08 9:01 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-06 15:29 [PATCH 0/5 v2] ext4: Fix performance regression with mballoc Jan Kara
2022-09-06 15:29 ` [PATCH 1/5] ext4: Make mballoc try target group first even with mb_optimize_scan Jan Kara
2022-09-07 17:43 ` Ritesh Harjani (IBM)
2022-09-06 15:29 ` [PATCH 2/5] ext4: Avoid unnecessary spreading of allocations among groups Jan Kara
2022-09-07 18:05 ` Ritesh Harjani (IBM)
2022-09-08 8:57 ` Jan Kara
2022-09-08 9:24 ` Ritesh Harjani (IBM)
2022-09-06 15:29 ` [PATCH 3/5] ext4: Make directory inode spreading reflect flexbg size Jan Kara
2022-09-06 15:29 ` [PATCH 4/5] ext4: Use locality group preallocation for small closed files Jan Kara
2022-09-07 18:25 ` Ritesh Harjani (IBM)
2022-09-06 15:29 ` [PATCH 5/5] ext4: Use buckets for cr 1 block scan instead of rbtree Jan Kara
2022-09-07 18:41 ` Ritesh Harjani (IBM)
2022-09-08 9:01 ` Jan Kara [this message]
2022-09-08 9:23 ` Ritesh Harjani (IBM)
2022-09-08 8:29 ` Ojaswin Mujoo
2022-09-08 9:03 ` Jan Kara
2022-09-08 11:00 ` Dan Carpenter
2022-09-08 11:33 ` Jan Kara
2022-09-06 20:38 ` [PATCH 0/5 v2] ext4: Fix performance regression with mballoc Stefan Wahren
2022-09-07 10:49 ` Jan Kara
2022-09-07 13:02 ` Jan Kara
2022-09-08 8:17 ` Ojaswin Mujoo
2022-09-08 9:12 ` Jan Kara
-- strict thread matches above, loose matches on Subject: below --
2022-09-08 9:21 [PATCH 0/5 v3] " Jan Kara
2022-09-08 9:21 ` [PATCH 5/5] ext4: Use buckets for cr 1 block scan instead of rbtree Jan Kara
2022-09-09 6:12 ` Ritesh Harjani (IBM)
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=20220908090137.ojysovmucdmlfbti@quack3 \
--to=jack@suse.cz \
--cc=adilger.kernel@dilger.ca \
--cc=linux-ext4@vger.kernel.org \
--cc=ojaswin@linux.ibm.com \
--cc=regressions@leemhuis.info \
--cc=ritesh.list@gmail.com \
--cc=stefan.wahren@i2se.com \
--cc=tytso@mit.edu \
/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