aboutsummaryrefslogtreecommitdiff
path: root/internal/lsp/debug
AgeCommit message (Collapse)Author
2020-04-27internal/event: remove the event.eventType typeIan Cottrell
Instead of tagging events with their type, instead we infer the type from the label pattern. The standard event creators all have a matching test that returns true if the the labels pattern matches the ones that would be built by the creator. Spans and logs already have a unique label pattern, other event types required a special label marker. This makes the system much more extensible, and also cleans up some the API. Change-Id: I1fbc9ec07aa84ead6c12bbd5ca65b13b605bfa4a Reviewed-on: https://go-review.googlesource.com/c/tools/+/229242 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-04-23internal/event: change event.At to be a private fieldIan Cottrell
This was the last piece of Event that was public, and it was only public to allow mutation in tests. Adding CloneEvent allows tests to create an updated copy rather than update the event in place. Change-Id: I2215d1eb0317063948ef0fac955fa768a209564d Reviewed-on: https://go-review.googlesource.com/c/tools/+/229241 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-04-23internal/event: extract keys to their own packageIan Cottrell
Now key types can be implemented outside the package that holds labels or events, they should be. This prevents the large list of types from poluting the public interface of the core packages. Change-Id: I927f31cb5e4e1d0c29619681015962f890623e5c Reviewed-on: https://go-review.googlesource.com/c/tools/+/229240 Run-TryBot: Ian Cottrell <iancottrell@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
2020-04-23internal/event: move event/core.Tag to event/label.LabelIan Cottrell
Also moves core.Key to label.Key, but leaves the implementations behind for now. After using for a while, the word Tag conveys slightly the wrong concept, tagging implies the entire set of information, label maps better to a single named piece of information. A label is just a named key/value pair, it is not really tied to the event package, separating it makes it much easier to understand the public symbols of the event and core packages, and allows us to also move the key implementations somewhere else, which otherwise dominate the API. Change-Id: I46275d531cec91e28af6ab1e74a2713505d52533 Reviewed-on: https://go-review.googlesource.com/c/tools/+/229239 Run-TryBot: Ian Cottrell <iancottrell@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-23internal/event: renaming the main event API functionsIan Cottrell
event.Log removed event.Print -> event.Log event.Record -> event.Metric event.StartSpan -> event.Start In order to support this core now exposes the MakeEvent and Export functions. Change-Id: Ic7550d88dbf400e32c419adbb61d1546c471841e Reviewed-on: https://go-review.googlesource.com/c/tools/+/229238 Reviewed-by: Robert Findley <rfindley@google.com>
2020-04-23internal/telemetry: renaming to internal/eventIan Cottrell
internal/telemetry/event was renamed to internal/event/core Some things were partly moved from internal/telemetry/event straight to internal/event to minimize churn in the following restructuring. Change-Id: I8511241c68d2d05f64c52dbe04748086dd325158 Reviewed-on: https://go-review.googlesource.com/c/tools/+/229237 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-04-08internal/lsp: make tag iteration allocation-freeIan Cottrell
Change the tag iteration api to something less flexible that allows for event iteration without allocation. Change-Id: I212d45ebceea0183d1a61e6b611e0558649be60a Reviewed-on: https://go-review.googlesource.com/c/tools/+/227301 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-04-08internal/lsp/cache: add concurrency error check for go cmdsRohan Challa
This change attempts to fix a concurrency error that would cause textDocument/CodeLens, textDocument/Formatting, textDocument/DocumentLink, and textDocument/Hover from failing on go.mod files. The issue was that the go command would return a potential concurrency error since the ModHandle and the ModTidyHandle are both using the temporary go.mod file. Updates golang/go#37824 Change-Id: I6cd63c1f75817c7308e033aec473966536a2a3bd Reviewed-on: https://go-review.googlesource.com/c/tools/+/224917 Reviewed-by: Heschi Kreinick <heschi@google.com> Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-06internal/lsp: make event directly implement TagMapIan Cottrell
Makes Event implement TagMap directly, instead of having to build an entirely new object. Change-Id: I0c1e8638de3dc3347f60fd93af3df6b7f8387751 Reviewed-on: https://go-review.googlesource.com/c/tools/+/227300 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-04-06internal/lsp: rewrite the rpc debug pageIan Cottrell
Now it only uses the telemetry messages directly rather than the metric system. This is much faster and more direct, and removes a blocker on improving the metrics support. Also fixes the fact that recieced and sent were the wrong way round before, probably as an artifact of the old protocol logging code, and also removes the bytes histogram which was a lie (it was a histogram of write sizes that was presented as a histogram of message sizes) fixes golang/go#38168 Change-Id: Ib1c3459c0ff1cf0c6087a828981e80c1ce1c5c1b Reviewed-on: https://go-review.googlesource.com/c/tools/+/227139 Run-TryBot: Ian Cottrell <iancottrell@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
2020-04-03internal/lsp, go/packages: don't log context cancellation errorsRebecca Stambler
Instead of checking the context, check the error. This may expose some errors that are not wrapped correctly. Replaced all uses of errors with golang.org/x/xerrors. Change-Id: Ia40160f8ea352e02618765f2a9415a4ece0dcd94 Reviewed-on: https://go-review.googlesource.com/c/tools/+/227036 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-31internal/lsp: rewrite the stats using the newer telemetry featuresIan Cottrell
This allows us to reduce the handler interface and delete the telemetry handler. It is also safer and faster, and can be easily disabled along with the rest of the telemetry system. Change-Id: Ia4961d7f2e374f7dc22360d6a4020a065bfeae6f Reviewed-on: https://go-review.googlesource.com/c/tools/+/225957 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-30internal/telemetry: add a synchronization to telemetryIan Cottrell
Some things that used to be safe due to the global lock now need ther own synchronization primitives. Fixes golang/go#38102 Change-Id: I03c692682d57620d96fe84b7dc74efae0d3f8f09 Reviewed-on: https://go-review.googlesource.com/c/tools/+/226317 Run-TryBot: Ian Cottrell <iancottrell@google.com> Reviewed-by: Rebecca Stambler <rstambler@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-29internal/telemetry: use tags instead of special event fields.Ian Cottrell
Change-Id: I0e6a26c62bd1f6eaa07c38a06152cb7a0f2eedc2 Reviewed-on: https://go-review.googlesource.com/c/tools/+/225579 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-26internal/telemetry: render trace tags using typed keysIan Cottrell
Type switch on the key and use it to get the value and decide how to render it. Use the same render for all debug tag printing. Change-Id: Ia305fded7dcf05b57c5805f48bb5c22fa7def71f Reviewed-on: https://go-review.googlesource.com/c/tools/+/225380 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-26internal/telemetry: make metrics take a strongly typed keyIan Cottrell
Now that keys are solidly typed, we can use them for the metrics. This prevents accidentally using the wrong type of key, and allows us to use the typed accesorrs rather than the raw value. Change-Id: I553bd8e12128d3f00a3e926dbd3bfd420cd3f135 Reviewed-on: https://go-review.googlesource.com/c/tools/+/225378 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-25internal/telemetry: replace TagSet with TagMap and TagPointerIan Cottrell
This separates the concerns of tag collections that have to be iterated and tag collections that need lookup by key. Also make it so that events just carry a plain slice of tags. We pass a TagMap down through the exporters and allow it to be extended on the way. We no longer need the event.Query method (or the event type) We now exclusivley use Key as the identity, and no longer have a common core implementation but just implement it directly in each type. This removes some confusion that was causing the same key through different paths to end up with a different identity. Change-Id: I61e47adcb397f4ca83dd90342b021dd8e9571ed3 Reviewed-on: https://go-review.googlesource.com/c/tools/+/224278 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-03-25internal/telemetry: change Exporter to be a function type.Ian Cottrell
Change-Id: Id410da20310baf4da6875de08e4449c7a6fb0250 Reviewed-on: https://go-review.googlesource.com/c/tools/+/224277 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-03-24internal/lsp: print view-specific environmentRebecca Stambler
For debugging purposes, we print the output of `go env` on start. Now, we print a view-specific `go env`, which will helps us when debugging multi-project workspaces. Additional information included: the folder of the view, if the view has a valid build configuration, and the build flags for the view. Updates golang/go#37978 Change-Id: Iadffd46f8ac5410971558a304b8bbcb2f9bdbcc3 Reviewed-on: https://go-review.googlesource.com/c/tools/+/225137 Run-TryBot: Rebecca Stambler <rstambler@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-03-23internal/telemetry: switch metrics to use the event systemIan Cottrell
Change-Id: If036530ffe47e7df925bcf6592f664d6020a3d65 Reviewed-on: https://go-review.googlesource.com/c/tools/+/223997 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-23internal/telemetry: replace event.TagList with event.TagSetIan Cottrell
This allows us to hide the implementation details of how tags are stored on a context from the normal interface, to allow us to explore more efficient mechanisms. The current storage is not intended as the most efficient choice, this cl is about isolating the API so we can experiment with benchmarks in the future. Change-Id: Ib101416bccd8ecdee269cee636b1564d51e1da8a Reviewed-on: https://go-review.googlesource.com/c/tools/+/222854 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-19internal/lsp: fix errors found by staticcheckRob Findley
While experimenting with different static analysis on x/tools, I noticed that there are many actionable diagnostics found by staticcheck. Fix the ones that were not false positives. Change-Id: I0b68cf1f636b57b557db879fad84fff9b7237a89 Reviewed-on: https://go-review.googlesource.com/c/tools/+/222248 Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-03-18internal/telemetry: add type safe tag keysIan Cottrell
This changes the way keys work, there is still a single internal key implementation for performance reasons, but the public interface is a set of key implementations that have type safe Of and Get methods. This also hides the implemenation of Tag so that we can modify the storage form and find a more efficient storage if needed. Change-Id: I6a39cc75c2824c6a92e52d59f16e82e876f16e9c Reviewed-on: https://go-review.googlesource.com/c/tools/+/223137 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-03-18internal/telemetry: delete the event.TagOf methodIan Cottrell
It encourages poor performing log lines, and also reduces the readability of those lines. Also delete the Key.With method which was unused, and should never be used instead of the event.Label function anyway. Change-Id: I9b55102864ee49a7d03e60af022a2002170c0fb1 Reviewed-on: https://go-review.googlesource.com/c/tools/+/222851 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-03-18internal/lsp: move the telemetry packageIan Cottrell
Move the lsp specific telemetry package that just declares the labels under the debug package and call it tag, to make all the usages much more readable. Change-Id: Ic89b3408dd3b8b3d914cc69d81f41b8919aaf424 Reviewed-on: https://go-review.googlesource.com/c/tools/+/222850 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-03-18internal/telemetry: allow ProcessEvent to modify the eventIan Cottrell
This allows early exporters to adjust the event for later ones. This is used to lookup key values from the context if needed. Also add a Query type event which is intended to perform all event modifications but nothing else, and is used to lookup values from the context. This cleans up a weirdness where the current lookup presumes there will be an exporter with a matching mechanism. Change-Id: I835d1e0b2511553c30f94b7becfe7b7b5462c111 Reviewed-on: https://go-review.googlesource.com/c/tools/+/223657 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-03-12internal/telemetry: convert key from string to structIan Cottrell
This makes keys a pointer, which reduces the allocations during logging, and has a significant improvement in memory and cpu cost when there is no exporter. Packing a string into an interface requires a 16 byte allocation, packing a pointer does not. name old time/op new time/op delta /LogNoExporter-8 4.39µs ± 2% 3.83µs ± 2% -12.74% (p=0.000 n=18+20) /Log-8 23.5µs ± 2% 22.6µs ± 1% -4.20% (p=0.000 n=19+18) name old alloc/op new alloc/op delta /LogNoExporter-8 1.70kB ± 0% 1.38kB ± 0% -18.78% (p=0.000 n=20+20) /Log-8 4.91kB ± 0% 4.91kB ± 0% ~ (p=1.000 n=20+20) name old allocs/op new allocs/op delta /LogNoExporter-8 83.0 ± 0% 63.0 ± 0% -24.10% (p=0.000 n=20+20) /Log-8 163 ± 0% 163 ± 0% ~ (all equal) Change-Id: Iec127f1bff8d5c8f4bd0a6d9f6d8fc4b8bc740b2 Reviewed-on: https://go-review.googlesource.com/c/tools/+/222599 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-12internal/lsp: migrate telemetry to using the event packageIan Cottrell
Change-Id: Idc662385ed08bd62593ccd1d54afd3fa8c1a7d29 Reviewed-on: https://go-review.googlesource.com/c/tools/+/222558 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-09internal/lsp: bring generated protocol code up to date; stop corrupting logsPeter Weinberger
1. logging at debug/rpc.go:105 was corrupting logs. 2. DocumentSymbol (a Server method) now returns []interface{}. 3. The latest version of the LSP changed CompletionItem.TextEdit to possibly be of the new type InsertReplaceEdit, so the generated Go code now has TextEdit an interface{} rather than a *TextEdit. This required a change to tests/util.go. 4. The latest version also introduced several other new types, and new members in some structs. Tests pass and the I've use the new gopls a little. Change-Id: Ic44d46f0c923882c9076c2754c1c85e09fbcaa2e Reviewed-on: https://go-review.googlesource.com/c/tools/+/222668 Run-TryBot: Peter Weinberger <pjw@google.com> Reviewed-by: Rebecca Stambler <rstambler@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-06internal/lsp/debug: guard rpc stats with a MutexRob Findley
This type was previously guarded implicitly by the global exporter mutex. With that gone, we've started seeing panics due to races in (*rpcs).Metric. Guard it with a mutex. Change-Id: I2a8c670ecfbaee9422e1f1d282b1fedb86b6a5e0 Reviewed-on: https://go-review.googlesource.com/c/tools/+/222300 Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Cottrell <iancottrell@google.com>
2020-03-05internal/lsp: use standardised events for taggingIan Cottrell
This means that tags also become cheap if there is no exporter and cleans up the mess with how spans, tags and logs were related. Also fixes the currently broken metrics that relied on the span tags. Change-Id: I8e56b6218a60fd31a1f6c8d329dbb2cab1b9254d Reviewed-on: https://go-review.googlesource.com/c/tools/+/222065 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-04internal/telemetry: change tracing to be event basedIan Cottrell
We no longer use the span as the core type of tracing, instead that is an artifact of the exporter, and start and end tracing is just event based. This both makes the interface normalized, and also means the null exporter case is considerably cheaper in memory and cpu. See below for benchstat changes name old time/op new time/op delta TracingNoExporter-8 4.19µs ±12% 2.71µs ±11% -35.33% (p=0.000 n=20+20) Tracing-8 24.1µs ± 3% 5.1µs ±17% -78.66% (p=0.000 n=16+20) name old alloc/op new alloc/op delta TracingNoExporter-8 2.32kB ± 0% 0.40kB ± 0% -82.76% (p=0.000 n=20+20) Tracing-8 6.32kB ± 0% 2.32kB ± 0% -63.30% (p=0.000 n=20+20) name old allocs/op new allocs/op delta TracingNoExporter-8 35.0 ± 0% 15.0 ± 0% -57.14% (p=0.000 n=20+20) Tracing-8 215 ± 0% 35 ± 0% -83.72% (p=0.000 n=20+20) Change-Id: I3cf25871fa49584819504b5c19aa580e5dd03395 Reviewed-on: https://go-review.googlesource.com/c/tools/+/221740 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-03-03internal/telemetry: moving towards a unified event based exporterIan Cottrell
This adds a type to events and makes the logging calls use it. Change-Id: Iaa50fe2e332caae611b1e00424c878a3bc479feb Reviewed-on: https://go-review.googlesource.com/c/tools/+/221741 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-03-03internal/telemetry: use atomics to get the exporterIan Cottrell
We change the main exporter to be stored and fetched using atomics rather than aquiring a mutex for a mild (but significant in the disabled case) speedup. Also has the benefit of not holding a global lock over all telemetry operations. benchstat of logging benchmatks before and after: name old time/op new time/op delta Baseline-8 329ns ± 2% 327ns ± 2% ~ (p=0.181 n=19+17) LoggingNoExporter-8 3.08µs ± 3% 2.42µs ± 2% -21.42% (p=0.000 n=20+19) Logging-8 13.7µs ± 2% 13.2µs ± 1% -3.49% (p=0.000 n=19+19) LoggingStdlib-8 5.39µs ± 3% 5.41µs ± 2% ~ (p=0.177 n=19+20) This is a replacement for https://go-review.googlesource.com/c/tools/+/212244 but built on the single exporter principle rather than the exporter list. Change-Id: Icc99319c4357e0bcb63386c64372a733e8a76796 Reviewed-on: https://go-review.googlesource.com/c/tools/+/221218 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-03-03internal/lsp: move the debug.Instance onto the ContextIan Cottrell
This allows us to register a telemetry exporter that works with mulitple active debug instances. It also means we don't have to store the debug information in our other objects. Change-Id: I9a9d5b0407c3352b6eaff80fb2c434ca33f4e397 Reviewed-on: https://go-review.googlesource.com/c/tools/+/221558 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-02internal/lsp/debug: add nil checks in debug pagePontus Leitzler
There are missing nil checks in a few places when using the gopls debug page. It will result in panics when trying to access a debug page that no longer exist (for example a closed session). This change adds nil checks and updates the template to not render non-existing debug address. Change-Id: Ic9163f3727fd8c51122cbd4ab4374fc4d55477c3 Reviewed-on: https://go-review.googlesource.com/c/tools/+/221699 Reviewed-by: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-02-28internal/telemetry: remove Flush method from exporterIan Cottrell
It is never invoked anyway, and it provices no useful benefit while complicating the implementation, as it is the only non context aware method. Change-Id: Id5a99439fedafdf4d71285e36103b4854cf3635a Reviewed-on: https://go-review.googlesource.com/c/tools/+/221540 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-02-26internal/telemetry: removing the concept of exporter listsIan Cottrell
Instead we only have a single exporter, and it must delegate behaviour to any other exporters it wants to include. This removes a whole collection of suprises caused by init functions adding new exporters to a list, as well as generally making things faster, at the small expense of needing to implement a custom exporter if you want to combine the features of a few other exporters. This is essentially the opposite of https://go-review.googlesource.com/c/tools/+/212243 which will now be abandoned in favor of this approach. Change-Id: Icacb4c1f0f40f99ddd1d82c73d4f25a3486e56ce Reviewed-on: https://go-review.googlesource.com/c/tools/+/220857 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Robert Findley <rfindley@google.com>
2020-02-24internal/lsp/lsprpc: automatically resolve and start the remote goplsRob Findley
Most users will not want to manage their own gopls instance, but may still want to benefit from using a shared instance. This CL adds support for an 'auto' network type that can be encoded in the -remote flag similarly to UDS (i.e. -remote="auto;uniqueid"). In this mode, the actual remote address will be resolved automatically based on the executing environment and unique identifier, and the remote server will be started if it isn't already running. Updates golang/go#34111 Change-Id: Ib62159765a108f3645f57709b8ff079b39dd6727 Reviewed-on: https://go-review.googlesource.com/c/tools/+/220137 Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-02-24internal/lsp/lsprpc: add a handshake between forwarder and remoteRob Findley
In the ideal future, users will have one or more gopls instances, each serving potentially many LSP clients. In order to have any hope of navigating this web, clients and servers must know about eachother. To allow for such an exchange of information, this CL adds an additional handler layer to the serving configured in the lsprpc package. For now, forwarders just use this layer to execute a handshake with the LSP server, communicating the location of their logs and debug addresses. Updates golang/go#34111 Change-Id: Ic7432062c01a8bbd52fb4a058a95bbf5dc26baa3 Reviewed-on: https://go-review.googlesource.com/c/tools/+/220081 Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-02-24internal/lsp/debug: move all debug state onto the InstanceRob Findley
For testability, and to support the exchange of debug information across Forwarder and server, it is helpful to encapsulate all debug information on the instance object. This CL moves all state in the debug package into a new 'State' type, that is added as a field on the debug.Instance. While doing so, common functionality for object collections is factored out into the objset helper type. Also add two new debug object types: Client and Server. These aren't yet used, but will be in a later CL (and frankly it was easier to leave them in this CL than to more carefully rewrite history...). Updates golang/go#34111 Change-Id: Ib809cd14cb957b41a9bcbd94a991f804531a76ea Reviewed-on: https://go-review.googlesource.com/c/tools/+/220078 Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-02-19internal/lsp: clear diagnostics for deleted filesRebecca Stambler
Diagnostics should be cleared for files which are (1) deleted on disk and not open in the editor, and (2) closed and only open in the editor. Enable the corresponding regression test, and fix a few issues raised by staticcheck. Fixes golang/go#37049 Change-Id: Iff736a7f6c3eaacda4237c2e4cf7926e9949dece Reviewed-on: https://go-review.googlesource.com/c/tools/+/220079 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-02-18internal/lsp/debug: drop memory debug threshold to 1GiBHeschi Kreinick
Most people do not have giant 64-GiB workstations, so 10GiB of RAM (5 active heap, 5 inactive for GOGC=100) is a really high threshold. Drop to 1GiB active to drop profiles. Change-Id: If0ae418828377a648a93322e269f4610fd64ebb3 Reviewed-on: https://go-review.googlesource.com/c/tools/+/219937 Run-TryBot: Heschi Kreinick <heschi@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-02-11internal/lsp/debug: fix early closure of logfileRob Findley
As of https://golang.org/cl/218457, logs are not being captured because the logfile is prematurely closed due to the scope of the deferred closure changing. Change-Id: I1754e5555025c7b2a5da58f621184d6740fd03cb Reviewed-on: https://go-review.googlesource.com/c/tools/+/219080 Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-02-10internal/lsp/debug: write debug info for large goplsesHeschi Kreinick
We've had various reports of high memory usage in gopls. Catching it in the act can be difficult, so check every second and write relevant profiles to os.TempDir every time the heap reaches a new watermark. Note that the logging in this package is broken. I didn't fix it, so nobody will know this is happening until we tell them. So it goes. Change-Id: I972d7ccfe5308658f86dde717465f0e0151b396d Reviewed-on: https://go-review.googlesource.com/c/tools/+/218858 Run-TryBot: Heschi Kreinick <heschi@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-02-10internal/lsp: move all debugging support to the debug packageIan Cottrell
We now carry around a debug instance in the app, and it manages the log file and all telemetry Change-Id: If4a51a36c38ef301b1b2bbda8e4c0a8d9bfc3c04 Reviewed-on: https://go-review.googlesource.com/c/tools/+/218457 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-02-07internal/lsp: change debug instance to a structIan Cottrell
We now build an instance and invoke methods on it. This is a step towards removing some global state, allowing multiple instances in one process and cleaning up some telemetry handling. Change-Id: I067469fed39c96653fffe96945c79193e86458d8 Reviewed-on: https://go-review.googlesource.com/c/tools/+/218157 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-02-03internal/lsp/debug: serve cache entry countsHeschi Kreinick
We seem to be leaking cache entries. A simple status page will help us confirm that. Change-Id: I485bfff6ebfb5d30655554487583e15a3f49f9a4 Reviewed-on: https://go-review.googlesource.com/c/tools/+/217597 Run-TryBot: Heschi Kreinick <heschi@google.com> Reviewed-by: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-01-31internal/lsp/debug: support dropping sessions and viewsRob Findley
These functions were unimplemented. Change-Id: Ie95ee4e99511e1e00689eefe6d97df0780b72d2f Reviewed-on: https://go-review.googlesource.com/c/tools/+/217090 Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-15internal/lsp: add server instance to debug infoRob Findley
When debugging multiple instances of gopls simultaneously, it is useful to be able to inspect stateful debugging information for each server instance, such as the location of logfiles and server startup information. This CL adds an additional section to the /info http handler, that formats additional information related to the gopls instance handling the request. Updates golang/go#34111 Change-Id: I6cb8073800ce52b0645f1898461a19e1ac980d2b Reviewed-on: https://go-review.googlesource.com/c/tools/+/214803 Reviewed-by: Rebecca Stambler <rstambler@golang.org> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>