[PATCH] D51154: [clangd] Log memory usage of DexIndex and MemIndex

2018-08-24 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rL340601: [clangd] Log memory usage of DexIndex and MemIndex (authored by omtcyfz, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D51154?vs=1623

[PATCH] D51154: [clangd] Log memory usage of DexIndex and MemIndex

2018-08-24 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment. In https://reviews.llvm.org/D51154#1211376, @ioeric wrote: > Do we plan to expose an API in `ClangdServer` to allow C++ API users to track > index memory usages? I think we do, IIUC the conclusion of the offline discussion was that it might be useful for the clients.

[PATCH] D51154: [clangd] Log memory usage of DexIndex and MemIndex

2018-08-24 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 162334. kbobyrev marked 3 inline comments as done. kbobyrev added a comment. Address few concerns. https://reviews.llvm.org/D51154 Files: clang-tools-extra/clangd/index/FileIndex.cpp clang-tools-extra/clangd/index/FileIndex.h clang-tools-extra/clangd

[PATCH] D51154: [clangd] Log memory usage of DexIndex and MemIndex

2018-08-24 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision. sammccall added inline comments. This revision is now accepted and ready to land. Comment at: clang-tools-extra/clangd/index/FileIndex.cpp:123 + size_t Bytes = Index.estimateMemoryUsage(); + for (const auto &Scheme : URISchemes) { +// std::

[PATCH] D51154: [clangd] Log memory usage of DexIndex and MemIndex

2018-08-23 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment. Do we plan to expose an API in `ClangdServer` to allow C++ API users to track index memory usages? Comment at: clang-tools-extra/clangd/index/FileIndex.cpp:123 + size_t Bytes = Index.estimateMemoryUsage(); + for (const auto &Scheme : URISchemes) { +

[PATCH] D51154: [clangd] Log memory usage of DexIndex and MemIndex

2018-08-23 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 162184. kbobyrev marked 2 inline comments as done. kbobyrev added a comment. Slightly simplify the code. https://reviews.llvm.org/D51154 Files: clang-tools-extra/clangd/index/FileIndex.cpp clang-tools-extra/clangd/index/FileIndex.h clang-tools-extra/

[PATCH] D51154: [clangd] Log memory usage of DexIndex and MemIndex

2018-08-23 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment. Some drive-by NITS. Comment at: clang-tools-extra/clangd/index/MemIndex.cpp:109 +std::lock_guard Lock(Mutex); + +Bytes += Index.getMemorySize(); Why not simply `return Index.getMemorySize()` under a lock? ===

[PATCH] D51154: [clangd] Log memory usage of DexIndex and MemIndex

2018-08-23 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments. Comment at: clang-tools-extra/clangd/index/dex/DexIndex.cpp:180 + Bytes += SymbolQuality.size() * sizeof(std::pair); + Bytes += InvertedIndex.size() * sizeof(Token); + { sammccall wrote: > I think you're not counting the size of

[PATCH] D51154: [clangd] Log memory usage of DexIndex and MemIndex

2018-08-23 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 162146. kbobyrev marked 6 inline comments as done. kbobyrev added a comment. Address a bunch of comments. https://reviews.llvm.org/D51154 Files: clang-tools-extra/clangd/index/FileIndex.cpp clang-tools-extra/clangd/index/FileIndex.h clang-tools-extra

[PATCH] D51154: [clangd] Log memory usage of DexIndex and MemIndex

2018-08-23 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments. Comment at: clang-tools-extra/clangd/index/MemIndex.cpp:105 +size_t MemIndex::estimateMemoryUsage() { + size_t Bytes = Index.size() * sizeof(std::pair); + return Bytes / (1000 * 1000); access to Index needs to be guarded by mute

[PATCH] D51154: [clangd] Log memory usage of DexIndex and MemIndex

2018-08-23 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision. kbobyrev added reviewers: ioeric, ilya-biryukov, sammccall. kbobyrev added a project: clang-tools-extra. Herald added subscribers: kadircet, arphaman, jkorous, MaskRay. This patch prints information about built index size estimation to verbose logs. This is useful