qlog_size: decimate rlog option (#33011)

* decimate option

* clean up

* check exists
pull/32997/head^2
Shane Smiskol 9 months ago committed by GitHub
parent 3c48a6154b
commit f31ad97e92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 21
      selfdrive/debug/internal/qlog_size.py

@ -5,6 +5,7 @@ from collections import defaultdict
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from cereal.services import SERVICE_LIST
from openpilot.tools.lib.logreader import LogReader from openpilot.tools.lib.logreader import LogReader
from tqdm import tqdm from tqdm import tqdm
@ -48,9 +49,29 @@ def make_pie(msgs, typ):
if __name__ == "__main__": if __name__ == "__main__":
parser = argparse.ArgumentParser(description='View log size breakdown by message type') parser = argparse.ArgumentParser(description='View log size breakdown by message type')
parser.add_argument('route', help='route to use') parser.add_argument('route', help='route to use')
parser.add_argument('--as-qlog', action='store_true', help='decimate rlog using latest decimation factors')
args = parser.parse_args() args = parser.parse_args()
msgs = list(LogReader(args.route)) msgs = list(LogReader(args.route))
if args.as_qlog:
new_msgs = []
msg_cnts: dict[str, int] = defaultdict(int)
for msg in msgs:
msg_which = msg.which()
if msg.which() in ("initData", "sentinel"):
new_msgs.append(msg)
continue
if msg_which not in SERVICE_LIST:
continue
decimation = SERVICE_LIST[msg_which].decimation
if decimation is not None and msg_cnts[msg_which] % decimation == 0:
new_msgs.append(msg)
msg_cnts[msg_which] += 1
msgs = new_msgs
make_pie(msgs, 'qlog') make_pie(msgs, 'qlog')
plt.show() plt.show()

Loading…
Cancel
Save