Skip to content
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

[nrfconnect] Optimized application main loop wake up interval #10644

Merged

Conversation

kkasperczyk-no
Copy link
Contributor

@kkasperczyk-no kkasperczyk-no commented Oct 19, 2021

Problem

Application wakes up MCU every 10 ms to update LEDs state and handle events even if it's not necessary.

Change overview

  • Moved updating BLE connection and Thread state from main loop to Matter event handler
  • Moved updating LED state from main loop to event handler
  • Refactored LEDWidget module to use timer and change LEDs state on timer expiration.
  • By the way spotted and removed unused lighting-app/nrfconnect/child_image/mcuboot.conf file

Testing

Tested manually on nrfconnect platform that application functional behavior despite main loop optimization didn't change

@github-actions
Copy link

github-actions bot commented Oct 19, 2021

PR #10644: Size comparison from 1623b4b to 58c6c67

8 builds (for k32w, p6, qpg, telink)
platform target config section 1623b4b 58c6c67 change % change
k32w lock-app k32w061+debug .bss 69052 69052 0 0.0
.data 1864 1864 0 0.0
.text 515520 515520 0 0.0
shell k32w061+debug .bss 55080 55080 0 0.0
.data 672 672 0 0.0
.text 357332 357332 0 0.0
lighting-app k32w061+se05x+release .bss 78576 78576 0 0.0
.data 1900 1900 0 0.0
.text 614304 614304 0 0.0
p6 lock-app default .bss 68216 68216 0 0.0
.data 2416 2416 0 0.0
.heap 962712 962712 0 0.0
.text 1126624 1126624 0 0.0
qpg lighting-app qpg6100+debug .bss 53552 53552 0 0.0
.data 996 996 0 0.0
.text 486616 486616 0 0.0
lock-app qpg6100+debug .bss 52488 52488 0 0.0
.data 952 952 0 0.0
.text 462684 462684 0 0.0
persistent-storage-app qpg6100+debug .bss 17778 17778 0 0.0
.data 280 280 0 0.0
.text 102704 102704 0 0.0
telink lighting-app tlsr9518adk80d bss 71000 71000 0 0.0
noinit 33216 33216 0 0.0
text 458304 458304 0 0.0
14 builds (for efr32, linux, mbed)
platform target config section 1623b4b 58c6c67 change % change
efr32 lighting-app BRD4161A .bss 118036 118036 0 0.0
.data 1800 1800 0 0.0
.text 782944 782944 0 0.0
lock-app BRD4161A .bss 115892 115892 0 0.0
.data 1760 1760 0 0.0
.text 762088 762088 0 0.0
window-app BRD4161A .bss 116212 116212 0 0.0
.data 1764 1764 0 0.0
.text 763012 763012 0 0.0
lighting-app BRD4161A+rpc .bss 131364 131364 0 0.0
.data 1852 1852 0 0.0
.text 762700 762700 0 0.0
linux all-clusters-app debug .bss 52176 52176 0 0.0
.data 978 978 0 0.0
.data.rel.ro 58688 58688 0 0.0
.dynamic 592 592 0 0.0
.got 4072 4072 0 0.0
.init 27 27 0 0.0
.init_array 512 512 0 0.0
.rodata 136373 136373 0 0.0
.text 1345186 1345186 0 0.0
chip-tool debug .bss 17552 17552 0 0.0
.data 1584 1584 0 0.0
.data.rel.ro 86192 86192 0 0.0
.dynamic 592 592 0 0.0
.got 4344 4344 0 0.0
.init 27 27 0 0.0
.init_array 416 416 0 0.0
.rodata 178892 178892 0 0.0
.text 2859941 2859941 0 0.0
ota-provider-app debug .bss 37472 37472 0 0.0
.data 752 752 0 0.0
.data.rel.ro 23176 23176 0 0.0
.dynamic 592 592 0 0.0
.got 4008 4008 0 0.0
.init 27 27 0 0.0
.init_array 440 440 0 0.0
.rodata 110056 110056 0 0.0
.text 1010594 1010594 0 0.0
ota-requestor-app debug .bss 205728 205728 0 0.0
.data 752 752 0 0.0
.data.rel.ro 24488 24488 0 0.0
.dynamic 592 592 0 0.0
.got 4136 4136 0 0.0
.init 27 27 0 0.0
.init_array 512 512 0 0.0
.rodata 128744 128744 0 0.0
.text 1130130 1130130 0 0.0
shell debug .bss 16072 16072 0 0.0
.data 242 242 0 0.0
.data.rel.ro 35120 35120 0 0.0
.dynamic 592 592 0 0.0
.got 3496 3496 0 0.0
.init 27 27 0 0.0
.init_array 336 336 0 0.0
.rodata 71855 71855 0 0.0
.text 569858 569858 0 0.0
tv-app debug .bss 216400 216400 0 0.0
.data 2032 2032 0 0.0
.data.rel.ro 55872 55872 0 0.0
.dynamic 592 592 0 0.0
.got 4400 4400 0 0.0
.init 27 27 0 0.0
.init_array 608 608 0 0.0
.rodata 152264 152264 0 0.0
.text 1464706 1464706 0 0.0
bridge-app debug+rpc .bss 52912 52912 0 0.0
.data 976 976 0 0.0
.data.rel.ro 25784 25784 0 0.0
.dynamic 592 592 0 0.0
.got 3944 3944 0 0.0
.init 27 27 0 0.0
.init_array 400 400 0 0.0
.rodata 110644 110644 0 0.0
.text 1052629 1052629 0 0.0
lighting-app debug+rpc .bss 42232 42232 0 0.0
.data 1106 1106 0 0.0
.data.rel.ro 52496 52496 0 0.0
.dynamic 608 608 0 0.0
.got 4104 4104 0 0.0
.init 27 27 0 0.0
.init_array 528 528 0 0.0
.rodata 127857 127857 0 0.0
.text 1253906 1253906 0 0.0
mbed lighting-app CY8CPROTO_062_4343W+release .bss 172164 172164 0 0.0
.data 5464 5464 0 0.0
.heap 858816 858816 0 0.0
.text 1219944 1219944 0 0.0
lock-app CY8CPROTO_062_4343W+release .bss 171084 171084 0 0.0
.data 5432 5432 0 0.0
.heap 859928 859928 0 0.0
.text 1197840 1197840 0 0.0

@github-actions
Copy link

github-actions bot commented Oct 19, 2021

PR #10644: Size comparison from 4c7f664 to fb92579

8 builds (for k32w, p6, qpg, telink)
platform target config section 4c7f664 fb92579 change % change
k32w lock-app k32w061+debug .bss 69052 69052 0 0.0
.data 1864 1864 0 0.0
.text 515520 515520 0 0.0
shell k32w061+debug .bss 55080 55080 0 0.0
.data 672 672 0 0.0
.text 357332 357332 0 0.0
lighting-app k32w061+se05x+release .bss 78576 78576 0 0.0
.data 1900 1900 0 0.0
.text 614304 614304 0 0.0
p6 lock-app default .bss 68216 68216 0 0.0
.data 2416 2416 0 0.0
.heap 962712 962712 0 0.0
.text 1126624 1126624 0 0.0
qpg lighting-app qpg6100+debug .bss 53552 53552 0 0.0
.data 996 996 0 0.0
.text 486616 486616 0 0.0
lock-app qpg6100+debug .bss 52488 52488 0 0.0
.data 952 952 0 0.0
.text 462684 462684 0 0.0
persistent-storage-app qpg6100+debug .bss 17778 17778 0 0.0
.data 280 280 0 0.0
.text 102704 102704 0 0.0
telink lighting-app tlsr9518adk80d bss 71000 71000 0 0.0
noinit 33216 33216 0 0.0
text 458304 458304 0 0.0
14 builds (for efr32, linux, mbed)
platform target config section 4c7f664 fb92579 change % change
efr32 lighting-app BRD4161A .bss 118036 118036 0 0.0
.data 1800 1800 0 0.0
.text 782944 782944 0 0.0
lock-app BRD4161A .bss 115892 115892 0 0.0
.data 1760 1760 0 0.0
.text 762088 762088 0 0.0
window-app BRD4161A .bss 116212 116212 0 0.0
.data 1764 1764 0 0.0
.text 763012 763012 0 0.0
lighting-app BRD4161A+rpc .bss 131364 131364 0 0.0
.data 1852 1852 0 0.0
.text 762700 762700 0 0.0
linux all-clusters-app debug .bss 52176 52176 0 0.0
.data 978 978 0 0.0
.data.rel.ro 58688 58688 0 0.0
.dynamic 592 592 0 0.0
.got 4072 4072 0 0.0
.init 27 27 0 0.0
.init_array 512 512 0 0.0
.rodata 136373 136373 0 0.0
.text 1345186 1345186 0 0.0
chip-tool debug .bss 17552 17552 0 0.0
.data 1584 1584 0 0.0
.data.rel.ro 86192 86192 0 0.0
.dynamic 592 592 0 0.0
.got 4344 4344 0 0.0
.init 27 27 0 0.0
.init_array 416 416 0 0.0
.rodata 178892 178892 0 0.0
.text 2859941 2859941 0 0.0
ota-provider-app debug .bss 37472 37472 0 0.0
.data 752 752 0 0.0
.data.rel.ro 23176 23176 0 0.0
.dynamic 592 592 0 0.0
.got 4008 4008 0 0.0
.init 27 27 0 0.0
.init_array 440 440 0 0.0
.rodata 110056 110056 0 0.0
.text 1010594 1010594 0 0.0
ota-requestor-app debug .bss 205728 205728 0 0.0
.data 752 752 0 0.0
.data.rel.ro 24488 24488 0 0.0
.dynamic 592 592 0 0.0
.got 4136 4136 0 0.0
.init 27 27 0 0.0
.init_array 512 512 0 0.0
.rodata 128744 128744 0 0.0
.text 1130130 1130130 0 0.0
shell debug .bss 16072 16072 0 0.0
.data 242 242 0 0.0
.data.rel.ro 35120 35120 0 0.0
.dynamic 592 592 0 0.0
.got 3496 3496 0 0.0
.init 27 27 0 0.0
.init_array 336 336 0 0.0
.rodata 71855 71855 0 0.0
.text 569858 569858 0 0.0
tv-app debug .bss 216400 216400 0 0.0
.data 2032 2032 0 0.0
.data.rel.ro 55872 55872 0 0.0
.dynamic 592 592 0 0.0
.got 4400 4400 0 0.0
.init 27 27 0 0.0
.init_array 608 608 0 0.0
.rodata 152264 152264 0 0.0
.text 1464706 1464706 0 0.0
bridge-app debug+rpc .bss 52912 52912 0 0.0
.data 976 976 0 0.0
.data.rel.ro 25784 25784 0 0.0
.dynamic 592 592 0 0.0
.got 3944 3944 0 0.0
.init 27 27 0 0.0
.init_array 400 400 0 0.0
.rodata 110644 110644 0 0.0
.text 1052629 1052629 0 0.0
lighting-app debug+rpc .bss 42232 42232 0 0.0
.data 1106 1106 0 0.0
.data.rel.ro 52496 52496 0 0.0
.dynamic 608 608 0 0.0
.got 4104 4104 0 0.0
.init 27 27 0 0.0
.init_array 528 528 0 0.0
.rodata 127857 127857 0 0.0
.text 1253906 1253906 0 0.0
mbed lighting-app CY8CPROTO_062_4343W+release .bss 172164 172164 0 0.0
.data 5464 5464 0 0.0
.heap 858816 858816 0 0.0
.text 1219944 1219944 0 0.0
lock-app CY8CPROTO_062_4343W+release .bss 171084 171084 0 0.0
.data 5432 5432 0 0.0
.heap 859928 859928 0 0.0
.text 1197840 1197840 0 0.0
2 builds (for esp32)
platform target config section 4c7f664 fb92579 change % change
esp32 all-clusters-app c3devkit .dram0.bss 60296 60296 0 0.0
.dram0.data 16192 16192 0 0.0
.flash.rodata 199008 199008 0 0.0
.flash.text 872638 872638 0 0.0
.iram0.text 57330 57330 0 0.0
m5stack .dram0.bss 62792 62792 0 0.0
.dram0.data 32084 32084 0 0.0
.flash.rodata 207432 207432 0 0.0
.flash.text 902739 902739 0 0.0
.iram0.text 125115 125115 0 0.0
10 builds (for nrfconnect)
platform target config section 4c7f664 fb92579 change % change
nrfconnect lighting-app nrf52840dk_nrf52840 bss 112332 112504 172 0.2
rodata 97776 97776 0 0.0
text 577652 577784 132 0.0
lock-app nrf52840dk_nrf52840 bss 111348 111576 228 0.2
rodata 94112 94112 0 0.0
text 559152 559272 120 0.0
pigweed-app nrf52840dk_nrf52840 bss 51772 51832 60 0.1
rodata 45772 45772 0 0.0
text 339392 339472 80 0.0
pump-app nrf52840dk_nrf52840 bss 111416 111644 228 0.2
rodata 95092 95092 0 0.0
text 562308 562428 120 0.0
pump-controller-app nrf52840dk_nrf52840 bss 111356 111584 228 0.2
rodata 94172 94172 0 0.0
text 558944 559064 120 0.0
shell nrf52840dk_nrf52840 bss 107316 107316 0 0.0
rodata 71640 71640 0 0.0
text 519032 519032 0 0.0
lighting-app nrf52840dk_nrf52840+rpc bss 108572 108744 172 0.2
rodata 88560 88560 0 0.0
text 550856 550984 128 0.0
nrf5340dk_nrf5340_cpuapp bss 113704 113876 172 0.2
rodata 93016 93016 0 0.0
text 507116 507248 132 0.0
lock-app nrf5340dk_nrf5340_cpuapp bss 112720 112948 228 0.2
rodata 89372 89372 0 0.0
text 488612 488732 120 0.0
shell nrf5340dk_nrf5340_cpuapp bss 108300 108300 0 0.0
rodata 66284 66284 0 0.0
text 439632 439632 0 0.0

@github-actions
Copy link

Size increase report for "nrfconnect-example-build" from 4c7f664

File Section File VM
chip-lock.elf bss 0 224
chip-lock.elf text 120 120
chip-lock.elf device_handles 8 8
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-shell.elf and ./pull_artifact/chip-shell.elf:

sections,vmsize,filesize

Comparing ./master_artifact/chip-lock.elf and ./pull_artifact/chip-lock.elf:

sections,vmsize,filesize
.debug_info,0,3365
.debug_abbrev,0,769
.debug_line,0,590
.debug_str,0,496
.debug_loc,0,476
.symtab,0,272
bss,224,0
.debug_frame,0,176
.strtab,0,174
text,120,120
.debug_ranges,0,72
.debug_aranges,0,48
device_handles,8,8
.shstrtab,0,2


@kkasperczyk-no
Copy link
Contributor Author

Changing to draft, a bug was spotted

@kkasperczyk-no kkasperczyk-no marked this pull request as draft October 19, 2021 10:54
Application wakes up MCU every 10 ms to update LEDs state and handle
events even if it's not necessary.

* Moved updating BLE connection and Thread state from main loop
to Matter event handler
* Moved updating LED state from main loop to event handler
* Refactored LEDWidget module to use timer and change LEDs state
on timer expiration.
* By the way spotted and removed unused
lighting-app/nrfconnect/child_image/mcuboot.conf file
@kkasperczyk-no kkasperczyk-no marked this pull request as ready for review October 19, 2021 12:12
@kkasperczyk-no
Copy link
Contributor Author

Bug fixed

@github-actions
Copy link

github-actions bot commented Oct 19, 2021

PR #10644: Size comparison from 4c7f664 to b579ddb

16 builds (for k32w, linux, p6, qpg, telink)
platform target config section 4c7f664 b579ddb change % change
k32w lock-app k32w061+debug .bss 69052 69052 0 0.0
.data 1864 1864 0 0.0
.text 515520 515520 0 0.0
shell k32w061+debug .bss 55080 55080 0 0.0
.data 672 672 0 0.0
.text 357332 357332 0 0.0
lighting-app k32w061+se05x+release .bss 78576 78576 0 0.0
.data 1900 1900 0 0.0
.text 614304 614304 0 0.0
linux all-clusters-app debug .bss 52176 52176 0 0.0
.data 978 978 0 0.0
.data.rel.ro 58688 58688 0 0.0
.dynamic 592 592 0 0.0
.got 4072 4072 0 0.0
.init 27 27 0 0.0
.init_array 512 512 0 0.0
.rodata 136373 136373 0 0.0
.text 1345186 1345186 0 0.0
chip-tool debug .bss 17552 17552 0 0.0
.data 1584 1584 0 0.0
.data.rel.ro 86192 86192 0 0.0
.dynamic 592 592 0 0.0
.got 4344 4344 0 0.0
.init 27 27 0 0.0
.init_array 416 416 0 0.0
.rodata 178892 178892 0 0.0
.text 2859941 2859941 0 0.0
ota-provider-app debug .bss 37472 37472 0 0.0
.data 752 752 0 0.0
.data.rel.ro 23176 23176 0 0.0
.dynamic 592 592 0 0.0
.got 4008 4008 0 0.0
.init 27 27 0 0.0
.init_array 440 440 0 0.0
.rodata 110056 110056 0 0.0
.text 1010594 1010594 0 0.0
ota-requestor-app debug .bss 205728 205728 0 0.0
.data 752 752 0 0.0
.data.rel.ro 24488 24488 0 0.0
.dynamic 592 592 0 0.0
.got 4136 4136 0 0.0
.init 27 27 0 0.0
.init_array 512 512 0 0.0
.rodata 128744 128744 0 0.0
.text 1130130 1130130 0 0.0
shell debug .bss 16072 16072 0 0.0
.data 242 242 0 0.0
.data.rel.ro 35120 35120 0 0.0
.dynamic 592 592 0 0.0
.got 3496 3496 0 0.0
.init 27 27 0 0.0
.init_array 336 336 0 0.0
.rodata 71855 71855 0 0.0
.text 569858 569858 0 0.0
tv-app debug .bss 216400 216400 0 0.0
.data 2032 2032 0 0.0
.data.rel.ro 55872 55872 0 0.0
.dynamic 592 592 0 0.0
.got 4400 4400 0 0.0
.init 27 27 0 0.0
.init_array 608 608 0 0.0
.rodata 152264 152264 0 0.0
.text 1464706 1464706 0 0.0
bridge-app debug+rpc .bss 52912 52912 0 0.0
.data 976 976 0 0.0
.data.rel.ro 25784 25784 0 0.0
.dynamic 592 592 0 0.0
.got 3944 3944 0 0.0
.init 27 27 0 0.0
.init_array 400 400 0 0.0
.rodata 110644 110644 0 0.0
.text 1052629 1052629 0 0.0
lighting-app debug+rpc .bss 42232 42232 0 0.0
.data 1106 1106 0 0.0
.data.rel.ro 52496 52496 0 0.0
.dynamic 608 608 0 0.0
.got 4104 4104 0 0.0
.init 27 27 0 0.0
.init_array 528 528 0 0.0
.rodata 127857 127857 0 0.0
.text 1253906 1253906 0 0.0
p6 lock-app default .bss 68216 68216 0 0.0
.data 2416 2416 0 0.0
.heap 962712 962712 0 0.0
.text 1126624 1126624 0 0.0
qpg lighting-app qpg6100+debug .bss 53552 53552 0 0.0
.data 996 996 0 0.0
.text 486616 486616 0 0.0
lock-app qpg6100+debug .bss 52488 52488 0 0.0
.data 952 952 0 0.0
.text 462684 462684 0 0.0
persistent-storage-app qpg6100+debug .bss 17778 17778 0 0.0
.data 280 280 0 0.0
.text 102704 102704 0 0.0
telink lighting-app tlsr9518adk80d bss 71000 71000 0 0.0
noinit 33216 33216 0 0.0
text 458304 458304 0 0.0
6 builds (for efr32, mbed)
platform target config section 4c7f664 b579ddb change % change
efr32 lighting-app BRD4161A .bss 118036 118036 0 0.0
.data 1800 1800 0 0.0
.text 782944 782944 0 0.0
lock-app BRD4161A .bss 115892 115892 0 0.0
.data 1760 1760 0 0.0
.text 762088 762088 0 0.0
window-app BRD4161A .bss 116212 116212 0 0.0
.data 1764 1764 0 0.0
.text 763012 763012 0 0.0
lighting-app BRD4161A+rpc .bss 131364 131364 0 0.0
.data 1852 1852 0 0.0
.text 762700 762700 0 0.0
mbed lighting-app CY8CPROTO_062_4343W+release .bss 172164 172164 0 0.0
.data 5464 5464 0 0.0
.heap 858816 858816 0 0.0
.text 1219944 1219944 0 0.0
lock-app CY8CPROTO_062_4343W+release .bss 171084 171084 0 0.0
.data 5432 5432 0 0.0
.heap 859928 859928 0 0.0
.text 1197840 1197840 0 0.0
2 builds (for esp32)
platform target config section 4c7f664 b579ddb change % change
esp32 all-clusters-app c3devkit .dram0.bss 60296 60296 0 0.0
.dram0.data 16192 16192 0 0.0
.flash.rodata 199008 199008 0 0.0
.flash.text 872638 872638 0 0.0
.iram0.text 57330 57330 0 0.0
m5stack .dram0.bss 62792 62792 0 0.0
.dram0.data 32084 32084 0 0.0
.flash.rodata 207432 207432 0 0.0
.flash.text 902739 902739 0 0.0
.iram0.text 125115 125115 0 0.0
10 builds (for nrfconnect)
platform target config section 4c7f664 b579ddb change % change
nrfconnect lighting-app nrf52840dk_nrf52840 bss 112332 112480 148 0.1
rodata 97776 97776 0 0.0
text 577652 577780 128 0.0
lock-app nrf52840dk_nrf52840 bss 111348 111544 196 0.2
rodata 94112 94112 0 0.0
text 559152 559268 116 0.0
pigweed-app nrf52840dk_nrf52840 bss 51772 51824 52 0.1
rodata 45772 45772 0 0.0
text 339392 339456 64 0.0
pump-app nrf52840dk_nrf52840 bss 111416 111612 196 0.2
rodata 95092 95092 0 0.0
text 562308 562420 112 0.0
pump-controller-app nrf52840dk_nrf52840 bss 111356 111552 196 0.2
rodata 94172 94172 0 0.0
text 558944 559060 116 0.0
shell nrf52840dk_nrf52840 bss 107316 107316 0 0.0
rodata 71640 71640 0 0.0
text 519032 519032 0 0.0
lighting-app nrf52840dk_nrf52840+rpc bss 108572 108720 148 0.1
rodata 88560 88560 0 0.0
text 550856 550980 124 0.0
nrf5340dk_nrf5340_cpuapp bss 113704 113852 148 0.1
rodata 93016 93016 0 0.0
text 507116 507244 128 0.0
lock-app nrf5340dk_nrf5340_cpuapp bss 112720 112916 196 0.2
rodata 89372 89372 0 0.0
text 488612 488724 112 0.0
shell nrf5340dk_nrf5340_cpuapp bss 108300 108300 0 0.0
rodata 66284 66284 0 0.0
text 439632 439632 0 0.0

@bzbarsky-apple bzbarsky-apple merged commit b06b55c into project-chip:master Oct 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants