kirr uploaded patch set #2 to this change.

View Change

The following approvals got outdated and were removed: Code-Review+1 by pespin

trx_toolkit/*: Represent bursts as arrays instead of lists

Continuing fake_trx profiling story I noticed that on rx path a
noticeable time is spent in converting from ubits to sbits via list
comprehensions. By changing burst representation from py list, which
stores each item as full python object, to an array, which stores each
item as just byte, and by leveraging bytearray.translate, we can speed
up that conversion by ~ 10x:

before:

In [1]: from data_msg import Msg

In [2]: burst = [0, 1] * (142//2)

In [3]: burst
Out[3]:
[0,
1,
0,
1,
0,
...
0,
1]

In [4]: Msg.ubit2sbit(burst)
Out[4]:
[127,
-127,
127,
-127,
...
127,
-127]

In [5]: %timeit Msg.ubit2sbit(burst)
3.01 µs ± 43.3 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)

after:

In [2]: burst = bytearray([0, 1] * (142//2))

In [3]: burst
Out[3]: bytearray(b'\x00\x01\x00\x01...\x00\x01')

In [4]: Msg.ubit2sbit(burst)
Out[4]: array('b', [127, -127, 127, -127, ... 127, -127])

In [5]: %timeit Msg.ubit2sbit(burst)
325 ns ± 12.1 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)

Change-Id: I7314e9e79752e06fa86b9e346a9beacc5e59579e
---
M src/target/trx_toolkit/data_msg.py
M src/target/trx_toolkit/gsm_shared.py
M src/target/trx_toolkit/rand_burst_gen.py
M src/target/trx_toolkit/test_data_msg.py
4 files changed, 36 insertions(+), 25 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/36/39536/2

To view, visit change 39536. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newpatchset
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: I7314e9e79752e06fa86b9e346a9beacc5e59579e
Gerrit-Change-Number: 39536
Gerrit-PatchSet: 2
Gerrit-Owner: kirr <kirr@nexedi.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: fixeria <vyanitskiy@sysmocom.de>
Gerrit-CC: osmith <osmith@sysmocom.de>
Gerrit-CC: pespin <pespin@sysmocom.de>