[PATCH] D150635: [clangd] Implement end-definition-comment inlay hints
Qingyuan Zheng via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 23 23:47:20 PDT 2023
daiyousei-qz added a comment.
Yeah, makes sense. Thank you for your insight! I missed the fact that this time include AST build time.
I manually injected a time region into `inlayHints`, here's part of logs printed for scrolling "offsetToPosition" build:
I[23:36:43.055] <-- textDocument/hover(21)
I[23:36:43.057] --> reply:textDocument/hover(21) 1 ms
I[23:36:43.057] --> textDocument/clangd.fileStatus
I[23:36:44.422] <-- textDocument/inlayHint(22)
E[23:36:44.612] ++++++ Inlay hints takes 189 ms to compute
I[23:36:44.612] --> reply:textDocument/inlayHint(22) 189 ms
I[23:36:44.612] --> textDocument/clangd.fileStatus
I[23:36:44.875] <-- textDocument/inlayHint(23)
E[23:36:45.053] ++++++ Inlay hints takes 178 ms to compute
I[23:36:45.054] --> reply:textDocument/inlayHint(23) 179 ms
I[23:36:45.054] --> textDocument/clangd.fileStatus
I[23:36:45.686] <-- textDocument/inlayHint(24)
E[23:36:45.865] ++++++ Inlay hints takes 178 ms to compute
I[23:36:45.865] --> reply:textDocument/inlayHint(24) 179 ms
I[23:36:45.865] --> textDocument/clangd.fileStatus
And here's logs scrolling "sourceLocToPosition" + "lspLength":
I[23:41:04.695] <-- textDocument/inlayHint(73)
I[23:41:04.707] --> reply:textDocument/inlayHint(73) 12 ms
I[23:41:04.707] --> textDocument/clangd.fileStatus
I[23:41:04.793] <-- textDocument/inlayHint(74)
I[23:41:04.807] --> reply:textDocument/inlayHint(74) 13 ms
I[23:41:04.807] --> textDocument/clangd.fileStatus
I[23:41:04.913] <-- textDocument/inlayHint(75)
I[23:41:04.926] --> reply:textDocument/inlayHint(75) 12 ms
I[23:41:04.926] --> textDocument/clangd.fileStatus
I[23:41:05.407] <-- textDocument/inlayHint(76)
I[23:41:05.420] --> reply:textDocument/inlayHint(76) 12 ms
I[23:41:05.420] --> textDocument/clangd.fileStatus
As this is more than 10x slower, I'm holding my position that we shouldn't use `offsetToPosition` for LSP features triggered per edit/scroll. 150ms is more than noticeable.
If you want to repro on your side, replace computation of HintStart/HintEnd with the following code
Position HintStart = offsetToPosition(MainFileBuf, RBraceOffset);
Position HintEnd =
offsetToPosition(MainFileBuf, RBraceOffset + HintRangeText.size());
Btw, it's always fascinating to see how modern computer system is so fast, and in the meantime still so "underpowered" :)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150635/new/
https://reviews.llvm.org/D150635
More information about the cfe-commits
mailing list