Instead of always locking/unlocking a contended mutex, we now do one atomic read
in the common case, and one read + one exchange if the timer has expried.
Also use this for memory profiling which has similar/compatible requirements.
Paths
| Differential D93726
[clangd] Use atomics instead of locks to track periodic memory trimming ClosedPublic Authored by sammccall on Dec 22 2020, 12:36 PM.
Details Summary Instead of always locking/unlocking a contended mutex, we now do one atomic read Also use this for memory profiling which has similar/compatible requirements.
Diff Detail
Event TimelineHerald added subscribers: usaxena95, kadircet, jfb, arphaman. · View Herald TranscriptDec 22 2020, 12:36 PM Comment Actions LGTM Small nits:
This revision is now accepted and ready to land.Dec 22 2020, 1:12 PM Comment Actions
Oops, I originally did plan to make operator() const, but then decided it'd be clearer for the caller to make PeriodicThrottler mutable instead. (Because pretending it doesn't have state is confusing).
Done. I have to confess I often pretend memory orders other than seq_cst don't exist just to keep the cognitive load down, but this case seems clear/isolated enough. This revision was landed with ongoing or failed builds.Dec 22 2020, 1:32 PM Closed by commit rG3dbe471a2603: [clangd] Use atomics instead of locks to track periodic memory trimming (authored by sammccall). · Explain Why This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 313413 clang-tools-extra/clangd/ClangdLSPServer.h
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/support/Threading.h
clang-tools-extra/clangd/support/Threading.cpp
clang-tools-extra/clangd/unittests/support/ThreadingTests.cpp
|