Date: Sat, 27 Feb 2016 17:27:00 +1100 (EST) From: Bruce Evans <brde@optusnet.com.au> To: Rick Macklem <rmacklem@uoguelph.ca> Cc: fs@freebsd.org Subject: Re: silly write caching in nfs3 Message-ID: <20160227171437.N1735@besplex.bde.org> In-Reply-To: <1347742231.11086226.1456545647628.JavaMail.zimbra@uoguelph.ca> References: <20160226164613.N2180@besplex.bde.org> <1347742231.11086226.1456545647628.JavaMail.zimbra@uoguelph.ca>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 26 Feb 2016, Rick Macklem wrote: > Bruce Evans wrote: >> nfs3 is slower than in old versions of FreeBSD. I debugged one of the >> reasons today. >... >> nfs_open() does the discarding for different reasons in the NMODIFIED >> and !NMODIFIED cases. In the NMODIFED case, it discard unconditionally. >> This case can be avoided by fsync() before close or setting the sysctl >> to commit in close. iozone does he fsync(). This helps in oldnfs but >> not in newfs. With it, iozone on newfs now behaves like it did on oldnfs >> 10-20 years ago. Something (perhaps just the timestamp bugs discussed >> later) "fixed" the discarding on oldnfs 5-10 years ago. >... >> The other reason for discarding is because the timestamps changed -- you >> just wrote them, so the timestamps should have changed. Different bugs >> in comparing the timestamps gave different misbehaviours. >> > You could easily test to see if second-resolution timestamps make a > difference by redefining the NFS_TIMESPEC_COMPARE() macro > { in sys/fs/nfsclient/nfsnode.h } so that it only compares the > tv_sec field and not the tv_nsec field. > --> Then the client would only think the mtime has changed when tv_sec > changes. My server has vfs.timestamp_precision for other reasons, so I get this automatically. So the fixes to use NFS_TIMESTAMP_COMPARE() don't actually work. This together with enabling write commit gives a useful optimization for compiling (it reduces the build time for a FreeBSD-4 kernel from 4.5 seconds to 4.4 seconds. Very useful for compiling hundreds of these :-). Write commit clears NMODIFIED and the buggy timestamp compare then avoids most cache invalidations. BTW, I don't kike the NFS_TIMESTAMP_COMPARE() macro. FreeBSD has a better standard macro timespeccmp(). The names of these macros have different bugs, but timespeccmp() is easier to use since it is shorter and you can see the comparison operator in it and it is not limited to comparing for inequality. NFS_TIMESTAMP_COMPARE() looks like it compares for equality, but actually compares for inequality. Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160227171437.N1735>