linux cachestat in file Readv and Prefetch

From: Cedric Villemain <Cedric(dot)Villemain+pgsql(at)abcSQL(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: linux cachestat in file Readv and Prefetch
Date: 2024-01-18 00:25:41
Message-ID: cbe67692-ad03-4c5a-a5bb-405a438e9cda@abcSQL.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I was testing the index prefetch and streamIO patches and I added
cachestat() syscall to get a better view of the prefetching.

It's a new linux syscall, it requires 6.5, it provides numerous
interesting information from the VM for the range of pages examined.
It's way way faster than the old mincore() and provides much more
valuable information:

    uint64 nr_cache;        /* Number of cached pages */
    uint64 nr_dirty;           /* Number of dirty pages */
    uint64 nr_writeback;  /* Number of pages marked for writeback. */
    uint64 nr_evicted;       /* Number of pages evicted from the cache. */
    /*
    * Number of recently evicted pages. A page is recently evicted if its
    * last eviction was recent enough that its reentry to the cache would
    * indicate that it is actively being used by the system, and that there
    * is memory pressure on the system.
    */
    uint64 nr_recently_evicted;

While here I also added some quick tweaks to suspend prefetching on
memory pressure.
It's working but I have absolutely not checked the performance impact of
my additions.

Sharing here for others to tests and adding in CF in case there is
interest to go further in this direction.

---
Cédric Villemain +33 (0)6 20 30 22 52
https://Data-Bene.io
PostgreSQL Expertise, Support, Training, R&D

--
---
Cédric Villemain +33 (0)6 20 30 22 52
https://Data-Bene.io
PostgreSQL Expertise, Support, Training, R&D

Attachment Content-Type Size
v1-0001-Add-cachestat-requires-linux-6.5.patch text/x-patch 4.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message James Coleman 2024-01-18 00:34:36 Re: Teach predtest about IS [NOT] <boolean> proofs
Previous Message Cédric Villemain 2024-01-18 00:24:54 linux cachestat in file Readv and Prefetch