Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-doc
Path: blob/main/website/content/en/status/report-2023-10-2023-12/packrat.adoc
18096 views
=== Packrat - NFS client caching on non-volatile storage

Contact: Rick Macklem <[email protected]>

NFSv4.1/4.2 provides support for a feature called delegations.
When a NFSv4.1/4.2 client holds a delegation, the client has certain rights to a file, including a guarantee that no other client will make changes to the file unless the delegation is recalled.
As such, when a client holds a delegation for a file, it can aggressively cache the file's data, knowing that it will not be modified by other clients until it returns the delegation.

This project is intended to allow the NFSv4.1/4.2 client to aggressively cache file data on client local non-volatile storage, when the client holds a delegation for the file.
I created a patch long ago to try and do this for NFSv4.0, but it was never at a stage where it was worth using.
This project is a complete rewrite of the patch, done in part because NFSv4.1/4.2 plus other recent NFSv4-related changes make doing this more feasible.

I now have code running fairly well and hope to have a patch ready for others to test this winter.
Early testing shows promise.
For a test run of "make buildkernel", the test with and without packrat enabled performed as follows:

.NFS operation counts
[cols="1,1,1,1,1,1", frame="none", options="header"]
|===
| NFS operation counts
| Getattr
| Lookup
| Read
| Write
| Total RPCs

|with packrats
|433506
|99254
|0
|0
|371736

|without packrats
|2359913
|97954
|10748
|0
|2318810

|===

.Elapsed Run Time
[cols="1,1,1", frame="none", options="header"]
|===
| Elapsed Run Time (sec)
| with packrat
| without packrat

| 
|5561
|6203

|===

As you can see, the packrat case ran a little faster and with fewer RPCs.
Although this test was run on my little LAN, it is hoped that a NFSv4.1/4.2 mount over a WAN would show a larger difference in performance.
I will note that the packrat cache was primed by unrolling a tarball of FreeBSD's [.filename]#/usr/src# into the NFSv4.1/4.2 mount.

This will be very much an experimental feature, but it is hoped it will allow NFS mounts to be used more effectively, particularly in WAN situations, such as a mobile laptop.

There is still work to be done, particularly with respect to recovery of delegations after a NFSv4.1/4.2 client restart.
Hopefully, the next status report will include a URL that allows downloading of a patch for user testing.