INVARIANTS vs DIAGNOSTIC % lf_advlockasync

Andriy Gapon avg at FreeBSD.org
Wed Dec 28 09:30:25 UTC 2016


I wonder if there are any guidelines on when to use INVARIANTS vs DIAGNOSTIC vs
something else.  Should the amount of output be taken into account?  Or the
performance impact?  Or just the common sense?

What I really mean is that if some sanity check could be rather expensive (e.g.
it needs to iterate over a potentially long list), what option should be used to
enabled it?

I ask this question with one particular case in mind.
lf_advlockasync() has a block of code under INVARIANTS with a loop over a list
that has a nested loop over the same list for pair-wise checks.
What's worse is that that code is executed with a lock held and that lock can
potentially be highly contended (ls_lock).
In our test environment we can observe the lock being held for as much as 125
milliseconds resulting in a huge backlog on the lock.  (Even though the
requested advisory locks are all shared locks and unlocks.)

So, we would like to reduce the performance hit in that code, but still have the
benefits of INVARIANTS enabled over all.

Any suggestions are welcome.
Thank you.
-- 
Andriy Gapon


More information about the freebsd-fs mailing list