Skip to content

Commit

Permalink
qlog_size: decimate rlog option (commaai#33011)
Browse files Browse the repository at this point in the history
* decimate option

* clean up

* check exists
  • Loading branch information
sshane authored Jul 18, 2024
1 parent 3c48a61 commit f31ad97
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions selfdrive/debug/internal/qlog_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import matplotlib.pyplot as plt

from cereal.services import SERVICE_LIST
from openpilot.tools.lib.logreader import LogReader
from tqdm import tqdm

Expand Down Expand Up @@ -48,9 +49,29 @@ def make_pie(msgs, typ):
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='View log size breakdown by message type')
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()

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')
plt.show()

0 comments on commit f31ad97

Please sign in to comment.