I have been investigating a MongoDB performance issue for weeks recently. I am using WiredTiger 2.9.2. I noticed that when io is slow, for example, imposing a cgroup limitation on block iops, the log slot join will have much higher failure rates. That's because some write threads were waiting for too long on the spin lock of slot switch. And the slot switch spin lock was occupied because a force slot switch is doing the log release process, which calls a __log_fs_write(). Because the io was slow, so the lock time was very long.
I wonder if we can release the log slot lock before __wt_write() and reacquire it after, since slots are not overlapped, and concurrent pwrite to a log file should not be a problem.
I have attached my patch as follows, look forward for your reply! Thanks!