Downthrottle to 16Hz on multi-feed charts

multichartz
Tyler Goodlet 2023-01-12 10:09:07 -05:00
parent 3b15e76285
commit e1e52e9130
1 changed files with 18 additions and 7 deletions

View File

@ -1058,17 +1058,28 @@ async def display_symbol_data(
display_rate = main_window().current_screen().refreshRate() display_rate = main_window().current_screen().refreshRate()
_quote_throttle_rate = floor(display_rate) - 6 _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 feed: Feed
async with open_feed( async with open_feed(
fqsns, fqsns,
loglevel=loglevel, loglevel=loglevel,
tick_throttle=cycles_per_feed,
# 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
),
) as feed: ) as feed: