summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/Threading.h
Commit message (Collapse)AuthorAgeFilesLines
* [clangd] Remove obsolete includes. NFCSam McCall2019-09-041-2/+2
| | | | llvm-svn: 370865
* [clangd] Move threading helper to more appropriate header. NFCSam McCall2019-09-041-0/+14
| | | | llvm-svn: 370864
* [clangd] Use llvm::set_thread_priority in background-indexKadir Cetinkaya2019-04-181-10/+0
| | | | | | | | | | | | Reviewers: gribozavr Subscribers: krytarowski, ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jfb, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60865 llvm-svn: 358664
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [clangd] Only reduce priority of a thread for indexing.Kadir Cetinkaya2018-12-171-1/+1
| | | | | | | | | | | | | | | | | | Summary: We'll soon have tasks pending for reading shards from disk, we want them to have normal priority. Because: - They are not CPU intensive, mostly IO bound. - Give a good coverage for the project at startup, therefore it is worth spending some cycles. - We have only one task per whole CDB rather than one task per file. Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D55315 llvm-svn: 349345
* [clangd] Avoid emitting Queued status when we are able to acquire the Barrier.Haojian Wu2018-12-131-0/+1
| | | | | | | | | | Reviewers: ilya-biryukov Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D55359 llvm-svn: 349032
* [clangd] Prevent thread starvation in tests on loaded systems.Sam McCall2018-11-271-0/+4
| | | | | | | | | | | | | | Summary: Background index deliberately runs low-priority, but for tests this may stop them making progress. Reviewers: kadircet Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D54938 llvm-svn: 347655
* [clangd] Use thread pool for background indexing.Kadir Cetinkaya2018-10-301-0/+8
| | | | | | | | | | | | Reviewers: sammccall, ioeric Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D53651 llvm-svn: 345590
* [clangd] Use 'const Twine&' instead of 'Twine'. NFCIlya Biryukov2018-07-261-1/+1
| | | | | | To fix clang-tidy warning llvm-svn: 338037
* [clangd] Replace UniqueFunction with llvm::unique_function.Benjamin Kramer2018-07-031-1/+1
| | | | | | One implementation of this ought to be enough for everyone. llvm-svn: 336228
* [clangd] Debounce streams of updates.Sam McCall2018-03-021-7/+39
| | | | | | | | | | | | | | | | | | | Summary: Don't actually start building ASTs for new revisions until either: - 500ms have passed since the last revision, or - we actually need the revision for something (or to unblock the queue) In practice, this avoids the "first keystroke results in diagnostics" problem. This is kind of awkward to test, and the test is pretty bad. It can be observed nicely by capturing a trace, though. Reviewers: hokein, ilya-biryukov Subscribers: klimek, jkorous-apple, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D43648 llvm-svn: 326546
* [clangd] Allow embedders some control over when diagnostics are generated.Sam McCall2018-02-221-16/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Through the C++ API, we support for a given snapshot version: - Yes: make sure we generate diagnostics for exactly this version - Auto: generate eventually-consistent diagnostics for at least this version - No: don't generate diagnostics for this version Eventually auto should be debounced for better UX. Through LSP, we force diagnostics for initial load (bypassing future debouncing) and all updates follow the "auto" policy. This is complicated to implement under the CancellationFlag design, so rewrote that part to just inspect the queue instead. It turns out we never pass None to the diagnostics callback, so remove Optional from the signature. The questionable behavior of not invoking the callback at all if CppFile::rebuild fails is not changed. Reviewers: ilya-biryukov Subscribers: klimek, jkorous-apple, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D43518 llvm-svn: 325774
* [clangd] Tracing: name worker threads, and enforce naming scheduled async tasksSam McCall2018-02-191-1/+3
| | | | | | | | | | | | | | | | | | | Summary: This has a bit of a blast radius, but I think there's enough value in "forcing" us to give names to these async tasks for debugging. Guessing about what multithreaded code is doing is so unfun... The "file" param attached to the tasks may seem to be redundant with the thread names, but note that thread names are truncated to 15 chars on linux! We'll be lucky to get the whole basename... Reviewers: ilya-biryukov Subscribers: klimek, jkorous-apple, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D43388 llvm-svn: 325480
* [clangd] Stop exposing Futures from ClangdServer operations.Sam McCall2018-02-131-3/+19
| | | | | | | | | | | | | | | | | | | | Summary: LSP has asynchronous semantics, being able to block on an async operation completing is unneccesary and leads to tighter coupling with the threading. In practice only tests depend on this, so we add a general-purpose "block until idle" function to the scheduler which will work for all operations. To get this working, fix a latent condition-variable bug in ASTWorker, and make AsyncTaskRunner const-correct. Reviewers: ilya-biryukov Subscribers: klimek, jkorous-apple, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D43127 llvm-svn: 324990
* Resubmit "[clangd] The new threading implementation"Ilya Biryukov2018-02-081-54/+45
| | | | | | | | | | | Initially submitted as r324356 and reverted in r324386. This change additionally contains a fix to crashes of the buildbots. The source of the crash was undefined behaviour caused by std::future<> whose std::promise<> was destroyed without calling set_value(). llvm-svn: 324575
* Revert "[clangd] The new threading implementation" (r324356)Ilya Biryukov2018-02-061-45/+54
| | | | | | | | | | | | And the follow-up changes r324361 and r324363. These changes seem to break two buildbots: - http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/14091 - http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules-2/builds/16001 We will need to investigate what went wrong and resubmit the changes afterwards. llvm-svn: 324386
* [clangd] The new threading implementationIlya Biryukov2018-02-061-54/+45
| | | | | | | | | | | | | | | | | | Summary: In the new threading model clangd creates one thread per file to manage the AST and one thread to process each of the incoming requests. The number of actively running threads is bounded by the semaphore to avoid overloading the system. Reviewers: sammccall Reviewed By: sammccall Subscribers: klimek, mgorny, jkorous-apple, ioeric, hintonda, cfe-commits Differential Revision: https://reviews.llvm.org/D42573 llvm-svn: 324356
* [clangd] Pass Context implicitly using TLS.Sam McCall2018-01-311-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Instead of passing Context explicitly around, we now have a thread-local Context object `Context::current()` which is an implicit argument to every function. Most manipulation of this should use the WithContextValue helper, which augments the current Context to add a single KV pair, and restores the old context on destruction. Advantages are: - less boilerplate in functions that just propagate contexts - reading most code doesn't require understanding context at all, and using context as values in fewer places still - fewer options to pass the "wrong" context when it changes within a scope (e.g. when using Span) - contexts pass through interfaces we can't modify, such as VFS - propagating contexts across threads was slightly tricky (e.g. copy vs move, no move-init in lambdas), and is now encapsulated in the threadpool Disadvantages are all the usual TLS stuff - hidden magic, and potential for higher memory usage on threads that don't use the context. (In practice, it's just one pointer) Reviewers: ilya-biryukov Subscribers: klimek, jkorous-apple, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D42517 llvm-svn: 323872
* [clangd] Refactored threading in ClangdServerIlya Biryukov2018-01-311-0/+83
Summary: We now provide an abstraction of Scheduler that abstracts threading and resource management in ClangdServer. No changes to behavior are intended with an exception of changed error messages. This patch is preliminary work to allow a revamped threading implementation that will move the threading code out of CppFile. Reviewers: sammccall, bkramer, jkorous-apple Reviewed By: sammccall Subscribers: hokein, mgorny, hintonda, ioeric, jkorous-apple, cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D42174 llvm-svn: 323851
OpenPOWER on IntegriCloud