bpmct
03/19/2023, 7:53 PMsh
2023-03-19T14:50:17.591-0500 ERROR Compiler.compiler_protocol compiler/compiler_fs_protocol.go:135 read failed {"error": "io: read/write on closed pipe"}
github.com/toitware/toit.git/toitlsp/lsp/compiler.(*CompilerFSProtocol).HandleConn
/Users/runner/work/toit/toit/tools/toitlsp/lsp/compiler/compiler_fs_protocol.go:135
github.com/toitware/toit.git/toitlsp/lsp/compiler.(*PipeFileServer).handleConn
/Users/runner/work/toit/toit/tools/toitlsp/lsp/compiler/file_server_pipe.go:52
Also created an issue: https://github.com/toitware/ide-tools/issues/212floitsch
03/19/2023, 7:54 PMfloitsch
03/19/2023, 7:56 PMfloitsch
03/19/2023, 7:56 PMfloitsch
03/19/2023, 7:56 PMbpmct
03/19/2023, 7:56 PMbpmct
03/19/2023, 7:57 PMbpmct
03/19/2023, 7:58 PMbpmct
03/19/2023, 7:59 PMfloitsch
03/19/2023, 8:00 PMbpmct
03/19/2023, 8:02 PMjag monitor / jag watch
) it got slowbpmct
03/19/2023, 8:02 PMfloitsch
03/19/2023, 8:02 PMif error != null
).floitsch
03/19/2023, 8:04 PMdelve
installed (Go's debugger).bpmct
03/19/2023, 8:04 PMfloitsch
03/19/2023, 8:04 PMdlv attach pid
you might be able to see which function it is continuously calling, and why it doesn't stop.floitsch
03/19/2023, 8:04 PMbpmct
03/19/2023, 8:05 PMtoit.lsp
?floitsch
03/19/2023, 8:05 PMbpmct
03/19/2023, 8:05 PMbpmct
03/19/2023, 8:10 PMsh
➜ bin dlv attach 61015
Type 'help' for list of commands.
(dlv)
floitsch
03/19/2023, 8:11 PMfloitsch
03/19/2023, 8:11 PMthreads
?bpmct
03/19/2023, 8:12 PMThread 3792956 at :0
Thread 3792960 at :0
* Thread 3792961 at 0x108d200 /Users/runner/hostedtoolcache/go/1.17.13/x64/src/sort/search.go:83 sort.SearchInts
Thread 3792962 at :0
Thread 3792963 at :0
Thread 3792994 at 0x1014830 /Users/runner/hostedtoolcache/go/1.17.13/x64/src/runtime/mbitmap.go:947 runtime.heapBitsSetType
Thread 3793039 at 0x1093ed1 /Users/runner/hostedtoolcache/go/1.17.13/x64/src/internal/poll/fd_mutex.go:186 internal/poll.(*fdMutex).rwunlock
Thread 3793044 at :0
Thread 3793045 at :0
Thread 3793046 at :0
Thread 3793047 at :0
Thread 3793048 at 0x105f0e8 /Users/runner/hostedtoolcache/go/1.17.13/x64/src/runtime/netpoll.go:284 internal/poll.runtime_pollReset
Thread 3793087 at :0
Thread 3793088 at 0x1109fed /Users/runner/hostedtoolcache/go/1.17.13/x64/src/bufio/bufio.go:105 bufio.(*Reader).fill
Thread 3793118 at :0
Thread 3793645 at :0
Thread 3793646 at 0x100c86b /Users/runner/hostedtoolcache/go/1.17.13/x64/src/runtime/malloc.go:858 runtime.mallocgc
Thread 3793647 at :0
Thread 3793648 at 0x10644be /Users/runner/hostedtoolcache/go/1.17.13/x64/src/runtime/asm_amd64.s:772 runtime.asmcgocall
Thread 3793649 at :0
Thread 3793651 at :0
Thread 3793652 at :0
Thread 3796699 at :0
Thread 3797876 at 0x1045f2e /Users/runner/hostedtoolcache/go/1.17.13/x64/src/runtime/select.go:310 runtime.selectgo
Thread 3798078 at :0
Thread 3798079 at 0x10368df /Users/runner/hostedtoolcache/go/1.17.13/x64/src/runtime/proc.go:410 runtime.acquireSudog
Thread 3798080 at :0
Thread 3798081 at :0
floitsch
03/19/2023, 8:13 PMfloitsch
03/19/2023, 8:15 PMgoroutines
list all goroutines.floitsch
03/19/2023, 8:15 PMgoroutine X
allows to switch to a goroutine.floitsch
03/19/2023, 8:15 PMlist
shows the source it's currently executing.floitsch
03/19/2023, 8:16 PMbt
prints a backtrace of the current goroutine.bpmct
03/19/2023, 8:18 PMsh
(dlv) list
> sort.SearchInts() /Users/runner/hostedtoolcache/go/1.17.13/x64/src/sort/search.go:83 (PC: 0x108d200)
Warning: debugging optimized function
Command failed: open /Users/runner/hostedtoolcache/go/1.17.13/x64/src/sort/search.go: no such file or directory
floitsch
03/19/2023, 8:19 PMfloitsch
03/19/2023, 8:19 PMup
floitsch
03/19/2023, 8:19 PMfloitsch
03/19/2023, 8:19 PMbt
backtrace could already help.bpmct
03/19/2023, 8:19 PMsh
(dlv) goroutine 2636
Switched from 2636 to 2636 (thread 3792961)
(dlv) bt
0 0x000000000108d200 in sort.SearchInts
at /Users/runner/hostedtoolcache/go/1.17.13/x64/src/sort/search.go:83
1 0x00000000012a6119 in github.com/toitware/toit.git/toitlsp/lsp/toit.FindLastGreaterThanIdx
at /Users/runner/work/toit/toit/tools/toitlsp/lsp/toit/summary.go:544
2 0x00000000012aaa0d in github.com/toitware/toit.git/toitlsp/lsp/toit/text.(*summaryReader).topLevelReferenceFromGlobalID
at /Users/runner/work/toit/toit/tools/toitlsp/lsp/toit/text/parser.go:776
3 0x00000000012a91b3 in github.com/toitware/toit.git/toitlsp/lsp/toit/text.(*summaryReader).readType
at /Users/runner/work/toit/toit/tools/toitlsp/lsp/toit/text/parser.go:430
4 0x00000000012a8b6a in github.com/toitware/toit.git/toitlsp/lsp/toit/text.(*summaryReader).readMethod
at /Users/runner/work/toit/toit/tools/toitlsp/lsp/toit/text/parser.go:359
5 0x00000000012a8325 in github.com/toitware/toit.git/toitlsp/lsp/toit/text.(*summaryReader).readFunctions
at /Users/runner/work/toit/toit/tools/toitlsp/lsp/toit/text/parser.go:257
6 0x00000000012a785b in github.com/toitware/toit.git/toitlsp/lsp/toit/text.(*summaryReader).readModule
at /Users/runner/work/toit/toit/tools/toitlsp/lsp/toit/text/parser.go:121
7 0x00000000012a7545 in github.com/toitware/toit.git/toitlsp/lsp/toit/text.(*summaryReader).Read
at /Users/runner/work/toit/toit/tools/toitlsp/lsp/toit/text/parser.go:82
8 0x00000000012a728c in github.com/toitware/toit.git/toitlsp/lsp/toit/text.ParseSummary
at /Users/runner/work/toit/toit/tools/toitlsp/lsp/toit/text/parser.go:49
9 0x00000000012b3ca7 in github.com/toitware/toit.git/toitlsp/lsp/compiler.(*parser).AnalyzeOutput
at /Users/runner/work/toit/toit/tools/toitlsp/lsp/compiler/parser.go:69
10 0x00000000012ac1da in github.com/toitware/toit.git/toitlsp/lsp/compiler.(*Compiler).Analyze.func1
at /Users/runner/work/toit/toit/tools/toitlsp/lsp/compiler/compiler.go:136
11 0x00000000012ae903 in github.com/toitware/toit.git/toitlsp/lsp/compiler.(*Compiler).run.func1
at /Users/runner/work/toit/toit/tools/toitlsp/lsp/compiler/compiler.go:336
12 0x0000000001064661 in runtime.goexit
at /Users/runner/hostedtoolcache/go/1.17.13/x64/src/runtime/asm_amd64.s:1581
bpmct
03/19/2023, 8:20 PM> sort.SearchInts() /Users/runner/hostedtoolcache/go/1.17.13/x64/src/sort/search.go:83 (PC: 0x108d200)
Warning: debugging optimized function
Frame 1: /Users/runner/work/toit/toit/tools/toitlsp/lsp/toit/summary.go:544 (PC: 12a6119)
(dlv) up
> sort.SearchInts() /Users/runner/hostedtoolcache/go/1.17.13/x64/src/sort/search.go:83 (PC: 0x108d200)
Warning: debugging optimized function
Frame 2: /Users/runner/work/toit/toit/tools/toitlsp/lsp/toit/text/parser.go:776 (PC: 12aaa0d)
(dlv) up
> sort.SearchInts() /Users/runner/hostedtoolcache/go/1.17.13/x64/src/sort/search.go:83 (PC: 0x108d200)
Warning: debugging optimized function
Frame 3: /Users/runner/work/toit/toit/tools/toitlsp/lsp/toit/text/parser.go:430 (PC: 12a91b3)
(dlv) up
> sort.SearchInts() /Users/runner/hostedtoolcache/go/1.17.13/x64/src/sort/search.go:83 (PC: 0x108d200)
Warning: debugging optimized function
Frame 4: /Users/runner/work/toit/toit/tools/toitlsp/lsp/toit/text/parser.go:359 (PC: 12a8b6a)
(dlv) up
> sort.SearchInts() /Users/runner/hostedtoolcache/go/1.17.13/x64/src/sort/search.go:83 (PC: 0x108d200)
Warning: debugging optimized function
Frame 5: /Users/runner/work/toit/toit/tools/toitlsp/lsp/toit/text/parser.go:257 (PC: 12a8325)
(dlv) up
> sort.SearchInts() /Users/runner/hostedtoolcache/go/1.17.13/x64/src/sort/search.go:83 (PC: 0x108d200)
Warning: debugging optimized function
Frame 6: /Users/runner/work/toit/toit/tools/toitlsp/lsp/toit/text/parser.go:121 (PC: 12a785b)
floitsch
03/19/2023, 8:20 PMfloitsch
03/19/2023, 8:21 PMcontinue
) and wait a bit.floitsch
03/19/2023, 8:21 PMctrl-c
to go back into delve and see if the backtrace changed.bpmct
03/19/2023, 8:23 PMsh
received SIGINT, stopping process (will not forward signal)
Stopped at: 0x7ff80872911a
=> 1: no source available
(dlv) bt
0 0x00007ff80872911a in ???
at ?:-1
1 0x0000000001066490 in runtime.pthread_cond_wait_trampoline
at /Users/runner/hostedtoolcache/go/1.17.13/x64/src/runtime/sys_darwin_amd64.s:535
2 0x00000000010644ed in runtime.asmcgocall
at /Users/runner/hostedtoolcache/go/1.17.13/x64/src/runtime/asm_amd64.s:795
3 0x0000000000000000 in ???
at ?:-1
4 0x0000000001052c34 in runtime.pthread_cond_wait
at /Users/runner/hostedtoolcache/go/1.17.13/x64/src/runtime/sys_darwin.go:444
5 0x000000000102fdad in runtime.semasleep
at /Users/runner/hostedtoolcache/go/1.17.13/x64/src/runtime/os_darwin.go:66
6 0x000000000100b2e5 in runtime.notesleep
at /Users/runner/hostedtoolcache/go/1.17.13/x64/src/runtime/lock_sema.go:182
7 0x000000000103904a in runtime.mPark
at /Users/runner/hostedtoolcache/go/1.17.13/x64/src/runtime/proc.go:1441
8 0x000000000103a558 in runtime.stopm
at /Users/runner/hostedtoolcache/go/1.17.13/x64/src/runtime/proc.go:2408
9 0x000000000103e6d6 in runtime.exitsyscall0
at /Users/runner/hostedtoolcache/go/1.17.13/x64/src/runtime/proc.go:4115
10 0x0000000001062543 in runtime.mcall
at /Users/runner/hostedtoolcache/go/1.17.13/x64/src/runtime/asm_amd64.s:307
floitsch
03/19/2023, 8:23 PMbpmct
03/19/2023, 8:25 PMsh
Sending output to pager...
(dlv) list
Stopped at: 0x7ff80872911a
=> 1: no source available
bpmct
03/19/2023, 8:25 PMfloitsch
03/19/2023, 8:25 PMfloitsch
03/19/2023, 8:25 PMgoroutines
you should see a list of all goroutines.floitsch
03/19/2023, 8:26 PMkasperl
03/19/2023, 8:26 PMfloitsch
03/19/2023, 8:26 PMkasperl
03/19/2023, 8:27 PMbpmct
03/19/2023, 8:28 PMbpmct
03/19/2023, 8:29 PMtmate
/ssh access to my machine tomorrow if you need to debug furtherfloitsch
03/19/2023, 8:29 PMfloitsch
03/19/2023, 8:31 PMfloitsch
03/19/2023, 8:35 PMbpmct
03/19/2023, 8:35 PMfloitsch
03/19/2023, 8:36 PMkasperl
03/24/2023, 1:32 PMbpmct
03/25/2023, 6:54 PMtoit.lsp
after upgrading to Jaguar v1.19.14floitsch
03/25/2023, 6:55 PMfloitsch
03/25/2023, 6:55 PMfloitsch
03/25/2023, 6:55 PMfloitsch
03/25/2023, 6:56 PMtoitLanguageServer.command
you should have an 'edit in settings.json'.floitsch
03/25/2023, 6:56 PMfloitsch
03/25/2023, 7:00 PMtoit.lsp
with two different flags (each with a value):
- --toitc
pointing to the toit compiler.
- --cpuprofile
with a directory where the profiles can be stored. That directory must exist.
For example, for me the following would work:
[
"/home/flo/.cache/jaguar/sdk/bin/toit.lsp",
"--toitc", "/home/flo/.cache/jaguar/sdk/bin/toit.compile",
"--cpuprofile", "/home/flo/tmp/lsp-profile"
]
Use ctrl-shift-p
followed by Developer: Reload Window
to apply the changes and restart the server.floitsch
03/25/2023, 7:02 PM.prof
file stays empty until the LSP server is shut down.floitsch
03/25/2023, 7:02 PMfloitsch
03/25/2023, 7:02 PMfloitsch
03/25/2023, 7:07 PMgo tool pprof PATH_TO_TOIT_LSP PATH_TO_PROFILE_FILE
. (see https://go.dev/blog/pprof), but I hope that we can do that on our machines as well.bpmct
03/25/2023, 7:07 PMfloitsch
03/25/2023, 7:08 PMbpmct
03/25/2023, 7:08 PMfloitsch
03/25/2023, 7:08 PMbpmct
03/25/2023, 7:09 PMsh
➜ jag version
Version: v1.9.14
SDK version: v2.0.0-alpha.71
Build date: 2023-03-25T18:51:50Z
➜ toit
floitsch
03/25/2023, 7:09 PMbpmct
03/25/2023, 7:09 PMfloitsch
03/25/2023, 7:09 PMbpmct
03/25/2023, 7:09 PMfloitsch
03/25/2023, 7:09 PMfloitsch
03/25/2023, 7:10 PMbpmct
03/25/2023, 7:11 PMfloitsch
03/25/2023, 7:11 PMfloitsch
03/25/2023, 7:12 PMfloitsch
03/25/2023, 7:13 PMtoitLanguageServer.trace.server
floitsch
03/25/2023, 7:13 PMbpmct
03/25/2023, 7:15 PMfloitsch
03/25/2023, 7:23 PMfloitsch
03/25/2023, 7:23 PMbpmct
03/25/2023, 7:28 PMfloitsch
03/25/2023, 7:29 PMbpmct
03/25/2023, 7:30 PM.toit
filefloitsch
03/25/2023, 7:30 PMbpmct
03/25/2023, 7:30 PMfloitsch
03/25/2023, 7:30 PMbpmct
03/25/2023, 7:31 PMbpmct
03/25/2023, 7:36 PMbpmct
03/25/2023, 7:36 PMbpmct
03/25/2023, 7:36 PMfloitsch
03/25/2023, 7:36 PMbpmct
03/25/2023, 7:37 PMtoit
// Save as hello.toit
import uart
import gpio
import reader show BufferedReader
import writer show Writer
import net
import mqtt
import net.x509
import certificate_roots
import encoding.json
import gpio
import gpio
import gpio.adc show Adc
// Include a random number, as we are sharing test.mosquitto.org with other users.
CLIENT_ID ::= "tio-$(random)"
HOST ::= "broker.mqttdashboard.com"
PORT ::= 8000
TOPIC ::= "tio"
main:
print "Hello totto!"
port := uart.Port
--rx=gpio.Pin 1 //blue
--tx=gpio.Pin 0 //purple
--baud_rate=9600
writer := Writer port
writer.write "Hello\n\n\n\n"
network := net.open
transport := mqtt.TcpTransport network --host=HOST
client := mqtt.Client --transport=transport
client.start --client_id=CLIENT_ID
client.subscribe TOPIC:: | topic/string payload/ByteArray |
writer.write payload
writer.write "\n\n\n"
print "Hello world?"
button1 := gpio.Pin 4 --input
button1Pressed := false
// butotn1: 2
// light1: 3
// button2: 4
// light2: 5ss
output_pin := gpio.Pin 5
--output
output_pin.set 1
print "light 1"
while true:
button1.wait_for 1
print "clicked"
sleep --ms=100
// writer.write "ooo button pushed\v n\n\n\n"
// print button1.get
// // sleep --ms 100
// sleep --ms=100
// if button1.get == 1 and not button1Pressed:
// print "passed"
// button1Pressed = true
// // writer.write "button1 pushed\v n\n\n\n"
// // client.publish TOPIC:: "button1 pushed\v n\n\n\n"
floitsch
03/25/2023, 7:37 PMbpmct
03/25/2023, 7:37 PMfloitsch
03/25/2023, 7:38 PMbpmct
03/25/2023, 7:38 PMfloitsch
03/25/2023, 7:38 PMbpmct
03/25/2023, 7:38 PMbpmct
03/25/2023, 7:39 PMfloitsch
03/25/2023, 7:39 PMbpmct
03/25/2023, 7:39 PMfloitsch
03/25/2023, 7:39 PMbpmct
03/25/2023, 7:39 PMfloitsch
03/25/2023, 7:40 PMkillall toit.lsp
bpmct
03/25/2023, 7:42 PMbpmct
03/25/2023, 7:54 PMmqtt
package import leads to the spikes. Seeing if any others do.floitsch
03/25/2023, 7:55 PMfloitsch
03/25/2023, 7:55 PMbpmct
03/25/2023, 7:56 PMtoit.lsp
processes and then they'd disappear. When I uncommented the mqtt import, 9 long-running toit.lsp
processes started all with high CPU usagebpmct
03/25/2023, 7:57 PMfloitsch
03/25/2023, 7:57 PMtoit.lsp
processes, but maybe that's just the threading showing up.floitsch
03/25/2023, 7:57 PMfloitsch
03/25/2023, 7:57 PM.packages
.bpmct
03/25/2023, 7:58 PMfloitsch
03/25/2023, 7:58 PM.packages
of your project.floitsch
03/25/2023, 7:59 PM.packages
(so we can investigate if it turns out to be the problem) and rerun jag pkg install
(so it downloads all packages again)?bpmct
03/25/2023, 7:59 PMfloitsch
03/25/2023, 7:59 PMfloitsch
03/25/2023, 8:00 PMbpmct
03/25/2023, 8:01 PMbpmct
03/25/2023, 8:01 PMfloitsch
03/25/2023, 8:02 PMbpmct
03/25/2023, 8:02 PMps
or something?floitsch
03/25/2023, 8:02 PMbpmct
03/25/2023, 8:02 PMbpmct
03/25/2023, 8:02 PMfloitsch
03/25/2023, 8:02 PMbpmct
03/25/2023, 8:03 PMbpmct
03/25/2023, 8:05 PMbpmct
03/25/2023, 8:07 PMimport mqtt
)
- CPU spiked (exactly like video I sent)
- Waited 30 seconds or so
- Uninstalled VS Code extensionfloitsch
03/25/2023, 8:07 PMinitialize
calls.floitsch
03/25/2023, 8:13 PMbpmct
03/25/2023, 8:15 PMfloitsch
03/25/2023, 8:15 PMfloitsch
03/25/2023, 8:42 PMfloitsch
03/25/2023, 8:43 PMfloitsch
03/25/2023, 8:43 PMcode --install-extension toit-1.6.6.vsix
floitsch
03/25/2023, 8:45 PMinitialize
call.
For example: Starting Toit LSP server: workingDir=/home/flo/work/pkg-tar
.
Will be interesting to see which working-directories your IDE starts the LSP for.floitsch
03/25/2023, 8:47 PMbpmct
03/25/2023, 9:21 PMbpmct
03/25/2023, 9:22 PMbpmct
03/25/2023, 9:27 PMsh
jaguar/sdk/lib/crypto
jaguar/sdk/lib/system/base
jaguar/sdk/lib/system
jaguar/sdk/lib/encoding
jaguar/sdk/lib/tls
floitsch
03/25/2023, 9:29 PMfloitsch
03/25/2023, 9:29 PMfloitsch
03/25/2023, 9:30 PMfloitsch
03/25/2023, 9:36 PMfloitsch
03/25/2023, 9:37 PMfloitsch
03/25/2023, 9:37 PMfloitsch
03/25/2023, 9:37 PMfloitsch
03/25/2023, 9:38 PMbpmct
03/25/2023, 10:41 PMfloitsch
03/25/2023, 10:41 PMfloitsch
03/25/2023, 10:41 PMbpmct
03/25/2023, 10:42 PMbpmct
03/25/2023, 10:42 PMfloitsch
03/25/2023, 10:42 PMfloitsch
03/25/2023, 10:43 PMbpmct
03/25/2023, 10:43 PMfloitsch
03/25/2023, 10:44 PM