Ensure full hist OHLC path is drawn on tread

Since we removed the `Viz.update_graphics()` call from the main rt loop
we have to be sure to call it in the history chart incr-loop to avoid
a gap between the  last bar and prior history since startup. We only
need to update on tread since that should be the only time a full redraw
is ever necessary, ow only the last datum is needed.

Further this moves the graphics cycle func's profiler init to the top in
an effort to get more correct latency measures.
overlays_interaction_latency_tuning
Tyler Goodlet 2023-01-17 13:54:32 -05:00
parent 4003729231
commit 60440bc6b7
1 changed files with 22 additions and 17 deletions

View File

@ -140,6 +140,7 @@ class DisplayState(Struct):
Chart-local real-time graphics state container.
'''
fqsn: str
godwidget: GodWidget
quotes: dict[str, Any]
@ -225,16 +226,19 @@ async def increment_history_view(
is_1m=True,
)
# check if tread-in-place view x-shift is needed
if should_tread:
# ensure path graphics append is shown on treads since
# the main rt loop does not call this.
hist_viz.update_graphics()
hist_chart.increment_view(datums=append_diff)
if (
do_px_step
and liv
):
hist_viz.plot.vb._set_yrange(viz=hist_viz)
# check if tread-in-place x-shift is needed
if should_tread:
hist_chart.increment_view(datums=append_diff)
async def graphics_update_loop(
@ -348,6 +352,7 @@ async def graphics_update_loop(
last_quote_s = time.time()
dss[fqsn] = ds = linked.display_state = DisplayState(**{
'fqsn': fqsn,
'godwidget': godwidget,
'quotes': {},
'maxmin': maxmin,
@ -456,6 +461,13 @@ def graphics_update_cycle(
) -> None:
profiler = Profiler(
msg=f'Graphics loop cycle for: `{ds.fqsn}`',
delayed=True,
disabled=not pg_profile_enabled(),
ms_threshold=ms_slower_then,
)
# TODO: SPEEDing this all up..
# - optimize this whole graphics stack with ``numba`` hopefully
# or at least a little `mypyc` B)
@ -468,17 +480,10 @@ def graphics_update_cycle(
flume = ds.flume
sym = flume.symbol
fqsn = sym.fqsn
main_viz = chart._vizs[fqsn]
hist_viz = hist_chart._vizs[fqsn]
main_viz = ds.viz
hist_viz = ds.hist_viz
index_field = main_viz.index_field
profiler = Profiler(
msg=f'Graphics loop cycle for: `{chart.name}`',
delayed=True,
disabled=not pg_profile_enabled(),
ms_threshold=ms_slower_then,
)
# unpack multi-referenced components
vlm_chart = ds.vlm_chart
@ -528,7 +533,7 @@ def graphics_update_cycle(
else:
main_viz.draw_last(
array_key=fqsn,
only_last_uppx=True,
# only_last_uppx=True,
)
# don't real-time "shift" the curve to the
@ -829,6 +834,8 @@ def graphics_update_cycle(
# graphic for all vizs
viz.draw_last(array_key=curve_name)
profiler.finish()
async def link_views_with_region(
rt_chart: ChartPlotWidget,
@ -1255,9 +1262,7 @@ async def display_symbol_data(
# ensure the last datum graphic is generated
# for zoom-interaction purposes.
viz.draw_last(
array_key=fqsn,
)
viz.draw_last(array_key=fqsn)
hist_pi.vb.maxmin = partial(
hist_chart.maxmin,