-
Notifications
You must be signed in to change notification settings - Fork 951
Unneccesary alloc in hot path #2237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
For easier read here the source code inline package main
type MockSPI int
func (m MockSPI) Tx(w, r []byte) (err error) {
switch {
case w == nil:
print(1)
}
return err
}
func (d MockSPI) SetWindow() {
d.Tx([]uint8{1}, nil)
}
func main() {
var m MockSPI = 1
m.SetWindow()
} |
So it's just the slice header here. If we replace the slice with a pointer to an array then we're ok.
This seems like the sort of thing we ought to be able to fix. |
This is what the Go SSA looks like for
|
I've fixed this specific issue a while ago in the driver: tinygo-org/drivers#545 |
Closing since was addressed. Thanks everyone! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I noticed that there are IMO unnecessary allocations generated by the compiler in the hot path if one uses the st7789 SPI driver on rp pico .
Looks like it might slow down SPI transmission considerably.
In order to debug it, I stripped down the code to the bare minimum still showing the diagnostics.
Please use tinygo (from dev branch) and compile
If you comment the switch or the print statement this warning goes away.
main.txt
The text was updated successfully, but these errors were encountered: