Skip to content

Improve DataTable performance #8227

@wabu

Description

@wabu

Performance with bokeh models containing data-table widgets is slow when the model gets updated (streaming data to it or changing widgets), adding up to some seconds of delay. When debugging it in the browser, Chromium warns about "Recalculate Style
Warning: Forced reflow is a likely performance bottleneck." (see screenshot below).

bokeh 0. 13.0
python 3.6.6 Anaconda
Chromium 66.0.3359.139
Debian 4.16.5-1
Linux 4.16.0-1-amd64

Here's an example, where adding a button cases the delay, but also had the problem when adding data to a plot with holoviews pipes

import bokeh.io as bki
import bokeh.models as bkm
import bokeh.layouts as bkl

doc = bki.curdoc()

from datetime import date
from random import randint, choice

n = 20
data = dict(
        dates=[date(2014, 3, i%30+1) for i in range(n)],
        downloads=[randint(0, 100) for i in range(n)],
        foo=[randint(0, 100) for i in range(n)],
        bar=[randint(0, 100) for i in range(n)],
        baz=[randint(0, 100) for i in range(n)],
    )
source = bkm.ColumnDataSource(data)

columns = [
        bkm.TableColumn(field="dates", title="Date", formatter=bkm.DateFormatter()),
        bkm.TableColumn(field="downloads", title="Downloads"),
        bkm.TableColumn(field="foo", title="Foo"),
        bkm.TableColumn(field="bar", title="Bar"),
        bkm.TableColumn(field="baz", title="Baz"),
    ]

table1 = bkm.DataTable(source=source, columns=columns[:-1])#, editable=True)
table2 = bkm.DataTable(source=source, columns=columns[1:])#, editable=True)

action = bkm.Button(label="click me")
foo = bkm.Button(label="foo")
box = bkl.widgetbox([action, foo], sizing_mode='scale_width')

def act():
    #last = label = box.children[1].label
    #while label == last:
    label = choice(["foo", "bar", "baz", "bla"])
    foo = bkm.Button(label=label)
    box.children.insert(1, foo)
                    
action.on_click(act)

doc.add_root(bkl.column(box, bkl.widgetbox(table1, table2)))

2018-09-08-112531_1364x719_scrot

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions