This is an archive of the discontinued LLVM Phabricator instance.

[clangd][NFC] Explode ReceivedPreamble into a CV
ClosedPublic

Authored by kadircet on May 29 2020, 3:06 AM.

Details

Summary

Instead of a notification, we make use of a CV and store the boolean on
LatestPreamble by converting it into an optional.

Depends on D80293.

Diff Detail

Event Timeline

kadircet created this revision.May 29 2020, 3:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 29 2020, 3:06 AM
sammccall added inline comments.May 29 2020, 7:25 AM
clang-tools-extra/clangd/TUScheduler.cpp
664

Does LatestPreamble signal RequestsCV or just PreambleCV?

Seems like it might be less error-prone to have just one CV, signalled when preamble requests are scheduled, latest preamble becomes available, and on shutdown. The spurious wakeups shouldn't be a real problem, right?

kadircet marked an inline comment as done.May 29 2020, 12:01 PM
kadircet added inline comments.
clang-tools-extra/clangd/TUScheduler.cpp
664

Does LatestPreamble signal RequestsCV or just PreambleCV?

it only signals PreambleCV. But it makes no sense for this code path to block on it, as it is signalled by the same thread. So in theory we should see LatestPreamble and not start blocking in such case.

Seems like it might be less error-prone to have just one CV, signalled when preamble requests are scheduled, latest preamble becomes available, and on shutdown. The spurious wakeups shouldn't be a real problem, right?

Yeah spurious wake-ups aren't really a problem. I thought having separate CVs sounded more clear, as predicates would still look the same even if we only had one CV. So it would enforce us to signal/wait on the right condition variable.

Happy to have only a single one too, do you have any suggestions for its name?

sammccall added inline comments.Jun 8 2020, 12:42 AM
clang-tools-extra/clangd/TUScheduler.cpp
664

Yeah, I think that having the CV not cover all the conditions, with correctness due to what threads the conditions are set on, is a bit too subtle.
I'd prefer a single CV named PreambleCV with an appropriate comment seems clear, WDYT?

kadircet updated this revision to Diff 269487.Jun 9 2020, 4:12 AM
kadircet marked 2 inline comments as done.
  • Make distinction between PreambleCV and RequestsCV clearer.
sammccall accepted this revision.Jun 9 2020, 6:06 AM
This revision is now accepted and ready to land.Jun 9 2020, 6:06 AM
This revision was automatically updated to reflect the committed changes.