Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools / gopls@v0.5.2 / integration / replay / README.md
1 # Replaying Logs
2
3 The LSP log replayer takes a log from a gopls session, starts up an instance of gopls,
4 and tries to replay the session. It produces a log from the replayed session and reports
5 some comparative statistics of the two logs.
6
7 ```replay -log <logfile>```
8
9 The `logfile` should be the log produced by gopls. It will have a name like
10 `/tmp/gopls-89775` or, on a Mac, `$TMPDIR/gopls-29388`.
11
12 If `replay` cannot find a copy of gopls to execute, use `-cmd <path to gopls>`.
13 It looks in the same places where `go install` would put its output,
14 namely `$GOBIN/gopls`, `$GOPATH/bin/gopls`, `$HOME/go/bin/gopls`.
15
16 The log for the replayed session is saved in `/tmp/seen`.
17
18 There is also a boolean argument `-cmp` which compares the log file
19 with `/tmp/seen` without invoking gopls and rerunning the session.
20
21 The output is fairly cryptic, and generated by logging. Ideas for better output would be welcome.
22 Here's an example, with intermingled comments:
23
24 ```
25 main.go:50: old 1856, hist:[10:177 30:1 100:0 300:3 1000:4 ]
26 ```
27 This says that the original log had 1856 records in it. The histogram is
28 counting how long RPCs took, in milliseconds. In this case 177 took no more
29 than 10ms, and 4 took between 300ms and 1000ms.
30 ```
31 main.go:53: calling mimic
32 main.go:293: mimic 1856
33 ```
34 This is a reminder that it's replaying in a new session, with a log file
35 containing 1856 records
36 ```
37 main.go:61: new 1846, hist:[10:181 30:1 100:1 300:1 1000:1 ]
38 ```
39 The new session produced 1846 log records (that's 10 fewer),
40 and a vaguely similar histogram.
41 ```
42 main.go:96: old: clrequest:578 clresponse:185 svrequest:2 svresponse:2 toserver:244 toclient:460 reporterr:385
43 main.go:96: new: clrequest:571 clresponse:185 svrequest:2 svresponse:2 toserver:241 toclient:460 reporterr:385
44 ```
45 The first line is for the original log, the second for the new log. The new log has 7 fewer RPC requests
46 from the client *clrequest* (578 vs 571), the same number of client responses *clresponse*, 3 fewer
47 notifications *toserver* from the client, the same number from the server *toclient* to the client, and
48 the same number of errors *reporterr*. (That's mysterious, but a look at the ends of the log files shows
49 that the original session ended with several RPCs that don't show up, for whatever reason, in the new session.)
50
51 Finally, there are counts of the various notifications seen, in the new log and the old log, and
52 which direction they went. (The 3 fewer notifications in the summary above can be seen here to be from cancels
53 and a didChange.)
54 ```
55 main.go:107: counts of notifications
56 main.go:110:  '$/cancelRequest'. new toserver 1
57 main.go:110:  '$/cancelRequest'. old toserver 3
58 main.go:110:  'initialized'. new toserver 1
59 main.go:110:  'initialized'. old toserver 1
60 main.go:110:  'textDocument/didChange'. new toserver 231
61 main.go:110:  'textDocument/didChange'. old toserver 232
62 main.go:110:  'textDocument/didOpen'. new toserver 1
63 main.go:110:  'textDocument/didOpen'. old toserver 1
64 main.go:110:  'textDocument/didSave'. new toserver 7
65 main.go:110:  'textDocument/didSave'. old toserver 7
66 main.go:110:  'textDocument/publishDiagnostics'. new toclient 182
67 main.go:110:  'textDocument/publishDiagnostics'. old toclient 182
68 main.go:110:  'window/logMessage'. new toclient 278
69 main.go:110:  'window/logMessage'. old toclient 278
70 ```
71 ### Caveats
72 Replay cannot restore the exact environment gopls saw for the original session.
73 For instance, the first didOpen message in the new session will see the file
74 as it was left by the original session.
75
76 Gopls invokes various tools, and the environment they see could have changed too.
77
78 Replay will use the gopls it finds (or is given). It has no way of using
79 the same version that created the original session.