The Provider extension point is designed to also be implemented by
ClangdLSPServer (to inject config-over-lsp) and likely by embedders.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang-tools-extra/clangd/ConfigProvider.h | ||
---|---|---|
59 | a fixed path |
thanks looks really cool!
clang-tools-extra/clangd/ConfigProvider.cpp | ||
---|---|---|
40 | I believe this function is going to be hot, I would suggest putting a span here to track the latencies | |
42 | i suppose doing this IO on most of our features are OK, as they tend to search for .clang-format at least (even the ancestor traversal), but I wonder whether these will also be triggered for code completion and signature help, as they currently don't do any IO (apart from preamble deserialization, and maybe one patched include file). Not a concern for this patch, but something to keep in mind when integrating with the rest. | |
58 | is this really necessary ? we are setting the cache key to old stat values anyway, so the next read shouldn't match neither the Size nor MTime. | |
68 | nit: I've found the nestedness a bit overwhelming, wdyt about putting this into a scope_exit function and using early returns above ? | |
121 | ummm, what ? is this a bug in path iterator that should be fixed rather than worked around? | |
182 | nit: I think this looks a bit ... surprising | |
clang-tools-extra/clangd/ConfigProvider.h | ||
72 | maybe also mention precedence order ? I suppose it already has the natural, the latter one will override the former behavior, but saying out explicitly wouldn't hurt. | |
74 | maybe chain instead of combine ? | |
85 | first part of this sentence doesn't say much, maybe drop it? | |
91 | doesn't seem to be implemented anywhere? I suppose it is just a convenience wrapper around Provider::fromYAMLFile, is it worth it? |
clang-tools-extra/clangd/ConfigProvider.cpp | ||
---|---|---|
40 | Tracing isn't trivially cheap: that usually involves taking a mutex, writing to a buffer, and I think flushing it to disk. So we shouldn't trace things that are both hot and small, which I think this is. I added a tracer to Provider::getConfig - OK to revisit if we need something more fine-grained? | |
42 | Yeah, this is a good point. I've added this idea to the class comment. Related: I think an abstraction like this, with some thought put into invalidation policy, should be eventually used for .clang-format, .clang-tidy, compile_commands.json, as we should be able to get fresh results with a fairly tiny amount of IO. | |
58 | I considered doing nothing here, or setting Size = Buf->size. But there are *possible* scenarios where you go back to the old state (think switching git branches) and then end up with a poisoned cache. And this is cheap (simple, and also doesn't actually cause you to miss the cache when you want to hit it) | |
68 | scope_exit is a neat idea, but when I tried it I found the code hard to reason about. I extracted a function instead. Unnesting this caused me to catch a case i'd missed: if stat succeeds but read fails (once), I'd prefer to retry the read before caching the failure forever... (again, the branch switching workflows) | |
121 | No, it's documented that Component isn't necessarily part of the path. Extended the comment a bit. | |
182 | the fact that this is Fragment instead of Fragment(P, C)? Yeah, this is an argument for adding an interface rather than using std::function. | |
clang-tools-extra/clangd/ConfigProvider.h | ||
85 | I think just saying "this function must be threadsafe" is a bit confusing because it's a const method, it's like saying "this function does not throw exceptions" in llvm code. But I shoud have made my point more explicit. Replaced with "Despite the need for caching..." | |
91 | Whoops, this was copy/pasted from a prototype. |
clang-tools-extra/clangd/ConfigProvider.cpp | ||
---|---|---|
40 | why do we want to cache failure case for missing files ? If it is truly missing and we didn't race with another process (likely git-checkout), the next stat will fail and we'll return a no-op fragment. |
Don't cache failed opens.
clang-tools-extra/clangd/ConfigProvider.cpp | ||
---|---|---|
40 | Yeah I was worried about a file we can stat but chronically can't read (e.g. because permissions are wrong). But this is probably not worth worrying about. Changed no not cache as you suggest. |
a fixed path