We had just finished making the change, I ran git commit, and immediately Zed froze, started to beachball…, and 10 seconds later it was back. Hmm...

Fixing the Git Blame Beachball

submited by
Style Pass
2024-05-06 20:00:05

We had just finished making the change, I ran git commit, and immediately Zed froze, started to beachball…, and 10 seconds later it was back.

Hmm... our process is doing... nothing...? That doesn't make sense. At least Instruments agrees that this is a "Severe Hang".

Well, that's interesting, the main thread is indeed blocked (and indeed so are almost all our backgrount threads). But why?

It's stuck in a syscall psynch_cvwait. That's a condition variable wait, but what's it waiting for? None of our background threads seem to be doing anything either...

Looking at the stack-trace by clicking the bottom-most right-most icon gives us a glimmer of a clue, but more of a "that shouldn't happen".

It looks like the main thread is blocking deliberately, in a block_with_timeout. We do this in a few places to ensure that if we can do a user-visible task quickly the result shows up on the next frame. That said the timeout is set to 5ms so that if the task takes longer than expected we don't block the UI thread. In this case we blocked for 4550ms which is, checks notes, about 1000 times too long.

Pushing that question to the side: Why isn't the main thread being woken up after 5ms? We continued clicking around in Instruments.

Leave a Comment