python-dbus-next icon indicating copy to clipboard operation
python-dbus-next copied to clipboard

Improve unmarshall performance

Open bdraco opened this issue 1 year ago • 5 comments

This change reduces the overhead of unmarshalling with the goal of having bleak scanners not overwhelming the system.

See related issue: https://github.com/hbldh/bleak/issues/236#issuecomment-789055069

(speed_up_unmarsh) % python3 bench/unmarshall.py
Unmarshalling 1000000 bluetooth rssi messages took 13.497067291998974 seconds
(master) % python3 bench/unmarshall.py
Unmarshalling 1000000 bluetooth rssi messages took 47.7756206660124 seconds

bdraco avatar Aug 03 '22 04:08 bdraco

I've been running this in production for a while.

I get more broken pipe errors with this change.

Either there is a bug or its too fast that the data hasn't come over the wire yet, and since the unmarshall code never waits for data to arrive over the wire if its split between multiple reads it increases the chance it will process it too fast and it won't be there yet.

bdraco avatar Aug 06 '22 20:08 bdraco

I think broke resume with the change

bdraco avatar Aug 06 '22 20:08 bdraco

Added a test for resume

bdraco avatar Aug 06 '22 21:08 bdraco

Spent another couple hours testing this and its all working great with bleak

bdraco avatar Aug 07 '22 00:08 bdraco

Related previous PR https://github.com/altdesktop/python-dbus-next/pull/62

cc @rjarry in case you have any interest based on your previous PR

bdraco avatar Aug 07 '22 20:08 bdraco

Above comments are for the future. I'm speculating on ways to speed it up a bit more, but anything else is going to be a much smaller improvement and can come in a future PR

bdraco avatar Sep 01 '22 16:09 bdraco

You have failing tests. Please rebase against master and run make docker-test to see test failures. I believe CICD build should work now.

acrisci avatar Sep 11 '22 16:09 acrisci

Still looks good

bdraco@Js-MacBook-Pro python-dbus-next % python3 bench/unmarshall.py 
Unmarshalling 1000000 bluetooth rssi messages took 13.812721209134907 seconds

bdraco avatar Sep 11 '22 17:09 bdraco

:+1:

acrisci avatar Sep 11 '22 20:09 acrisci

Thanks. I have a few more I can pull out as well that I'll cleanup and send as soon. I'm traveling this week so its going to depend on how ✈️ goes and jet lag

bdraco avatar Sep 11 '22 20:09 bdraco