summaryrefslogtreecommitdiffstats
path: root/sys/sys/rangelock.h
diff options
context:
space:
mode:
authorcperciva <cperciva@FreeBSD.org>2013-08-15 20:19:17 +0000
committercperciva <cperciva@FreeBSD.org>2013-08-15 20:19:17 +0000
commit8544609e649a9e074023f253de79d42b4d7d11e6 (patch)
tree4269ac322b715795b2eb9b74bd3b25dc79b21f76 /sys/sys/rangelock.h
parent6d37e23f0ac7ee8dd61ffd3d96cbdbef9994b541 (diff)
downloadFreeBSD-src-8544609e649a9e074023f253de79d42b4d7d11e6.zip
FreeBSD-src-8544609e649a9e074023f253de79d42b4d7d11e6.tar.gz
Change the queue of locks in kern_rangelock.c from holding lock requests in
the order that they arrive, to holding (a) granted write lock requests, followed by (b) granted read lock requests, followed by (c) ungranted requests, in order of arrival. This changes the stopping condition for iterating through granted locks to see if a new request can be granted: When considering a read lock request, we can stop iterating as soon as we see a read lock request, since anything after that point is either a granted read lock request or a request which has not yet been granted. (For write lock requests, we must still compare against all granted lock requests.) For workloads with R parallel reads and W parallel writes, this improves the time spent from O((R+W)^2) to O(W*(R+W)); i.e., heavy parallel-read workloads become significantly more scalable. No statistically significant change in buildworld time has been measured, but synthetic tests of parallel 'dd > /dev/null' and 'openssl enc >/dev/null' with the input file cached yield dramatic (up to 10x) improvement with high (up to 128 processes) levels of parallelism. Reviewed by: kib
Diffstat (limited to 'sys/sys/rangelock.h')
-rw-r--r--sys/sys/rangelock.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/sys/rangelock.h b/sys/sys/rangelock.h
index fb0d252..2a904c0 100644
--- a/sys/sys/rangelock.h
+++ b/sys/sys/rangelock.h
@@ -48,9 +48,13 @@ struct rl_q_entry;
* Access to the structure itself is synchronized with the externally
* supplied mutex.
*
- * rl_waiters is the queue of lock requests in the order of arrival.
+ * rl_waiters is the queue containing in order (a) granted write lock
+ * requests, (b) granted read lock requests, and (c) in order of arrival,
+ * lock requests which cannot be granted yet.
+ *
* rl_currdep is the first lock request that cannot be granted now due
- * to the preceding requests conflicting with it.
+ * to the preceding requests conflicting with it (i.e., it points to
+ * position (c) in the list above).
*/
struct rangelock {
TAILQ_HEAD(, rl_q_entry) rl_waiters;
OpenPOWER on IntegriCloud