This repository was archived by the owner on Mar 2, 2026. It is now read-only.
Commit 113247b
committed
sysfs: improve SPI heap utilization and performance
- Put spiConn inside the SPI object instead of allocating it on the heap.
- Create a 4 items array of spiIOCTransfer inside the SPI object to remove
memory allocation when doing transfers of 4 items or less.
This results in dramatic improvement when using spi.Conn.Tx().
Test environment:
- go 1.10.2
- Intel(R) Xeon(R) CPU E5-2690 0 @ 2.90GHz
- Raspberry Pi 3
Intel: 60% faster
Before: BenchmarkSPI 10000000 167 ns/op 32 B/op 1 allocs/op
After: BenchmarkSPI 20000000 68.0 ns/op 0 B/op 0 allocs/op
RPi3: 37% faster
Before: BenchmarkSPI 1000000 1795 ns/op 32 B/op 1 allocs/op
After: BenchmarkSPI 1000000 1125 ns/op 0 B/op 0 allocs/op1 parent a07da60 commit 113247b
1 file changed
+15
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
70 | 73 | | |
71 | 74 | | |
72 | 75 | | |
| |||
137 | 140 | | |
138 | 141 | | |
139 | 142 | | |
140 | | - | |
| 143 | + | |
| 144 | + | |
141 | 145 | | |
142 | 146 | | |
143 | 147 | | |
| |||
218 | 222 | | |
219 | 223 | | |
220 | 224 | | |
221 | | - | |
222 | | - | |
223 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
224 | 229 | | |
225 | 230 | | |
226 | 231 | | |
| |||
267 | 272 | | |
268 | 273 | | |
269 | 274 | | |
270 | | - | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
271 | 281 | | |
272 | 282 | | |
273 | 283 | | |
| |||
0 commit comments