This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Respect task cancellation in TUScheduler.
ClosedPublic

Authored by sammccall on Nov 20 2018, 2:51 AM.

Details

Summary
  • Reads are never executed if canceled before ready-to run. In practice, we finalize cancelled reads eagerly and out-of-order.
  • Cancelled reads don't prevent prior updates from being elided, as they don't actually depend on the result of the update.
  • Updates are downgraded from WantDiagnostics::Yes to WantDiagnostics::Auto when cancelled, which allows them to be elided when all dependent reads are cancelled and there are subsequent writes. (e.g. when the queue is backed up with cancelled requests).

The queue operations aren't optimal (we scan the whole queue for cancelled
tasks every time the scheduler runs, and check cancellation twice in the end).
However I believe these costs are still trivial in practice (compared to any
AST operation) and the logic can be cleanly separated from the rest of the
scheduler.

Diff Detail

Repository
rL LLVM

Event Timeline

sammccall created this revision.Nov 20 2018, 2:51 AM
ilya-biryukov accepted this revision.Nov 21 2018, 5:19 AM

LGTM

clangd/TUScheduler.cpp
598 ↗(On Diff #174738)

NIT: maybe also break on non-cancelled reads? Going past this point does not seem particularly useful, as we won't be able to cancel any pending updates before them anyway. And it does not seem like responding for a cancelled task fast is higher priority than delivering the results of that non-cancelled read.

This revision is now accepted and ready to land.Nov 21 2018, 5:19 AM
This revision was automatically updated to reflect the committed changes.
This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.