AnsweredAssumed Answered

High CPU Utilization during BLE Scan caused by hsdk threads

Question asked by Tony Wang on Nov 20, 2019
Latest reply on Dec 10, 2019 by Mario Ignacio Castaneda Lopez

Hi,
We are running a BLE scanning test process by using hsdk library to communicate with the NXP bluetooth chip to preform BLE scan.
After this test process starts scanning by calling GAPStartScanningRequest function (hsdk-c), it takes full CPU utilization 99% when the number of Bluetooth devices in the test setup is around 1500.
And even we reduce the number of Bluetooth devices to low (less than 100), it still takes around 30%.
Using top command to track:

 

/root # top -p 6131
top - 14:08:00 up 2:11, 2 users, load average: 2.38, 2.52, 2.58
Tasks: 4 total, 1 running, 3 sleeping, 0 stopped, 0 zombie
Cpu(s): 39.2%us, 73.2%sy, 0.0%ni, 90.7%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 830384k total, 691512k used, 138872k free, 0k buffers
Swap: 0k total, 0k used, 0k free, 324160k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
6132 cli 20 0 23636 1256 612 R 78 0.2 0:03.58 DTR                   (DeviceThreadRoutine hsdk/physical/PhysicalDevice.c)
6133 cli 20 0 23636 1256 612 S 20 0.2 0:01.55 FTR                     (FramerThreadRoutine hsdk/protocol/Framer.c)
6131 cli 20 0 23636 1256 612 S 0 0.2 0:00.01 blescantest
6134 cli 20 0 23636 1256 612 S 0 0.2 0:00.00 blescantest

 

From the strace tracking result:
/root # strace -T -r -c -p 6132
Process 6132 attached - interrupt to quit
^CProcess 6132 detached
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
45.13 0.021352 1 30736 poll
34.71 0.016425 1 30736 read
14.98 0.007089 0 30735 write
5.18 0.002450 0 30736 gettimeofday
0.00 0.000000 0 4 futex
------ ----------- ----------- --------- --------- ----------------
100.00 0.047316 122947 total
/root # strace -T -r -c -p 6133
Process 6133 attached - interrupt to quit
^CProcess 6133 detached
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
95.04 0.106040 2 47379 poll
4.96 0.005539 0 47379 read
0.00 0.000000 0 49 write
0.00 0.000000 0 38 mprotect
0.00 0.000000 0 6 futex
------ ----------- ----------- --------- --------- ----------------
100.00 0.111579 94851 total

 

Is there any fix for the problem?

Thanks.
Best regards,
Tony Wang

Outcomes