fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/40044?usp=email )
Change subject: trx_toolkit/burst_fwd: Use 'is' instead of '==' when checking if trx is src_trx
......................................................................
trx_toolkit/burst_fwd: Use 'is' instead of '==' when checking if trx is src_trx
In python `a is b` is just a pointer comparison of locations of objects
a and b, while `a == b` can involve doing arbitrary code invoking __eq__
and is generally slower even without __eq__ defined:
In [1]: class A:
...: pass
...:
In [2]: a = A()
In [4]: b = A()
In [5]: a == a
Out[5]: True
In [6]: a == b
Out[6]: False
In [7]: a is a
Out[7]: True
In [8]: a is b
Out[8]: False
In [9]: %timeit a is a
84.2 ns ± 0.133 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)
In [10]: %timeit a is b
87.5 ns ± 0.0736 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)
In [11]: %timeit a == a
100 ns ± 0.659 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)
In [12]: %timeit a == b
116 ns ± 0.399 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)
BurstForwarder.forward_msg is one of the hottest places, as e.g. for every
received packet from BTS it forwards it to multiple Ms receivers. It
makes sense to be careful and save cycles here.
Change-Id: Ic9e16720daeb348b5f9c535c24a682db53a93529
---
M src/target/trx_toolkit/burst_fwd.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
laforge: Looks good to me, but someone else must approve
Jenkins Builder: Verified
fixeria: Looks good to me, approved
diff --git a/src/target/trx_toolkit/burst_fwd.py b/src/target/trx_toolkit/burst_fwd.py
index 6924531..e3da9c2 100644
--- a/src/target/trx_toolkit/burst_fwd.py
+++ b/src/target/trx_toolkit/burst_fwd.py
@@ -52,7 +52,7 @@
# Iterate over all known transceivers
for trx in self.trx_list:
- if trx == src_trx:
+ if trx is src_trx:
continue
# Check transceiver state
--
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/40044?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: Ic9e16720daeb348b5f9c535c24a682db53a93529
Gerrit-Change-Number: 40044
Gerrit-PatchSet: 2
Gerrit-Owner: kirr <kirr(a)nexedi.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: osmith <osmith(a)sysmocom.de>
Gerrit-CC: pespin <pespin(a)sysmocom.de>
fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/40045?usp=email )
Change subject: trx_toolkit/*: Don't use `del x; x = None` idiom
......................................................................
trx_toolkit/*: Don't use `del x; x = None` idiom
In Python it is enough to do `x = None` to release the object that was
pointed to by x previously. So at Python level doing this extra
del only spends more CPU time, but when we will switch to Cython, and
e.g. Msg.burst will be a C-level attribute, the following will not work
at all
del msg.burst
msg.burst = None
because at runtime it will complain that
del msg.burst
AttributeError: 'Msg' object has no attribute 'burst' and no __dict__ for setting new attributes
-> Remove unneeded del to save some time and avoid problems with upcoming switch to Cython.
Change-Id: I7a83bdd52fb9318bd8b975f85ce37c7144873f61
---
M src/target/trx_toolkit/burst_fwd.py
M src/target/trx_toolkit/clck_gen.py
M src/target/trx_toolkit/fake_trx.py
3 files changed, 2 insertions(+), 5 deletions(-)
Approvals:
fixeria: Looks good to me, approved; Verified
laforge: Looks good to me, but someone else must approve
diff --git a/src/target/trx_toolkit/burst_fwd.py b/src/target/trx_toolkit/burst_fwd.py
index e3da9c2..2824e0a 100644
--- a/src/target/trx_toolkit/burst_fwd.py
+++ b/src/target/trx_toolkit/burst_fwd.py
@@ -47,8 +47,7 @@
tx_freq = src_trx.get_tx_freq(rx_msg.fn)
if src_trx.rf_muted:
- del rx_msg.burst # burst bits are omited
- rx_msg.burst = None
+ rx_msg.burst = None # burst bits are omited
# Iterate over all known transceivers
for trx in self.trx_list:
diff --git a/src/target/trx_toolkit/clck_gen.py b/src/target/trx_toolkit/clck_gen.py
index ae7a899..f769c3e 100755
--- a/src/target/trx_toolkit/clck_gen.py
+++ b/src/target/trx_toolkit/clck_gen.py
@@ -82,7 +82,6 @@
self._thread.join()
# Free memory, reset breaker
- del self._thread
self._thread = None
self._breaker.clear()
diff --git a/src/target/trx_toolkit/fake_trx.py b/src/target/trx_toolkit/fake_trx.py
index 8f187ac..711ad21 100755
--- a/src/target/trx_toolkit/fake_trx.py
+++ b/src/target/trx_toolkit/fake_trx.py
@@ -226,8 +226,7 @@
return
# Since TRXDv1, we should send a NOPE.ind
- del msg.burst # burst bits are omited
- msg.burst = None
+ msg.burst = None # burst bits are omited
# TODO: shoud we make these values configurable?
msg.toa256 = self.TOA256_NOISE_DEFAULT
--
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/40045?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: I7a83bdd52fb9318bd8b975f85ce37c7144873f61
Gerrit-Change-Number: 40045
Gerrit-PatchSet: 2
Gerrit-Owner: kirr <kirr(a)nexedi.com>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: osmith <osmith(a)sysmocom.de>
Gerrit-CC: pespin <pespin(a)sysmocom.de>
fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/40046?usp=email )
Change subject: trx_toolkit/udp_link: Factor code to describe remote into .desc_remote() function
......................................................................
trx_toolkit/udp_link: Factor code to describe remote into .desc_remote() function
And use that utility everywhere where remote of UDPLink is logged.
The reason we are doing this is that with upcoming switch to Cython the
way remote address is stored will change to `struct sockaddr_in` and
instead of updating all users, we will need to only change
UDPLink.desc_remote() in one place.
Add .desc_local() for symmetry.
Change-Id: I1e2fa560ada7a8de4c9b9150058c2a1c73874fbe
---
M src/target/trx_toolkit/data_if.py
M src/target/trx_toolkit/udp_link.py
2 files changed, 9 insertions(+), 5 deletions(-)
Approvals:
fixeria: Looks good to me, approved
Jenkins Builder: Verified
laforge: Looks good to me, but someone else must approve
diff --git a/src/target/trx_toolkit/data_if.py b/src/target/trx_toolkit/data_if.py
index 5bc243f..f59ca17 100644
--- a/src/target/trx_toolkit/data_if.py
+++ b/src/target/trx_toolkit/data_if.py
@@ -70,7 +70,7 @@
msg.parse_msg(data)
except:
log.error("Failed to parse a TRXD Tx message "
- "from R:%s:%u" % (self.remote_addr, self.remote_port))
+ "from R:%s" % self.desc_remote())
return None
# Make sure the header version matches
@@ -90,7 +90,7 @@
msg.parse_msg(bytearray(data))
except:
log.error("Failed to parse a TRXD Rx message "
- "from R:%s:%u" % (self.remote_addr, self.remote_port))
+ "from R:%s" % self.desc_remote())
return None
# Make sure the header version matches
diff --git a/src/target/trx_toolkit/udp_link.py b/src/target/trx_toolkit/udp_link.py
index f0a8224..8690109 100644
--- a/src/target/trx_toolkit/udp_link.py
+++ b/src/target/trx_toolkit/udp_link.py
@@ -34,11 +34,15 @@
def __del__(self):
self.sock.close()
- def desc_link(self):
+ def desc_local(self):
(bind_addr, bind_port) = self.sock.getsockname()
+ return "%s:%u" % (bind_addr, bind_port)
- return "L:%s:%u <-> R:%s:%u" \
- % (bind_addr, bind_port, self.remote_addr, self.remote_port)
+ def desc_remote(self):
+ return "%s:%u" % (self.remote_addr, self.remote_port)
+
+ def desc_link(self):
+ return "L:%s <-> R:%s" % (self.desc_local(), self.desc_remote())
def send(self, data):
self.sendto(data, (self.remote_addr, self.remote_port))
--
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/40046?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: I1e2fa560ada7a8de4c9b9150058c2a1c73874fbe
Gerrit-Change-Number: 40046
Gerrit-PatchSet: 2
Gerrit-Owner: kirr <kirr(a)nexedi.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: osmith <osmith(a)sysmocom.de>
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Attention is currently required from: pespin.
osmith has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-remsim/+/41947?usp=email )
Change subject: rspro_server.c: Fix missing include for inet_ntoa()
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/41947?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: I49352bcc2b8e418e17453809354382bd37eb838e
Gerrit-Change-Number: 41947
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Mon, 26 Jan 2026 13:23:06 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-remsim/+/41947?usp=email )
Change subject: rspro_server.c: Fix missing include for inet_ntoa()
......................................................................
rspro_server.c: Fix missing include for inet_ntoa()
This file was calling inet_ntoa() without including arpa/inet.h, which
is the header defining the function according to man and posix
documentation.
Change-Id: I49352bcc2b8e418e17453809354382bd37eb838e
---
M src/server/rspro_server.c
1 file changed, 1 insertion(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-remsim refs/changes/47/41947/1
diff --git a/src/server/rspro_server.c b/src/server/rspro_server.c
index 1cc1af1..4e3666c 100644
--- a/src/server/rspro_server.c
+++ b/src/server/rspro_server.c
@@ -3,6 +3,7 @@
#include <unistd.h>
#include <pthread.h>
#include <errno.h>
+#include <arpa/inet.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/select.h>
--
To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/41947?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: I49352bcc2b8e418e17453809354382bd37eb838e
Gerrit-Change-Number: 41947
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>