From e1e52e91305c7744ec68ac628addfde68d46bc90 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 12 Jan 2023 10:09:07 -0500 Subject: [PATCH] Downthrottle to 16Hz on multi-feed charts --- piker/ui/_display.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/piker/ui/_display.py b/piker/ui/_display.py index b2df5108..1d962b78 100644 --- a/piker/ui/_display.py +++ b/piker/ui/_display.py @@ -1058,17 +1058,28 @@ async def display_symbol_data( display_rate = main_window().current_screen().refreshRate() _quote_throttle_rate = floor(display_rate) - 6 + # TODO: we should be able to increase this if we use some + # `mypyc` speedups elsewhere? 22ish seems to be the sweet + # spot for single-feed chart. + num_of_feeds = len(fqsns) + mx: int = 22 + if num_of_feeds > 1: + # there will be more ctx switches with more than 1 feed so we + # max throttle down a bit more. + mx = 16 + + # limit to at least display's FPS + # avoiding needless Qt-in-guest-mode context switches + cycles_per_feed = min( + round(_quote_throttle_rate/num_of_feeds), + mx, + ) + feed: Feed async with open_feed( fqsns, loglevel=loglevel, - - # limit to at least display's FPS - # avoiding needless Qt-in-guest-mode context switches - tick_throttle=min( - round(_quote_throttle_rate/len(fqsns)), - 22, # aka 6 + 16 - ), + tick_throttle=cycles_per_feed, ) as feed: