I’ve noticed that a dashboard I’ve been building has suffered a drop in performance after updating from 2.2.3 to 2.3 (on my machine, at least).
Specifically I am using the event MouseMove
on an image
to update a line
on an adjacent plot. With 2.2.3 the line ceases to update as soon as I stop moving the mouse, which I interpret to be ‘good’; while with 2.3.0 the line continues to update for a while after I stop (depending on how fast I was moving the mouse) [tested by switching between venvs]. It is possible that the overall update rate is lower in 2.2.3, leading to reduced ‘queuing’, but I don’t have a way to measure that.
A MWE:
import numpy as np
from bokeh.io import curdoc
from bokeh.layouts import column
from bokeh.plotting import figure
from bokeh.events import MouseMove
from bokeh.models import ColumnDataSource
h,w,s = (50,100,200)
np_data = np.random.uniform(size=(h,w,s))
def sample_data(x,y):
xs, ys = np.clip(x,0,w-1).astype(int), np.clip(y,0,h-1).astype(int)
yvals = np_data[ys,xs,:]
return yvals
xvals = np.arange(s)
yvals = sample_data(0,0)
source = ColumnDataSource(data={'a': xvals, 'b': yvals})
def mousemove_callback(event):
yvals = sample_data(event.x, event.y)
source.data = {'a':xvals,'b':yvals}
pimg = figure(plot_width=800, plot_height=400)
pimg.image(image=[np_data[...,0]], x=0, y=0, dw=w, dh=h)
pimg.on_event(MouseMove, mousemove_callback)
pline = figure(plot_width=800, plot_height=300)
pline.line('a', 'b', source=source)
layout = column(pimg, pline)
curdoc().add_root(layout)
I appreciate this isn’t really a good type of interactivity to implement (too fast update rate, throttling etc.), but I am intrigued what is causing this change? My original implementation was in holoviews where the performance change seems even worse with the update (although again I don’t have a way to measure that well).