[PATCH] D51996: [clangd] Simplify cancellation public API

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 13 00:17:55 PDT 2018


ilya-biryukov added a comment.

> but the thing you're spending the CPU on is checking for cancellation...

Unless checking for cancellation is really cheap (which is doable, I think).
We should probably hit some of those in practice before doing something, though.



================
Comment at: clangd/Cancellation.h:81
+/// Always false if there is no active cancelable task.
+/// This isn't free (context lookup) - don't call it in a tight loop.
+bool isCancelled();
----------------
Allowing fast checking for cancellation seem important.
E.g. if we want to cancel in the middle of parsing, we'll probably be faced with sema callbacks, frequency of which we don't control, so we'd better design something that's fast to check.

I see two ways to deal with this:
- Keep the current design, but cache last access to context key.
- Add an API to get something that can quickly check for cancellation, i.e. something that would hold a reference to resolved context key.

Both could be added later, though, and I don't have any data, it's just my intuition.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51996





More information about the cfe-commits mailing list