Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable L2 cache of all (MRU+MFU) metadata but MFU data only #16402

Merged
merged 1 commit into from
Aug 16, 2024

Conversation

shodanshok
Copy link
Contributor

@shodanshok shodanshok commented Jul 31, 2024

Fixes #16343

l2arc_mfuonly was added to avoid wasting L2 ARC on read-once MRU data and metadata. However it can be useful to cache as much metadata as possible while, at the same time, restricting data cache to MFU buffers only.

This patch allow for such behavior by setting l2arc_mfuonly to 2 (or higher). The list of possible values is the following:
0: cache both MRU and MFU for both data and metadata;
1: cache only MFU for both data and metadata;
2: cache both MRU and MFU for metadata, but only MFU for data.

Motivation and Context

Provide as much metadata L2 cache as possible, while at the same time caching (hopefully) useful MFU data.

Description

See above.

How Has This Been Tested?

Minimal, on local virtual machine only.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

Copy link
Member

@amotin amotin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic of the values looks ugly to me, but I don't have better thoughts.

man/man4/zfs.4 Outdated Show resolved Hide resolved
Fixes openzfs#16343

`l2arc_mfuonly` was added to avoid wasting L2 ARC on read-once MRU
data and metadata. However it can be useful to cache as much
metadata as possible while, at the same time, restricting data
cache to MFU buffers only.

This patch allow for such behavior by setting `l2arc_mfuonly` to 2
(or higher). The list of possible values is the following:
0: cache both MRU and MFU for both data and metadata;
1: cache only MFU for both data and metadata;
2: cache both MRU and MFU for metadata, but only MFU for data.

Signed-off-by: Gionatan Danti <g.danti@assyoma.it>
@behlendorf behlendorf added the Status: Accepted Ready to integrate (reviewed, tested) label Aug 16, 2024
@behlendorf behlendorf merged commit 77a797a into openzfs:master Aug 16, 2024
20 of 23 checks passed
@tkittich
Copy link
Contributor

tkittich commented Aug 22, 2024

@shodanshok Thank you very much for working on this feature. ^^

Maybe it could be possible to check a dataset property and mark a buffer as not eligible for the L2ARC in function l2arc_write_eligible(). It would be great if this feature could be enabled per dataset as a new setting, i.e. metaandmfu, for primarycache and secondarycache properties.

@shodanshok
Copy link
Contributor Author

@shodanshok Thank you very much for working on this feature. ^^

Maybe it could be possible to check a dataset property and mark a buffer as not eligible for the L2ARC in function l2arc_write_eligible(). It would be great if this feature could be enabled per dataset as a new setting, i.e. metaandmfu, for primarycache and secondarycache properties.

I tried something similar during my tests, however it seems to me that it is not possible to that without altering the arc_buf_hdr structure.

More specifically, arc_buf_hdr can be used to distinguish between data and metadata, but not between MRU and MFU status, which are determined by the underlying buffer list. Adding such a field to arc_buf_hdr would mean to a) increase the size of a core structure and b) insert some kind of function to update the new field whenever the buffer switches from MRU to MFU.

So while I agree that would be great to control such thing via dataset property, the patch as-merged provide an immediate workaround without changing the header struct.

@jaen jaen mentioned this pull request Aug 27, 2024
13 tasks
lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Sep 4, 2024
`l2arc_mfuonly` was added to avoid wasting L2 ARC on read-once MRU
data and metadata. However it can be useful to cache as much
metadata as possible while, at the same time, restricting data
cache to MFU buffers only.

This patch allow for such behavior by setting `l2arc_mfuonly` to 2
(or higher). The list of possible values is the following:
0: cache both MRU and MFU for both data and metadata;
1: cache only MFU for both data and metadata;
2: cache both MRU and MFU for metadata, but only MFU for data.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Gionatan Danti <g.danti@assyoma.it>
Closes openzfs#16343 
Closes openzfs#16402
tonyhutter pushed a commit that referenced this pull request Sep 4, 2024
`l2arc_mfuonly` was added to avoid wasting L2 ARC on read-once MRU
data and metadata. However it can be useful to cache as much
metadata as possible while, at the same time, restricting data
cache to MFU buffers only.

This patch allow for such behavior by setting `l2arc_mfuonly` to 2
(or higher). The list of possible values is the following:
0: cache both MRU and MFU for both data and metadata;
1: cache only MFU for both data and metadata;
2: cache both MRU and MFU for metadata, but only MFU for data.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Gionatan Danti <g.danti@assyoma.it>
Closes #16343 
Closes #16402
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

L2ARC with metadata and MFU only
4 participants