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] Remove Python Bluetooth and ChipStack event loop integration #33775

Conversation

agners
Copy link
Contributor

@agners agners commented Jun 6, 2024

The Python Bluetooth implementation for Linux (BluezManager in ChipBluezMgr.py) and macOS (CoreBluetoothManager in ChipCoreBluetoothMgr.py) integrate with ChipStack to pump their event loops on long running operations such as commissioning (through CallAsyncWithCompleteCallback()). From what I can tell this is no longer used as the Bluetooth communication is entirely handled by the respective native implementations for Linux and macOS today. It seems the Python Bluetooth managers are only used for some mbed integration tests. Specifically through scan_chip_ble_devices() in src/test_driver/mbed/integration_tests/common/utils.py. This operation anyway busy wait during scanning and don't need any event loop integration.

So as a first step, this PR simply breaks this tie and removes the event loop integration with the Device ChipStack/ChipDeviceController.

@agners
Copy link
Contributor Author

agners commented Jun 6, 2024

Note that the event loop integration is rather hacky anyways. Especially on the Linux side this could be done much nicer with Python asyncio and GLib. This StackOverflow answer has the basics: Essentially instead of creating a MainLoop on GLib side, simply pending() and iteration(may_block=False) regularly from asyncio tasks.

Copy link

github-actions bot commented Jun 6, 2024

PR #33775: Size comparison from d15f6c1 to 11130f0

Full report (8 builds for cc32xx, mbed, qpg, stm32, tizen)
platform target config section d15f6c1 11130f0 change % change
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 604330 604330 0 0.0
RAM 204592 204592 0 0.0
lock CC3235SF_LAUNCHXL FLASH 649606 649606 0 0.0
RAM 204852 204852 0 0.0
mbed lock-app-release cy8cproto_062_4343w FLASH 1497092 1497092 0 0.0
RAM 226152 226152 0 0.0
qpg lighting-app qpg6105+debug FLASH 650088 650088 0 0.0
RAM 104644 104644 0 0.0
lock-app qpg6105+debug FLASH 609932 609932 0 0.0
RAM 99320 99320 0 0.0
stm32 light STM32WB5MM-DK FLASH 471412 471412 0 0.0
RAM 141732 141732 0 0.0
tizen all-clusters-app arm unknown 1556 1556 0 0.0
FLASH 1609932 1609932 0 0.0
RAM 45452 45452 0 0.0
chip-tool-ubsan arm unknown 2364 2364 0 0.0
FLASH 15626834 15626834 0 0.0
RAM 6822312 6822312 0 0.0

The Python Bluetooth implementation for Linux (`BluezManager` in
ChipBluezMgr.py) and macOS (`CoreBluetoothManager` in
ChipCoreBluetoothMgr.py) integrate with ChipStack to pump their event
loops on long running operations such as commissioning (through
`CallAsyncWithCompleteCallback()`). From what I can tell, the Python
Bluetooth stack is only used for some mbed integration tests.
Specifically through `scan_chip_ble_devices()`
in src/test_driver/mbed/integration_tests/common/utils.py. This
operation doesn't need the event loop integration.

So as a first step, this PR simply breaks this tie and removes the
event loop integration with the Device ChipStack/ChipDeviceController.
@agners agners force-pushed the remove-python-bluetooth-event-loop-integration branch from 11130f0 to cf87fd8 Compare June 6, 2024 12:45
Copy link

github-actions bot commented Jun 6, 2024

PR #33775: Size comparison from d15f6c1 to cf87fd8

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 d15f6c1 cf87fd8 change % change
bl602 lighting-app bl602 FLASH 1267952 1267952 0 0.0
RAM 95408 95408 0 0.0
bl602+mfd FLASH 1282228 1282228 0 0.0
RAM 95560 95560 0 0.0
bl602+rpc FLASH 1307166 1307166 0 0.0
RAM 103840 103840 0 0.0
bl702 lighting-app bl702 FLASH 1088592 1088592 0 0.0
RAM 14897 14897 0 0.0
bl702+mfd FLASH 1099284 1099284 0 0.0
RAM 15049 15049 0 0.0
bl702+rpc FLASH 1178416 1178416 0 0.0
RAM 23925 23925 0 0.0
bl706-eth FLASH 872024 872024 0 0.0
RAM 27016 27016 0 0.0
bl706-wifi FLASH 1123616 1123616 0 0.0
RAM 14349 14349 0 0.0
bl702l lighting-app bl702l FLASH 1075478 1075478 0 0.0
RAM 21468 21468 0 0.0
bl702l+mfd FLASH 1086738 1086738 0 0.0
RAM 21628 21628 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 797296 797296 0 0.0
RAM 103176 103176 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 812984 812984 0 0.0
RAM 113656 113656 0 0.0
lock-mtd LP_EM_CC1354P10_6 FLASH 802344 802344 0 0.0
RAM 107776 107776 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 755256 755256 0 0.0
RAM 101884 101884 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 740920 740920 0 0.0
RAM 102124 102124 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 604330 604330 0 0.0
RAM 204592 204592 0 0.0
lock CC3235SF_LAUNCHXL FLASH 649606 649606 0 0.0
RAM 204852 204852 0 0.0
cyw30739 light CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 660973 660973 0 0.0
RAM 74592 74592 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 680825 680825 0 0.0
RAM 77224 77224 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 680825 680825 0 0.0
RAM 77224 77224 0 0.0
CYW930739M2EVB-02 unknown 2040 2040 0 0.0
FLASH 637753 637753 0 0.0
RAM 69660 69660 0 0.0
light-switch CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 603461 603461 0 0.0
RAM 70296 70296 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 623097 623097 0 0.0
RAM 72848 72848 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 623097 623097 0 0.0
RAM 72848 72848 0 0.0
lock CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 618797 618797 0 0.0
RAM 73312 73312 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 638521 638521 0 0.0
RAM 75864 75864 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 638521 638521 0 0.0
RAM 75864 75864 0 0.0
thermostat CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 587581 587581 0 0.0
RAM 67280 67280 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 607425 607425 0 0.0
RAM 69912 69912 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 607425 607425 0 0.0
RAM 69912 69912 0 0.0
efr32 lighting-app BRD4187C FLASH 887608 887600 -8 -0.0
RAM 183504 183504 0 0.0
lock-app BRD4338a FLASH 700504 700504 0 0.0
RAM 242708 242708 0 0.0
window-app BRD4187C FLASH 967780 967772 -8 -0.0
RAM 167936 167936 0 0.0
esp32 all-clusters-app c3devkit DRAM 88404 88404 0 0.0
FLASH 1465420 1465420 0 0.0
IRAM 75570 75570 0 0.0
m5stack DRAM 114876 114876 0 0.0
FLASH 1534151 1534151 0 0.0
IRAM 125403 125403 0 0.0
linux air-purifier-app debug unknown 4576 4576 0 0.0
FLASH 2530112 2530112 0 0.0
RAM 128832 128832 0 0.0
all-clusters-app debug unknown 5344 5344 0 0.0
FLASH 5561310 5561310 0 0.0
RAM 481944 481944 0 0.0
all-clusters-minimal-app debug unknown 5264 5264 0 0.0
FLASH 5047448 5047448 0 0.0
RAM 236520 236520 0 0.0
bridge-app debug unknown 5232 5232 0 0.0
FLASH 4475544 4475544 0 0.0
RAM 216544 216544 0 0.0
chip-tool debug unknown 5744 5744 0 0.0
FLASH 11514199 11514199 0 0.0
RAM 521474 521474 0 0.0
chip-tool-ipv6only arm64 unknown 17368 17368 0 0.0
FLASH 10663252 10663252 0 0.0
RAM 569472 569472 0 0.0
fabric-admin debug unknown 5600 5600 0 0.0
FLASH 11284247 11284247 0 0.0
RAM 515058 515058 0 0.0
fabric-bridge-app debug unknown 5240 5240 0 0.0
FLASH 4345352 4345352 0 0.0
RAM 208592 208592 0 0.0
lighting-app debug+rpc+ui unknown 5864 5864 0 0.0
FLASH 5362034 5362034 0 0.0
RAM 225136 225136 0 0.0
lock-app debug unknown 5184 5184 0 0.0
FLASH 4539512 4539512 0 0.0
RAM 203968 203968 0 0.0
ota-provider-app debug unknown 4552 4552 0 0.0
FLASH 4175512 4175512 0 0.0
RAM 192928 192928 0 0.0
ota-requestor-app debug unknown 4488 4488 0 0.0
FLASH 4299608 4299608 0 0.0
RAM 197440 197440 0 0.0
shell debug unknown 4112 4112 0 0.0
FLASH 2794637 2794637 0 0.0
RAM 154168 154168 0 0.0
thermostat-no-ble arm64 unknown 9144 9144 0 0.0
FLASH 4148468 4148468 0 0.0
RAM 234344 234344 0 0.0
tv-app debug unknown 5472 5472 0 0.0
FLASH 5585240 5585240 0 0.0
RAM 344600 344600 0 0.0
tv-casting-app debug unknown 5104 5104 0 0.0
FLASH 9565638 9565638 0 0.0
RAM 340016 340016 0 0.0
mbed lock-app-release cy8cproto_062_4343w FLASH 1497092 1497092 0 0.0
RAM 226152 226152 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 872704 872704 0 0.0
RAM 139209 139209 0 0.0
nrf7002dk_nrf5340_cpuapp FLASH 948104 948104 0 0.0
RAM 137637 137637 0 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 FLASH 821608 821608 0 0.0
RAM 138107 138107 0 0.0
nxp contact k32w0+release FLASH 575460 575460 0 0.0
RAM 70112 70112 0 0.0
k32w1+release FLASH 590872 590872 0 0.0
RAM 74144 74144 0 0.0
light k32w0+release FLASH 609360 609360 0 0.0
RAM 69588 69588 0 0.0
k32w1+release FLASH 673656 673656 0 0.0
RAM 82896 82896 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1608876 1608876 0 0.0
RAM 207212 207212 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1533460 1533460 0 0.0
RAM 204116 204116 0 0.0
light cy8ckit_062s2_43012 FLASH 1459820 1459820 0 0.0
RAM 197396 197396 0 0.0
lock cy8ckit_062s2_43012 FLASH 1461948 1461948 0 0.0
RAM 224460 224460 0 0.0
qpg lighting-app qpg6105+debug FLASH 650088 650088 0 0.0
RAM 104644 104644 0 0.0
lock-app qpg6105+debug FLASH 609932 609932 0 0.0
RAM 99320 99320 0 0.0
stm32 light STM32WB5MM-DK FLASH 471412 471412 0 0.0
RAM 141732 141732 0 0.0
telink air-quality-sensor-app tlsr9528a_retention FLASH 624936 624936 0 0.0
RAM 49944 49944 0 0.0
all-clusters-app tlsr9118bdk40d FLASH 599948 599948 0 0.0
RAM 130368 130368 0 0.0
all-clusters-minimal-app tlsr9528a FLASH 769662 769662 0 0.0
RAM 110132 110132 0 0.0
bridge-app tlsr9258a FLASH 668054 668054 0 0.0
RAM 94752 94752 0 0.0
contact-sensor-app tlsr9528a_retention FLASH 626742 626742 0 0.0
RAM 49988 49988 0 0.0
light-switch-app-ota-shell-factory-data tlsr9528a FLASH 713674 713674 0 0.0
RAM 76580 76580 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 558238 558238 0 0.0
RAM 126624 126624 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 793018 793018 0 0.0
RAM 99980 99980 0 0.0
lock-app-dfu tlsr9528a FLASH 659786 659786 0 0.0
RAM 69268 69268 0 0.0
ota-requestor-app tlsr9258a FLASH 686930 686930 0 0.0
RAM 94476 94476 0 0.0
pump-app tlsr9518adk80d FLASH 608866 608866 0 0.0
RAM 56368 56368 0 0.0
pump-controller-app tlsr9518adk80d FLASH 599252 599252 0 0.0
RAM 56168 56168 0 0.0
shell tlsr9518adk80d FLASH 462618 462618 0 0.0
RAM 71852 71852 0 0.0
smoke_co_alarm-app tlsr9528a_retention FLASH 633142 633142 0 0.0
RAM 51616 51616 0 0.0
temperature-measurement-app-mars-ota tlsr9518adk80d FLASH 642852 642852 0 0.0
RAM 59804 59804 0 0.0
thermostat tlsr9518adk80d FLASH 618200 618200 0 0.0
RAM 56492 56492 0 0.0
window-covering tlsr9118bdk40d FLASH 464634 464634 0 0.0
RAM 82272 82272 0 0.0
tizen all-clusters-app arm unknown 1556 1556 0 0.0
FLASH 1609932 1609932 0 0.0
RAM 45452 45452 0 0.0
chip-tool-ubsan arm unknown 2364 2364 0 0.0
FLASH 15626834 15626834 0 0.0
RAM 6822312 6822312 0 0.0

@mergify mergify bot merged commit 88ebdf7 into project-chip:master Jun 6, 2024
68 checks passed
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