adafruit / adafruit/Adafruit_CircuitPython_BLE

High CPU usage with BLEUART

Open
#109 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
138
Forks
58
PR merge metrics
No merged PRs in 30d

Description

There is high CPU usage observed when reading bytes from BLEUART connection. With modified (bigger) buffer size in `adafruit_ble/services/nordic.py`, if I read 180 bytes of BLE buffer in about 50 times per second, that uses the total CPU about 20%-25% with RaspberryPi4. RPi4 has 4 cores so that means it uses the single core about 80% to 100% percent.

Current configuration:
```
Raspberry Pi OS: 5.4.72-v7l+
Adafruit_CircuitPython_BLE: 7.3.1
Adafruit_Blinka_bleio: 2.0.4
Bluez: 5.50-1.2~deb10u1+rpt2
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading the BLEUART implementation and the buffer handling in adafruit_ble/services/nordic.py. Reproduce the reported workload on a Raspberry Pi 4: read 180 bytes about 50 times per second with the larger buffer, then measure CPU usage. Done means identifying the source of the excessive CPU use and confirming lower usage under the same workload.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, python, raspberry-pi
Domain
embedded-iot, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.