pcstat icon indicating copy to clipboard operation
pcstat copied to clipboard

Add support for cachestat syscall as mincore alternative

Open boomskats opened this issue 1 year ago • 0 comments

This adds support for the cachestat syscall introduced in kernel 6.5 by @nhatsmrt as an alternative to mmap/mincore. I've tried to make sure that the output is fully backward-compatible and users have to explicitly opt-in to the mechanism. The only output that's changed is the -json output where I've added the newly available stats if and only -cachestat is chosen.

There's some good background on the new syscall here. I guess the headline is this:

Using cachestat real -- Median: 33.377s, Average: 33.475s, Standard Deviation: 0.3602 user -- Median: 4.08s, Average: 4.1078s, Standard Deviation: 0.0742 sys -- Median: 28.823s, Average: 28.8866s, Standard Deviation: 0.2689

Using mincore: real -- Median: 102.352s, Average: 102.3442s, Standard Deviation: 0.2059 user -- Median: 10.149s, Average: 10.1482s, Standard Deviation: 0.0162 sys -- Median: 91.186s, Average: 91.2084s, Standard Deviation: 0.2046

I also ran both syscalls on a 2TB sparse file:

Using cachestat: real 0m0.009s user 0m0.000s sys 0m0.009s

Using mincore: real 0m37.510s user 0m2.934s sys 0m34.558s

I'm going to run some more tests over the next few days, but it looks like 15GB ish is the sweet spot where the new syscall starts to make a difference.

boomskats avatar Nov 06 '24 22:11 boomskats