[S] Change in osmocom-bb[master]: trx_toolkit/data_msg: Disable cyclic GC support for RxMsg
kirr has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/40085?usp=email ) Change subject: trx_toolkit/data_msg: Disable cyclic GC support for RxMsg ...................................................................... trx_toolkit/data_msg: Disable cyclic GC support for RxMsg Checking profiling turned out that there are frequent PyObject_GC_Track/PyObject_GC_UnTrack for RxMsg because BurstForwarder creates RxMsg often: to forward on received TxMsg burst to N destinations - N RxMsg instances are currently created. Investigating generated data_msg.c code shows that neither Msg, nor TxMsg have Py_TPFLAGS_HAVE_GC flag set, but RxMsg does have it set and does have generated .tp_traverse and .tp_clear routines. Investigating a bit more turns our that if we exclude `array.array burst` from RxMsg definition, all those cyclic-GC related things go away from generated code. So somehow Cython thinks that array.array can have a back pointer to RxMsg and emits GC supporting code due to that. But that is not possible to have a back-pointer from array.array to RxMsg: the only object that array.array references is arraydescr object: https://github.com/cython/cython/blob/e22e99e9/Cython/Includes/cpython/array... which is plain C struct inside and does not reference other objects at all: https://github.com/cython/cython/blob/e22e99e9/Cython/Includes/cpython/array... -> So disable cyclic-GC support for RxMsg to avoid associated overhead. Do so for TxMsg and Msg explicitly for symmetry as well. Change-Id: I2c592cec4931db04c29cadfeb97ce5325295d862 --- M src/target/trx_toolkit/data_msg.pxd M src/target/trx_toolkit/data_msg.pyx 2 files changed, 8 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/85/40085/1 diff --git a/src/target/trx_toolkit/data_msg.pxd b/src/target/trx_toolkit/data_msg.pxd index e0acbda..2eb6ed3 100644 --- a/src/target/trx_toolkit/data_msg.pxd +++ b/src/target/trx_toolkit/data_msg.pxd @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # cython: language_level=3 -from cython cimport final +from cython cimport final, no_gc # NOTE no_gc means "no cyclic gc", acyclic gc support is still there from cpython cimport array from libc.stdint cimport int8_t, int64_t, uint8_t @@ -19,6 +19,7 @@ cdef Modulation ModGMSK +@no_gc cdef class Msg: cdef readonly int ver cdef readonly int64_t fn # -1 if not valid @@ -58,6 +59,7 @@ @final +@no_gc cdef class TxMsg(Msg): cdef public bytearray burst # | None cdef readonly int pwr # -1 if unset @@ -67,6 +69,7 @@ @final +@no_gc # NOTE by default cython thinks that .burst might participate in cycle cdef class RxMsg(Msg): cdef public array.array burst # array.array[b] | None diff --git a/src/target/trx_toolkit/data_msg.pyx b/src/target/trx_toolkit/data_msg.pyx index 1e786c1..304dbdb 100644 --- a/src/target/trx_toolkit/data_msg.pyx +++ b/src/target/trx_toolkit/data_msg.pyx @@ -19,7 +19,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -from cython cimport final +from cython cimport final, no_gc from libc.stdint cimport int16_t, int64_t, uint16_t, uint32_t from cpython cimport array @@ -79,6 +79,7 @@ cdef int KNOWN_VERSION_MAX = 1 # 0, 1 +@no_gc cdef class Msg: ''' TRXD (DATA) message coding API (common part). ''' @@ -318,6 +319,7 @@ cdef int PWR_MAX = 0xff @final +@no_gc cdef class TxMsg(Msg): ''' Tx (L1 -> TRX) message coding API. ''' @@ -473,6 +475,7 @@ @final +@no_gc cdef class RxMsg(Msg): ''' Rx (TRX -> L1) message coding API. ''' -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/40085?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: I2c592cec4931db04c29cadfeb97ce5325295d862 Gerrit-Change-Number: 40085 Gerrit-PatchSet: 1 Gerrit-Owner: kirr <kirr@nexedi.com> Gerrit-CC: fixeria <vyanitskiy@sysmocom.de> Gerrit-CC: osmith <osmith@sysmocom.de> Gerrit-CC: pespin <pespin@sysmocom.de>
participants (1)
-
kirr