Re: [RFC PATCH 0/3] Neural Storage Driver - learning page cache prefetcher
Ayhan Aydin <[email protected]>
| Newsgroups | org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel,org.kvack.linux-mm |
|---|---|
| Message-ID | <CAFLp9PEHKcdAgt3LX1m_0+H=foY+Va8gtSv6r7Gp1RVcKZ7YiA@mail.gmail.com> |
Hi Matthew, Thanks for taking the time to look at this. Really appreciate the detailed feedback. Adding Jan and linux-fsdevel to this reply per your suggestion rather than waiting for the next round. > Architecturally, we're only hooking into the read path and ignoring > the page fault path. Was that a deliberate choice? Yes, deliberate, though I'd frame it as a starting point rather than a final position. The read path was attractive because hooking there let NSD observe and build its access-pattern model without adding latency to the caller's path. The benchmarks I mentioned (18-19% wall-time reduction, +22.6% throughput) are from that observer-only design. The page fault path is synchronous and latency-sensitive by nature, so I was cautious about touching it before the read-path approach had proven itself. I don't think it needs to stay excluded, though. A lightweight, sampled hook (rather than firing on every fault) could let NSD extend its model to fault-driven access without sitting directly in the fault-critical path. Happy to prototype that and bring overhead numbers before proposing it as part of the series. > It would be nice to replace the existing mechanism of marking folios > with PG_readahead, if that's possible. This is the part I want to be most careful about, and I'd like your read on it. Right now NSD is purely an observer. It never touches ra_state/file_ra_struct or the PG_readahead flag itself; all actual page insertion is still delegated to the existing mechanism. That was a deliberate safety choice: with CONFIG_NSD off, or even with the module unloaded at runtime, the kernel's readahead behavior is completely unaffected. There's no state that depends on NSD having been loaded. Moving to something that actually drives PG_readahead / the readahead window would make NSD a lot more useful, but I want to preserve that same guarantee: the kernel must always be able to fall back to its native behavior instantly and safely if NSD is removed, even mid-operation. Before I go down that path I'd like to talk through where the safest integration point is, whether that's advising the existing ondemand_readahead() logic rather than replacing it, or something else you'd suggest. > It'd be nice to be able to detect backward access patterns as well > as forward access patterns. Right now the predictor (Markov chain / frequency-recency based) is forward-only. It assumes roughly monotonic access. Backward detection is something I hadn't prioritized yet but agree it's a real gap. Happy to look at extending the per-inode context tracking to catch reverse sequential access as a next step. Let me know which of these you'd want to see first. I could start with a writeup of the sampled fault-path hook, or with a proposal for how NSD could advise readahead decisions without owning the state. Whichever is more useful for moving this forward. Thanks again, Ayhan