4 ms·
> So reader/writer locks tend to rely on the additional concurrency, and on readers not blocking other readers. > software has a constant tendency to get slowe
by tntn 7y ago
> So reader/writer locks tend to rely on the additional concurrency, and on readers not blocking other readers.
> software has a constant tendency to get slower, absent deliberate and careful efforts to hold the line, as developers add features and complexity. And if slower processes don’t immediately impact performance (because they only hold read locks), they’re more likely to go unnoticed. Thus, it’s not unlikely that over time read lock durations will creep upwards, mostly without effect, until one happens to coincide with an attempt to grab a write lock.
For me, the takeaway here is to maintain discipline in software regarding locking behavior. It's almost always a bad idea to hold a lock (rw or not) for an extended period of time.
Notably, this is how the Linux kernel developers responded to the case linked in the discussion of mmap_sem - the operation quadratic in number of threads was thrown out to avoid holding the rwsem for extended periods of time.
Also, re "and the lock is held by readers for a significant length of time": I would imagine that Rusty Russell would consider a few microseconds a "significant length of time" and wonder if you were insane if your software held a lock for 60 seconds.
- dmit 7y agoIn a perfect world "maintaining discipline" is indeed the correct solution, but my experience tells me that humans cannot be relied upon to do that. Some individual humans can, but not the collective whole. The discipline has to come from elsewhere. Either from the management (reducing the number of people you have to rely on from N to log(N)), or from tooling (reducing the number to log(1)). As always, education is the silver bullet. Instill proper values, enable the skills to follow through, and in a mere 40-60 years the industry will be in a better place. As long as there is no incentive to mass-produce junior software developers on the cheap, we're golden.