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

[Python] Use thread-safe futures for concurrent operations #33891

Merged

Conversation

agners
Copy link
Contributor

@agners agners commented Jun 12, 2024

Instead of using quasi-global variables in the ChipStack singleton use device controller local futures to store results from callbacks. This has several advantages, namely:

  • Avoid unnecessary shared state between device controllers
  • Avoid unnecessary shared state between various operations within a device controller (those who don't share callbacks could be called from different threads now)
  • Explicitly set Futures to None to detect spurious/unexpected callbacks
  • Better code readability
  • concurrent.futures are thread-safe
  • Will make asyncio transition easier

This change shouldn't change the external API.

This allows us to get rid of the rather complicated CallAsyncWithCompleteCallback. While at it, also get rid of the largely unused DCState enum.

Copy link

github-actions bot commented Jun 12, 2024

PR #33891: Size comparison from 0ae8a02 to ec4d728

Full report (85 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, mbed, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
platform target config section 0ae8a02 ec4d728 change % change
bl602 lighting-app bl602 FLASH 1267948 1267948 0 0.0
RAM 95424 95424 0 0.0
bl602+mfd FLASH 1282226 1282226 0 0.0
RAM 95576 95576 0 0.0
bl602+rpc FLASH 1306906 1306906 0 0.0
RAM 103856 103856 0 0.0
bl702 lighting-app bl702 FLASH 1088588 1088588 0 0.0
RAM 14897 14897 0 0.0
bl702+mfd FLASH 1099538 1099538 0 0.0
RAM 15049 15049 0 0.0
bl702+rpc FLASH 1178668 1178668 0 0.0
RAM 23925 23925 0 0.0
bl706-eth FLASH 872188 872188 0 0.0
RAM 27016 27016 0 0.0
bl706-wifi FLASH 1123784 1123784 0 0.0
RAM 14349 14349 0 0.0
bl702l lighting-app bl702l FLASH 1075730 1075730 0 0.0
RAM 21468 21468 0 0.0
bl702l+mfd FLASH 1086992 1086992 0 0.0
RAM 21628 21628 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 797636 797636 0 0.0
RAM 103184 103184 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 813440 813440 0 0.0
RAM 113664 113664 0 0.0
lock-mtd LP_EM_CC1354P10_6 FLASH 802804 802804 0 0.0
RAM 107784 107784 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 755292 755292 0 0.0
RAM 101884 101884 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 740940 740940 0 0.0
RAM 102132 102132 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 604902 604902 0 0.0
RAM 204608 204608 0 0.0
lock CC3235SF_LAUNCHXL FLASH 650690 650690 0 0.0
RAM 204868 204868 0 0.0
cyw30739 light CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 661149 661149 0 0.0
RAM 74608 74608 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 681001 681001 0 0.0
RAM 77240 77240 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 681001 681001 0 0.0
RAM 77240 77240 0 0.0
CYW930739M2EVB-02 unknown 2040 2040 0 0.0
FLASH 637937 637937 0 0.0
RAM 69676 69676 0 0.0
light-switch CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 603325 603325 0 0.0
RAM 70312 70312 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 622969 622969 0 0.0
RAM 72864 72864 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 622969 622969 0 0.0
RAM 72864 72864 0 0.0
lock CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 619117 619117 0 0.0
RAM 73328 73328 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 638841 638841 0 0.0
RAM 75880 75880 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 638841 638841 0 0.0
RAM 75880 75880 0 0.0
thermostat CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 587365 587365 0 0.0
RAM 67296 67296 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 607209 607209 0 0.0
RAM 69928 69928 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 607209 607209 0 0.0
RAM 69928 69928 0 0.0
efr32 lighting-app BRD4187C FLASH 887760 887760 0 0.0
RAM 183520 183520 0 0.0
lock-app BRD4338a FLASH 701568 701568 0 0.0
RAM 242804 242804 0 0.0
window-app BRD4187C FLASH 968628 968628 0 0.0
RAM 167952 167952 0 0.0
esp32 all-clusters-app c3devkit DRAM 88420 88420 0 0.0
FLASH 1466124 1466124 0 0.0
IRAM 75570 75570 0 0.0
m5stack DRAM 114892 114892 0 0.0
FLASH 1535363 1535363 0 0.0
IRAM 125403 125403 0 0.0
linux air-purifier-app debug unknown 4568 4568 0 0.0
FLASH 2531824 2531824 0 0.0
RAM 129072 129072 0 0.0
all-clusters-app debug unknown 5344 5344 0 0.0
FLASH 5568382 5568382 0 0.0
RAM 483000 483000 0 0.0
all-clusters-minimal-app debug unknown 5264 5264 0 0.0
FLASH 5052168 5052168 0 0.0
RAM 236792 236792 0 0.0
bridge-app debug unknown 5232 5232 0 0.0
FLASH 4477496 4477496 0 0.0
RAM 216752 216752 0 0.0
chip-tool debug unknown 5744 5744 0 0.0
FLASH 11511063 11511063 0 0.0
RAM 535202 535202 0 0.0
chip-tool-ipv6only arm64 unknown 19792 19792 0 0.0
FLASH 10649252 10649252 0 0.0
RAM 583200 583200 0 0.0
fabric-admin debug unknown 5600 5600 0 0.0
FLASH 11281207 11281207 0 0.0
RAM 528786 528786 0 0.0
fabric-bridge-app debug unknown 5240 5240 0 0.0
FLASH 4347112 4347112 0 0.0
RAM 208800 208800 0 0.0
lighting-app debug+rpc+ui unknown 5864 5864 0 0.0
FLASH 5365538 5365538 0 0.0
RAM 225392 225392 0 0.0
lock-app debug unknown 5184 5184 0 0.0
FLASH 4542840 4542840 0 0.0
RAM 204208 204208 0 0.0
ota-provider-app debug unknown 4552 4552 0 0.0
FLASH 4177320 4177320 0 0.0
RAM 193200 193200 0 0.0
ota-requestor-app debug unknown 4488 4488 0 0.0
FLASH 4301784 4301784 0 0.0
RAM 197840 197840 0 0.0
shell debug unknown 4112 4112 0 0.0
FLASH 2799949 2799949 0 0.0
RAM 154392 154392 0 0.0
thermostat-no-ble arm64 unknown 9160 9160 0 0.0
FLASH 4149604 4149604 0 0.0
RAM 234584 234584 0 0.0
tv-app debug unknown 5472 5472 0 0.0
FLASH 5587128 5587128 0 0.0
RAM 345640 345640 0 0.0
tv-casting-app debug unknown 5104 5104 0 0.0
FLASH 9559046 9559046 0 0.0
RAM 352800 352800 0 0.0
mbed lock-app-release cy8cproto_062_4343w FLASH 1497404 1497404 0 0.0
RAM 226168 226168 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 873856 873856 0 0.0
RAM 139225 139225 0 0.0
nrf7002dk_nrf5340_cpuapp FLASH 948556 948556 0 0.0
RAM 137653 137653 0 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 FLASH 821832 821832 0 0.0
RAM 138123 138123 0 0.0
nxp contact k32w0+release FLASH 575260 575260 0 0.0
RAM 70120 70120 0 0.0
k32w1+release FLASH 590384 590384 0 0.0
RAM 74152 74152 0 0.0
light k32w0+release FLASH 609224 609224 0 0.0
RAM 69596 69596 0 0.0
k32w1+release FLASH 673552 673552 0 0.0
RAM 82904 82904 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1610052 1610052 0 0.0
RAM 207228 207228 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1534260 1534260 0 0.0
RAM 204132 204132 0 0.0
light cy8ckit_062s2_43012 FLASH 1460548 1460548 0 0.0
RAM 197412 197412 0 0.0
lock cy8ckit_062s2_43012 FLASH 1462844 1462844 0 0.0
RAM 224476 224476 0 0.0
qpg lighting-app qpg6105+debug FLASH 650128 650128 0 0.0
RAM 104652 104652 0 0.0
lock-app qpg6105+debug FLASH 610116 610116 0 0.0
RAM 99328 99328 0 0.0
stm32 light STM32WB5MM-DK FLASH 472028 472028 0 0.0
RAM 141748 141748 0 0.0
telink air-quality-sensor-app tlsr9528a_retention FLASH 625172 625172 0 0.0
RAM 49952 49952 0 0.0
all-clusters-app tlsr9118bdk40d FLASH 600770 600770 0 0.0
RAM 130384 130384 0 0.0
all-clusters-minimal-app tlsr9528a FLASH 770382 770382 0 0.0
RAM 110148 110148 0 0.0
bridge-app tlsr9258a FLASH 668302 668302 0 0.0
RAM 94768 94768 0 0.0
contact-sensor-app tlsr9528a_retention FLASH 626924 626924 0 0.0
RAM 49996 49996 0 0.0
light-switch-app-ota-shell-factory-data tlsr9528a FLASH 712762 712762 0 0.0
RAM 76588 76588 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 557908 557908 0 0.0
RAM 126640 126640 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 792970 792970 0 0.0
RAM 99996 99996 0 0.0
lock-app-dfu tlsr9528a FLASH 660228 660228 0 0.0
RAM 69276 69276 0 0.0
ota-requestor-app tlsr9258a FLASH 686638 686638 0 0.0
RAM 94492 94492 0 0.0
pump-app tlsr9518adk80d FLASH 609124 609124 0 0.0
RAM 56376 56376 0 0.0
pump-controller-app tlsr9518adk80d FLASH 599472 599472 0 0.0
RAM 56176 56176 0 0.0
shell tlsr9518adk80d FLASH 462614 462614 0 0.0
RAM 71852 71852 0 0.0
smoke_co_alarm-app tlsr9528a_retention FLASH 633318 633318 0 0.0
RAM 51624 51624 0 0.0
temperature-measurement-app-mars-ota tlsr9518adk80d FLASH 642310 642310 0 0.0
RAM 59812 59812 0 0.0
thermostat tlsr9518adk80d FLASH 618374 618374 0 0.0
RAM 56500 56500 0 0.0
window-covering tlsr9118bdk40d FLASH 464694 464694 0 0.0
RAM 82272 82272 0 0.0
tizen all-clusters-app arm unknown 1548 1548 0 0.0
FLASH 1612836 1612836 0 0.0
RAM 45412 45412 0 0.0
chip-tool-ubsan arm unknown 2360 2360 0 0.0
FLASH 15735450 15735450 0 0.0
RAM 6902388 6902388 0 0.0

@agners agners force-pushed the use-futures-for-asynchronous-operations branch from ec4d728 to a51c323 Compare June 13, 2024 07:16
Copy link

github-actions bot commented Jun 13, 2024

PR #33891: Size comparison from bbd3419 to a51c323

Full report (85 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, mbed, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
platform target config section bbd3419 a51c323 change % change
bl602 lighting-app bl602 FLASH 1268236 1268236 0 0.0
RAM 95328 95328 0 0.0
bl602+mfd FLASH 1282514 1282514 0 0.0
RAM 95480 95480 0 0.0
bl602+rpc FLASH 1307194 1307194 0 0.0
RAM 103760 103760 0 0.0
bl702 lighting-app bl702 FLASH 1088876 1088876 0 0.0
RAM 14897 14897 0 0.0
bl702+mfd FLASH 1099826 1099826 0 0.0
RAM 15049 15049 0 0.0
bl702+rpc FLASH 1178956 1178956 0 0.0
RAM 23925 23925 0 0.0
bl706-eth FLASH 872476 872476 0 0.0
RAM 27016 27016 0 0.0
bl706-wifi FLASH 1124174 1124174 0 0.0
RAM 14349 14349 0 0.0
bl702l lighting-app bl702l FLASH 1076018 1076018 0 0.0
RAM 21468 21468 0 0.0
bl702l+mfd FLASH 1087280 1087280 0 0.0
RAM 21628 21628 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 797864 797864 0 0.0
RAM 103088 103088 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 813668 813668 0 0.0
RAM 113568 113568 0 0.0
lock-mtd LP_EM_CC1354P10_6 FLASH 803056 803056 0 0.0
RAM 107688 107688 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 755552 755552 0 0.0
RAM 101788 101788 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 741184 741184 0 0.0
RAM 102036 102036 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 605378 605378 0 0.0
RAM 204512 204512 0 0.0
lock CC3235SF_LAUNCHXL FLASH 651166 651166 0 0.0
RAM 204772 204772 0 0.0
cyw30739 light CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 661413 661413 0 0.0
RAM 74512 74512 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 681265 681265 0 0.0
RAM 77144 77144 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 681265 681265 0 0.0
RAM 77144 77144 0 0.0
CYW930739M2EVB-02 unknown 2040 2040 0 0.0
FLASH 638201 638201 0 0.0
RAM 69580 69580 0 0.0
light-switch CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 603589 603589 0 0.0
RAM 70216 70216 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 623233 623233 0 0.0
RAM 72768 72768 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 623233 623233 0 0.0
RAM 72768 72768 0 0.0
lock CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 619373 619373 0 0.0
RAM 73232 73232 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 639097 639097 0 0.0
RAM 75784 75784 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 639097 639097 0 0.0
RAM 75784 75784 0 0.0
thermostat CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 587629 587629 0 0.0
RAM 67200 67200 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 607473 607473 0 0.0
RAM 69832 69832 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 607473 607473 0 0.0
RAM 69832 69832 0 0.0
efr32 lighting-app BRD4187C FLASH 888024 888024 0 0.0
RAM 183424 183424 0 0.0
lock-app BRD4338a FLASH 702040 702040 0 0.0
RAM 242708 242708 0 0.0
window-app BRD4187C FLASH 969084 969084 0 0.0
RAM 167856 167856 0 0.0
esp32 all-clusters-app c3devkit DRAM 88324 88324 0 0.0
FLASH 1466428 1466428 0 0.0
IRAM 75570 75570 0 0.0
m5stack DRAM 114796 114796 0 0.0
FLASH 1535555 1535555 0 0.0
IRAM 125403 125403 0 0.0
linux air-purifier-app debug unknown 4568 4568 0 0.0
FLASH 2533808 2533808 0 0.0
RAM 129072 129072 0 0.0
all-clusters-app debug unknown 5344 5344 0 0.0
FLASH 5570398 5570398 0 0.0
RAM 483000 483000 0 0.0
all-clusters-minimal-app debug unknown 5264 5264 0 0.0
FLASH 5054184 5054184 0 0.0
RAM 236792 236792 0 0.0
bridge-app debug unknown 5232 5232 0 0.0
FLASH 4479496 4479496 0 0.0
RAM 216752 216752 0 0.0
chip-tool debug unknown 5744 5744 0 0.0
FLASH 11513047 11513047 0 0.0
RAM 535202 535202 0 0.0
chip-tool-ipv6only arm64 unknown 19816 19816 0 0.0
FLASH 1065152 1065152 0 0.0
RAM 583200 583200 0 0.0
fabric-admin debug unknown 5600 5600 0 0.0
FLASH 11283191 11283191 0 0.0
RAM 528786 528786 0 0.0
fabric-bridge-app debug unknown 5240 5240 0 0.0
FLASH 4349096 4349096 0 0.0
RAM 208800 208800 0 0.0
lighting-app debug+rpc+ui unknown 5864 5864 0 0.0
FLASH 5367554 5367554 0 0.0
RAM 225392 225392 0 0.0
lock-app debug unknown 5184 5184 0 0.0
FLASH 4544872 4544872 0 0.0
RAM 204208 204208 0 0.0
ota-provider-app debug unknown 4552 4552 0 0.0
FLASH 4179352 4179352 0 0.0
RAM 193200 193200 0 0.0
ota-requestor-app debug unknown 4488 4488 0 0.0
FLASH 4303768 4303768 0 0.0
RAM 197840 197840 0 0.0
shell debug unknown 4112 4112 0 0.0
FLASH 2801933 2801933 0 0.0
RAM 154392 154392 0 0.0
thermostat-no-ble arm64 unknown 9184 9184 0 0.0
FLASH 4151860 4151860 0 0.0
RAM 234584 234584 0 0.0
tv-app debug unknown 5472 5472 0 0.0
FLASH 5589160 5589160 0 0.0
RAM 345640 345640 0 0.0
tv-casting-app debug unknown 5104 5104 0 0.0
FLASH 9561030 9561030 0 0.0
RAM 352800 352800 0 0.0
mbed lock-app-release cy8cproto_062_4343w FLASH 1497660 1497660 0 0.0
RAM 226072 226072 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 874184 874184 0 0.0
RAM 139129 139129 0 0.0
nrf7002dk_nrf5340_cpuapp FLASH 948776 948776 0 0.0
RAM 137557 137557 0 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 FLASH 822156 822156 0 0.0
RAM 138027 138027 0 0.0
nxp contact k32w0+release FLASH 575436 575436 0 0.0
RAM 70024 70024 0 0.0
k32w1+release FLASH 590552 590552 0 0.0
RAM 74056 74056 0 0.0
light k32w0+release FLASH 609384 609384 0 0.0
RAM 69500 69500 0 0.0
k32w1+release FLASH 673744 673744 0 0.0
RAM 82808 82808 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1610508 1610508 0 0.0
RAM 207132 207132 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1534716 1534716 0 0.0
RAM 204036 204036 0 0.0
light cy8ckit_062s2_43012 FLASH 1460988 1460988 0 0.0
RAM 197316 197316 0 0.0
lock cy8ckit_062s2_43012 FLASH 1463300 1463300 0 0.0
RAM 224380 224380 0 0.0
qpg lighting-app qpg6105+debug FLASH 650352 650352 0 0.0
RAM 104556 104556 0 0.0
lock-app qpg6105+debug FLASH 610404 610404 0 0.0
RAM 99232 99232 0 0.0
stm32 light STM32WB5MM-DK FLASH 472260 472260 0 0.0
RAM 141652 141652 0 0.0
telink air-quality-sensor-app tlsr9528a_retention FLASH 625418 625418 0 0.0
RAM 49904 49904 0 0.0
all-clusters-app tlsr9118bdk40d FLASH 601012 601012 0 0.0
RAM 130288 130288 0 0.0
all-clusters-minimal-app tlsr9528a FLASH 770624 770624 0 0.0
RAM 110052 110052 0 0.0
bridge-app tlsr9258a FLASH 668544 668544 0 0.0
RAM 94672 94672 0 0.0
contact-sensor-app tlsr9528a_retention FLASH 627170 627170 0 0.0
RAM 49948 49948 0 0.0
light-switch-app-ota-shell-factory-data tlsr9528a FLASH 713008 713008 0 0.0
RAM 76540 76540 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 558150 558150 0 0.0
RAM 126544 126544 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 793212 793212 0 0.0
RAM 99900 99900 0 0.0
lock-app-dfu tlsr9528a FLASH 660474 660474 0 0.0
RAM 69228 69228 0 0.0
ota-requestor-app tlsr9258a FLASH 686880 686880 0 0.0
RAM 94396 94396 0 0.0
pump-app tlsr9518adk80d FLASH 609370 609370 0 0.0
RAM 56328 56328 0 0.0
pump-controller-app tlsr9518adk80d FLASH 599718 599718 0 0.0
RAM 56128 56128 0 0.0
shell tlsr9518adk80d FLASH 462614 462614 0 0.0
RAM 71852 71852 0 0.0
smoke_co_alarm-app tlsr9528a_retention FLASH 633552 633552 0 0.0
RAM 51576 51576 0 0.0
temperature-measurement-app-mars-ota tlsr9518adk80d FLASH 642556 642556 0 0.0
RAM 59764 59764 0 0.0
thermostat tlsr9518adk80d FLASH 618620 618620 0 0.0
RAM 56452 56452 0 0.0
window-covering tlsr9118bdk40d FLASH 464934 464934 0 0.0
RAM 82224 82224 0 0.0
tizen all-clusters-app arm unknown 1548 1548 0 0.0
FLASH 1614168 1614168 0 0.0
RAM 45412 45412 0 0.0
chip-tool-ubsan arm unknown 2360 2360 0 0.0
FLASH 15741802 15741802 0 0.0
RAM 6906152 6906152 0 0.0

Instead of using quasi-global variables in the ChipStack singleton
use device controller local futures to store results from callbacks.
This has several advantages, namely:
- Avoid unnecessary shared state between device controllers
- Avoid unnecessary shared state between various operations within a
  device controller (those who don't share callbacks could be called
  from different threads now)
- Explicitly set Futures to None to detect spurious/unexpected callbacks
- Better code readability
- concurrent.futures are thread-safe
- Will make asyncio transition easier

This change shouldn't change the external API.
@agners agners force-pushed the use-futures-for-asynchronous-operations branch from a51c323 to aa4a78a Compare June 13, 2024 09:04
Copy link

github-actions bot commented Jun 13, 2024

PR #33891: Size comparison from bbd3419 to aa4a78a

Full report (85 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, mbed, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
platform target config section bbd3419 aa4a78a change % change
bl602 lighting-app bl602 FLASH 1268236 1268236 0 0.0
RAM 95328 95328 0 0.0
bl602+mfd FLASH 1282514 1282514 0 0.0
RAM 95480 95480 0 0.0
bl602+rpc FLASH 1307194 1307194 0 0.0
RAM 103760 103760 0 0.0
bl702 lighting-app bl702 FLASH 1088876 1088876 0 0.0
RAM 14897 14897 0 0.0
bl702+mfd FLASH 1099826 1099826 0 0.0
RAM 15049 15049 0 0.0
bl702+rpc FLASH 1178956 1178956 0 0.0
RAM 23925 23925 0 0.0
bl706-eth FLASH 872476 872476 0 0.0
RAM 27016 27016 0 0.0
bl706-wifi FLASH 1124174 1124174 0 0.0
RAM 14349 14349 0 0.0
bl702l lighting-app bl702l FLASH 1076018 1076018 0 0.0
RAM 21468 21468 0 0.0
bl702l+mfd FLASH 1087280 1087280 0 0.0
RAM 21628 21628 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 797864 797864 0 0.0
RAM 103088 103088 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 813668 813668 0 0.0
RAM 113568 113568 0 0.0
lock-mtd LP_EM_CC1354P10_6 FLASH 803056 803056 0 0.0
RAM 107688 107688 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 755552 755552 0 0.0
RAM 101788 101788 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 741184 741184 0 0.0
RAM 102036 102036 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 605378 605378 0 0.0
RAM 204512 204512 0 0.0
lock CC3235SF_LAUNCHXL FLASH 651166 651166 0 0.0
RAM 204772 204772 0 0.0
cyw30739 light CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 661413 661413 0 0.0
RAM 74512 74512 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 681265 681265 0 0.0
RAM 77144 77144 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 681265 681265 0 0.0
RAM 77144 77144 0 0.0
CYW930739M2EVB-02 unknown 2040 2040 0 0.0
FLASH 638201 638201 0 0.0
RAM 69580 69580 0 0.0
light-switch CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 603589 603589 0 0.0
RAM 70216 70216 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 623233 623233 0 0.0
RAM 72768 72768 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 623233 623233 0 0.0
RAM 72768 72768 0 0.0
lock CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 619373 619373 0 0.0
RAM 73232 73232 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 639097 639097 0 0.0
RAM 75784 75784 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 639097 639097 0 0.0
RAM 75784 75784 0 0.0
thermostat CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 587629 587629 0 0.0
RAM 67200 67200 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 607473 607473 0 0.0
RAM 69832 69832 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 607473 607473 0 0.0
RAM 69832 69832 0 0.0
efr32 lighting-app BRD4187C FLASH 888024 888024 0 0.0
RAM 183424 183424 0 0.0
lock-app BRD4338a FLASH 702040 702040 0 0.0
RAM 242708 242708 0 0.0
window-app BRD4187C FLASH 969084 969084 0 0.0
RAM 167856 167856 0 0.0
esp32 all-clusters-app c3devkit DRAM 88324 88324 0 0.0
FLASH 1466428 1466428 0 0.0
IRAM 75570 75570 0 0.0
m5stack DRAM 114796 114796 0 0.0
FLASH 1535555 1535555 0 0.0
IRAM 125403 125403 0 0.0
linux air-purifier-app debug unknown 4568 4568 0 0.0
FLASH 2533808 2533808 0 0.0
RAM 129072 129072 0 0.0
all-clusters-app debug unknown 5344 5344 0 0.0
FLASH 5570398 5570398 0 0.0
RAM 483000 483000 0 0.0
all-clusters-minimal-app debug unknown 5264 5264 0 0.0
FLASH 5054184 5054184 0 0.0
RAM 236792 236792 0 0.0
bridge-app debug unknown 5232 5232 0 0.0
FLASH 4479496 4479496 0 0.0
RAM 216752 216752 0 0.0
chip-tool debug unknown 5744 5744 0 0.0
FLASH 11513047 11513047 0 0.0
RAM 535202 535202 0 0.0
chip-tool-ipv6only arm64 unknown 19816 19816 0 0.0
FLASH 1065152 1065152 0 0.0
RAM 583200 583200 0 0.0
fabric-admin debug unknown 5600 5600 0 0.0
FLASH 11283191 11283191 0 0.0
RAM 528786 528786 0 0.0
fabric-bridge-app debug unknown 5240 5240 0 0.0
FLASH 4349096 4349096 0 0.0
RAM 208800 208800 0 0.0
lighting-app debug+rpc+ui unknown 5864 5864 0 0.0
FLASH 5367554 5367554 0 0.0
RAM 225392 225392 0 0.0
lock-app debug unknown 5184 5184 0 0.0
FLASH 4544872 4544872 0 0.0
RAM 204208 204208 0 0.0
ota-provider-app debug unknown 4552 4552 0 0.0
FLASH 4179352 4179352 0 0.0
RAM 193200 193200 0 0.0
ota-requestor-app debug unknown 4488 4488 0 0.0
FLASH 4303768 4303768 0 0.0
RAM 197840 197840 0 0.0
shell debug unknown 4112 4112 0 0.0
FLASH 2801933 2801933 0 0.0
RAM 154392 154392 0 0.0
thermostat-no-ble arm64 unknown 9184 9184 0 0.0
FLASH 4151860 4151860 0 0.0
RAM 234584 234584 0 0.0
tv-app debug unknown 5472 5472 0 0.0
FLASH 5589160 5589160 0 0.0
RAM 345640 345640 0 0.0
tv-casting-app debug unknown 5104 5104 0 0.0
FLASH 9561030 9561030 0 0.0
RAM 352800 352800 0 0.0
mbed lock-app-release cy8cproto_062_4343w FLASH 1497660 1497660 0 0.0
RAM 226072 226072 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 874184 874184 0 0.0
RAM 139129 139129 0 0.0
nrf7002dk_nrf5340_cpuapp FLASH 948776 948776 0 0.0
RAM 137557 137557 0 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 FLASH 822156 822156 0 0.0
RAM 138027 138027 0 0.0
nxp contact k32w0+release FLASH 575436 575436 0 0.0
RAM 70024 70024 0 0.0
k32w1+release FLASH 590552 590552 0 0.0
RAM 74056 74056 0 0.0
light k32w0+release FLASH 609384 609384 0 0.0
RAM 69500 69500 0 0.0
k32w1+release FLASH 673744 673744 0 0.0
RAM 82808 82808 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1610508 1610508 0 0.0
RAM 207132 207132 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1534716 1534716 0 0.0
RAM 204036 204036 0 0.0
light cy8ckit_062s2_43012 FLASH 1460988 1460988 0 0.0
RAM 197316 197316 0 0.0
lock cy8ckit_062s2_43012 FLASH 1463300 1463300 0 0.0
RAM 224380 224380 0 0.0
qpg lighting-app qpg6105+debug FLASH 650352 650352 0 0.0
RAM 104556 104556 0 0.0
lock-app qpg6105+debug FLASH 610404 610404 0 0.0
RAM 99232 99232 0 0.0
stm32 light STM32WB5MM-DK FLASH 472260 472260 0 0.0
RAM 141652 141652 0 0.0
telink air-quality-sensor-app tlsr9528a_retention FLASH 625418 625418 0 0.0
RAM 49904 49904 0 0.0
all-clusters-app tlsr9118bdk40d FLASH 601012 601012 0 0.0
RAM 130288 130288 0 0.0
all-clusters-minimal-app tlsr9528a FLASH 770624 770624 0 0.0
RAM 110052 110052 0 0.0
bridge-app tlsr9258a FLASH 668544 668544 0 0.0
RAM 94672 94672 0 0.0
contact-sensor-app tlsr9528a_retention FLASH 627170 627170 0 0.0
RAM 49948 49948 0 0.0
light-switch-app-ota-shell-factory-data tlsr9528a FLASH 713008 713008 0 0.0
RAM 76540 76540 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 558150 558150 0 0.0
RAM 126544 126544 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 793212 793212 0 0.0
RAM 99900 99900 0 0.0
lock-app-dfu tlsr9528a FLASH 660474 660474 0 0.0
RAM 69228 69228 0 0.0
ota-requestor-app tlsr9258a FLASH 686880 686880 0 0.0
RAM 94396 94396 0 0.0
pump-app tlsr9518adk80d FLASH 609370 609370 0 0.0
RAM 56328 56328 0 0.0
pump-controller-app tlsr9518adk80d FLASH 599718 599718 0 0.0
RAM 56128 56128 0 0.0
shell tlsr9518adk80d FLASH 462614 462614 0 0.0
RAM 71852 71852 0 0.0
smoke_co_alarm-app tlsr9528a_retention FLASH 633552 633552 0 0.0
RAM 51576 51576 0 0.0
temperature-measurement-app-mars-ota tlsr9518adk80d FLASH 642556 642556 0 0.0
RAM 59764 59764 0 0.0
thermostat tlsr9518adk80d FLASH 618620 618620 0 0.0
RAM 56452 56452 0 0.0
window-covering tlsr9118bdk40d FLASH 464934 464934 0 0.0
RAM 82224 82224 0 0.0
tizen all-clusters-app arm unknown 1548 1548 0 0.0
FLASH 1614168 1614168 0 0.0
RAM 45412 45412 0 0.0
chip-tool-ubsan arm unknown 2360 2360 0 0.0
FLASH 15741802 15741802 0 0.0
RAM 6906152 6906152 0 0.0

Copy link

github-actions bot commented Jun 13, 2024

PR #33891: Size comparison from bbd3419 to 3c24956

Full report (85 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, mbed, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
platform target config section bbd3419 3c24956 change % change
bl602 lighting-app bl602 FLASH 1268236 1268236 0 0.0
RAM 95328 95328 0 0.0
bl602+mfd FLASH 1282514 1282514 0 0.0
RAM 95480 95480 0 0.0
bl602+rpc FLASH 1307194 1307194 0 0.0
RAM 103760 103760 0 0.0
bl702 lighting-app bl702 FLASH 1088876 1088876 0 0.0
RAM 14897 14897 0 0.0
bl702+mfd FLASH 1099826 1099826 0 0.0
RAM 15049 15049 0 0.0
bl702+rpc FLASH 1178956 1178956 0 0.0
RAM 23925 23925 0 0.0
bl706-eth FLASH 872476 872476 0 0.0
RAM 27016 27016 0 0.0
bl706-wifi FLASH 1124174 1124174 0 0.0
RAM 14349 14349 0 0.0
bl702l lighting-app bl702l FLASH 1076018 1076018 0 0.0
RAM 21468 21468 0 0.0
bl702l+mfd FLASH 1087280 1087280 0 0.0
RAM 21628 21628 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 797864 797864 0 0.0
RAM 103088 103088 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 813668 813668 0 0.0
RAM 113568 113568 0 0.0
lock-mtd LP_EM_CC1354P10_6 FLASH 803056 803056 0 0.0
RAM 107688 107688 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 755552 755552 0 0.0
RAM 101788 101788 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 741184 741184 0 0.0
RAM 102036 102036 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 605378 605378 0 0.0
RAM 204512 204512 0 0.0
lock CC3235SF_LAUNCHXL FLASH 651166 651166 0 0.0
RAM 204772 204772 0 0.0
cyw30739 light CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 661413 661413 0 0.0
RAM 74512 74512 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 681265 681265 0 0.0
RAM 77144 77144 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 681265 681265 0 0.0
RAM 77144 77144 0 0.0
CYW930739M2EVB-02 unknown 2040 2040 0 0.0
FLASH 638201 638201 0 0.0
RAM 69580 69580 0 0.0
light-switch CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 603589 603589 0 0.0
RAM 70216 70216 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 623233 623233 0 0.0
RAM 72768 72768 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 623233 623233 0 0.0
RAM 72768 72768 0 0.0
lock CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 619373 619373 0 0.0
RAM 73232 73232 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 639097 639097 0 0.0
RAM 75784 75784 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 639097 639097 0 0.0
RAM 75784 75784 0 0.0
thermostat CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 587629 587629 0 0.0
RAM 67200 67200 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 607473 607473 0 0.0
RAM 69832 69832 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 607473 607473 0 0.0
RAM 69832 69832 0 0.0
efr32 lighting-app BRD4187C FLASH 888024 888024 0 0.0
RAM 183424 183424 0 0.0
lock-app BRD4338a FLASH 702040 702040 0 0.0
RAM 242708 242708 0 0.0
window-app BRD4187C FLASH 969084 969084 0 0.0
RAM 167856 167856 0 0.0
esp32 all-clusters-app c3devkit DRAM 88324 88324 0 0.0
FLASH 1466428 1466428 0 0.0
IRAM 75570 75570 0 0.0
m5stack DRAM 114796 114796 0 0.0
FLASH 1535555 1535555 0 0.0
IRAM 125403 125403 0 0.0
linux air-purifier-app debug unknown 4568 4568 0 0.0
FLASH 2533808 2533808 0 0.0
RAM 129072 129072 0 0.0
all-clusters-app debug unknown 5344 5344 0 0.0
FLASH 5570398 5570398 0 0.0
RAM 483000 483000 0 0.0
all-clusters-minimal-app debug unknown 5264 5264 0 0.0
FLASH 5054184 5054184 0 0.0
RAM 236792 236792 0 0.0
bridge-app debug unknown 5232 5232 0 0.0
FLASH 4479496 4479496 0 0.0
RAM 216752 216752 0 0.0
chip-tool debug unknown 5744 5744 0 0.0
FLASH 11513047 11513047 0 0.0
RAM 535202 535202 0 0.0
chip-tool-ipv6only arm64 unknown 19816 19816 0 0.0
FLASH 1065152 1065152 0 0.0
RAM 583200 583200 0 0.0
fabric-admin debug unknown 5600 5600 0 0.0
FLASH 11283191 11283191 0 0.0
RAM 528786 528786 0 0.0
fabric-bridge-app debug unknown 5240 5240 0 0.0
FLASH 4349096 4349096 0 0.0
RAM 208800 208800 0 0.0
lighting-app debug+rpc+ui unknown 5864 5864 0 0.0
FLASH 5367554 5367554 0 0.0
RAM 225392 225392 0 0.0
lock-app debug unknown 5184 5184 0 0.0
FLASH 4544872 4544872 0 0.0
RAM 204208 204208 0 0.0
ota-provider-app debug unknown 4552 4552 0 0.0
FLASH 4179352 4179352 0 0.0
RAM 193200 193200 0 0.0
ota-requestor-app debug unknown 4488 4488 0 0.0
FLASH 4303768 4303768 0 0.0
RAM 197840 197840 0 0.0
shell debug unknown 4112 4112 0 0.0
FLASH 2801933 2801933 0 0.0
RAM 154392 154392 0 0.0
thermostat-no-ble arm64 unknown 9184 9184 0 0.0
FLASH 4151860 4151860 0 0.0
RAM 234584 234584 0 0.0
tv-app debug unknown 5472 5472 0 0.0
FLASH 5589160 5589160 0 0.0
RAM 345640 345640 0 0.0
tv-casting-app debug unknown 5104 5104 0 0.0
FLASH 9561030 9561030 0 0.0
RAM 352800 352800 0 0.0
mbed lock-app-release cy8cproto_062_4343w FLASH 1497660 1497660 0 0.0
RAM 226072 226072 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 874184 874184 0 0.0
RAM 139129 139129 0 0.0
nrf7002dk_nrf5340_cpuapp FLASH 948776 948776 0 0.0
RAM 137557 137557 0 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 FLASH 822156 822156 0 0.0
RAM 138027 138027 0 0.0
nxp contact k32w0+release FLASH 575436 575436 0 0.0
RAM 70024 70024 0 0.0
k32w1+release FLASH 590552 590552 0 0.0
RAM 74056 74056 0 0.0
light k32w0+release FLASH 609384 609384 0 0.0
RAM 69500 69500 0 0.0
k32w1+release FLASH 673744 673744 0 0.0
RAM 82808 82808 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1610508 1610508 0 0.0
RAM 207132 207132 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1534716 1534716 0 0.0
RAM 204036 204036 0 0.0
light cy8ckit_062s2_43012 FLASH 1460988 1460988 0 0.0
RAM 197316 197316 0 0.0
lock cy8ckit_062s2_43012 FLASH 1463300 1463300 0 0.0
RAM 224380 224380 0 0.0
qpg lighting-app qpg6105+debug FLASH 650352 650352 0 0.0
RAM 104556 104556 0 0.0
lock-app qpg6105+debug FLASH 610404 610404 0 0.0
RAM 99232 99232 0 0.0
stm32 light STM32WB5MM-DK FLASH 472260 472260 0 0.0
RAM 141652 141652 0 0.0
telink air-quality-sensor-app tlsr9528a_retention FLASH 625418 625418 0 0.0
RAM 49904 49904 0 0.0
all-clusters-app tlsr9118bdk40d FLASH 601012 601012 0 0.0
RAM 130288 130288 0 0.0
all-clusters-minimal-app tlsr9528a FLASH 770624 770624 0 0.0
RAM 110052 110052 0 0.0
bridge-app tlsr9258a FLASH 668544 668544 0 0.0
RAM 94672 94672 0 0.0
contact-sensor-app tlsr9528a_retention FLASH 627170 627170 0 0.0
RAM 49948 49948 0 0.0
light-switch-app-ota-shell-factory-data tlsr9528a FLASH 713008 713008 0 0.0
RAM 76540 76540 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 558150 558150 0 0.0
RAM 126544 126544 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 793212 793212 0 0.0
RAM 99900 99900 0 0.0
lock-app-dfu tlsr9528a FLASH 660474 660474 0 0.0
RAM 69228 69228 0 0.0
ota-requestor-app tlsr9258a FLASH 686880 686880 0 0.0
RAM 94396 94396 0 0.0
pump-app tlsr9518adk80d FLASH 609370 609370 0 0.0
RAM 56328 56328 0 0.0
pump-controller-app tlsr9518adk80d FLASH 599718 599718 0 0.0
RAM 56128 56128 0 0.0
shell tlsr9518adk80d FLASH 462614 462614 0 0.0
RAM 71852 71852 0 0.0
smoke_co_alarm-app tlsr9528a_retention FLASH 633552 633552 0 0.0
RAM 51576 51576 0 0.0
temperature-measurement-app-mars-ota tlsr9518adk80d FLASH 642556 642556 0 0.0
RAM 59764 59764 0 0.0
thermostat tlsr9518adk80d FLASH 618620 618620 0 0.0
RAM 56452 56452 0 0.0
window-covering tlsr9118bdk40d FLASH 464934 464934 0 0.0
RAM 82224 82224 0 0.0
tizen all-clusters-app arm unknown 1548 1548 0 0.0
FLASH 1614168 1614168 0 0.0
RAM 45412 45412 0 0.0
chip-tool-ubsan arm unknown 2360 2360 0 0.0
FLASH 15741802 15741802 0 0.0
RAM 6906152 6906152 0 0.0

@mergify mergify bot merged commit 645d3a7 into project-chip:master Jun 13, 2024
68 checks passed
agners added a commit to home-assistant-libs/chip-wheels that referenced this pull request Jun 17, 2024
This adds more cleanups from the master branch to keep our 1.3 based
branch close to upstream. Most noteworthy here are a patch which stops
mDNS discovery when using the on-network commissioning API, fixes when
commissioning using WiFi/Thread setup through BLE directly (the Python
Matter Server isn't using this APIs currently), dropping unnecessary
code and and general messaging cleanup.

Specifically, this integrates changes from the following PRs
- project-chip/connectedhomeip#33882
- project-chip/connectedhomeip#33896
- project-chip/connectedhomeip#33891
- project-chip/connectedhomeip#33880
- project-chip/connectedhomeip#33914
- project-chip/connectedhomeip#33915
- project-chip/connectedhomeip#33933
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.

3 participants