Repository navigation
Speed up unpacking incoming packet data - #1076
Conversation
use struct.Struct to avoid building the unpacks each call
use struct.Struct to avoid building the unpacks each call
Codecov Report
@@ Coverage Diff @@
## master #1076 +/- ##
=======================================
Coverage 99.92% 99.92%
=======================================
Files 23 23
Lines 2557 2559 +2
Branches 477 477
=======================================
+ Hits 2555 2557 +2
Misses 1 1
Partials 1 1
Continue to review full report at Codecov.
|
|
The 3 unsigned short reads in SRV could be a single unpack call |
|
This reduced parsing by ~19% overall. |
|
This worked out to a 21% speed up overnight, but were still 7.3 million calls to |
|
I don't see any other opportunities to improve this. Python 3.11 is really going to be the solution here since its showing almost a 45% speed up in this area. |
https://build.opensuse.org/request/show/985062 by user 1Antoine1 + dimstar_suse - Ignore flakey test (gh#python-zeroconf/python-zeroconf#1077). - update to 0.38.7: * Performance improvements for parsing incoming packet data (gh#python-zeroconf/python-zeroconf#1076).
use
struct.Structto avoid building the unpacks each call as it saves a non-trivial amount of work especially with small values.This makes the most difference if the rest of the program is doing > 100 different unpacks since it will avoid the case were the cache is exhausted
https://github.com/python/cpython/blob/f9585e2adc36fb2886f96ef86a5aa14215fc1151/Modules/_struct.c#L2103