Skip to content

x/sys/unix: new cachestat syscall in Linux 6.5 #61917

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

Closed
mauri870 opened this issue Aug 10, 2023 · 1 comment
Closed

x/sys/unix: new cachestat syscall in Linux 6.5 #61917

mauri870 opened this issue Aug 10, 2023 · 1 comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FeatureRequest Issues asking for a new feature that does not need a proposal. FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@mauri870
Copy link
Member

mauri870 commented Aug 10, 2023

A new system call called "cachestat" will be introduced in Linux 6.5 (currently RC5), which enables user-space applications to retrieve detailed page cache statistics for a specific file. This syscall provides valuable insights for making informed decisions about file operations and resource management.

While Linux already has the "mincore" syscall (which we have already in x/sys/unix and runtime) for checking page residency in memory, "cachestat" offers more extensive page cache statistics, aiming to enhance scalability. The syscall's output includes information about cached pages, dirty pages, pages marked for writeback, evicted pages, and recently evicted pages.

This new syscall seems to be quite a lot faster than mincore in some benchmarks shared here.

Some possible use cases for it:

  • Databases can make query decisions based on the in-memory cache state of indexes. Offering visibility into the writeback algorithm to diagnose performance issues effectively.
  • Implementing workload-aware writeback pacing, estimating IO managed by page cache for smarter synchronization and batching.
  • Providing a memory usage computation for large files and directories, akin to the disk usage analysis performed by the 'du' tool.

Copied from Phoronix

struct cachestat_range {
    __u64 off;
    __u64 len;
};

struct cachestat {
    __u64 nr_cache;
    __u64 nr_dirty;
    __u64 nr_writeback;
    __u64 nr_evicted;
    __u64 nr_recently_evicted;
}

asmlinkage long sys_cachestat(unsigned int fd,
		struct cachestat_range __user *cstat_range,
		struct cachestat __user *cstat, unsigned int flags);
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Aug 10, 2023
@gopherbot gopherbot added this to the Unreleased milestone Aug 10, 2023
@mknyszek mknyszek added NeedsFix The path to resolution is known, but the work has not been done. help wanted labels Aug 10, 2023
@mknyszek mknyszek added the FeatureRequest Issues asking for a new feature that does not need a proposal. label Aug 10, 2023
mauri870 added a commit to mauri870/sys that referenced this issue Oct 7, 2023
The cachestat system call is an alternative to mincore that
offers more extensive page cache statistics, aiming to enhance
scalability. It was added on Linux 6.5.

Fixes golang/go#61917
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/533242 mentions this issue: unix: add linux cachestat system call

@github-project-automation github-project-automation bot moved this from Todo to Done in Go Compiler / Runtime Oct 10, 2023
@golang golang locked and limited conversation to collaborators Oct 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FeatureRequest Issues asking for a new feature that does not need a proposal. FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants