Closed EarthenSky closed 2 months ago
Trace of 1 ADC read (before):
Trace of 8 ADC reads (optimized):
Package | Line Rate | Branch Rate | Health |
---|---|---|---|
adc | 92% | 87% | ✔ |
calibration | 100% | 100% | ✔ |
dac | 100% | 97% | ✔ |
digital_input | 100% | 91% | ✔ |
digital_output | 98% | 95% | ✔ |
eeprom | 83% | 63% | ✔ |
eeprom.protobuf_assets.eeprom_data_classes | 97% | 52% | ✔ |
eeprom.protobuf_assets.generated_pb2 | 77% | 50% | ✔ |
gpio | 98% | 94% | ✔ |
led | 0% | 0% | ❌ |
peripherals | 69% | 23% | ➖ |
pwm | 96% | 95% | ✔ |
reg_helper | 97% | 85% | ✔ |
relay | 100% | 100% | ✔ |
tc | 98% | 98% | ✔ |
utilities | 100% | 100% | ✔ |
Summary | 92% (3176 / 3457) | 80% (680 / 845) | ✔ |
Building on #423
Performance is improved by 19 times, from
105ms
per 8 ADC reads, to5.5ms
per 8 ADC reads.It's possible to improve the performance more than 160 hz for all 8 ADC, however 1/3 of all time is being spend sleeping, while another 1/3 is spent transferring data over SPI. It's unlikely to get faster than 200 hz. The speed improvements are due to bit optimizations, minimizing data sent over the channel, python optimizations, and batching of requests (minimize system calls opening & closing devices), all of which were found via profiling. For more info, see this (private) page in the wiki.
Main Changes
batch_read_samples_adc1
with minimal calling of slow functions (get_state()
is the evilest)read_command_tuple
andspi_apply_adc_commands
to efficiently read commandsTODOs