Skip to content

BokehJS leak a lots style tag in head tag cause a slow performance #10072

@rwayan

Description

@rwayan

I am using this simple code to show this promblem

import panel as pn
import holoviews as hv
import numpy as np
import pandas as pd
import datetime
from streamz.dataframe import DataFrame as sDataFrame



pn.extension()

df = sDataFrame(example=pd.DataFrame({'y': []}, index=pd.DatetimeIndex([])))
def line_plot(data):
    return hv.Table(pd.concat(data[0:10]))
altair_stream = df.cumsum().stream.sliding_window(50).map(line_plot)
def emit():
    df.emit(pd.DataFrame({'y': [np.random.randn()]}, index=pd.DatetimeIndex([datetime.datetime.now()])))

altair_pane = pn.pane.Streamz(altair_stream, height=350, always_watch=True)
altair_pane.add_periodic_callback(emit, period=100)
col = pn.Column(altair_pane)
col.servable()

from the beginning it running very well in normal performance, and then after serveral minutes later
it be come very low performance.

then i saw a lots of tags like

<style type="text/css" rel="stylesheet">.slickgrid_298815 .slick-header-column { left: 1000px; } .slickgrid_298815 .slick-top-panel { height:25px; } .slickgrid_298815 .slick-preheader-panel { height:25px; } .slickgrid_298815 .slick-headerrow-columns { height:25px; } .slickgrid_298815 .slick-footerrow-columns { height:25px; } .slickgrid_298815 .slick-cell { height:20px; } .slickgrid_298815 .slick-row { height:25px; } .slickgrid_298815 .l0 { } .slickgrid_298815 .r0 { } .slickgrid_298815 .l1 { } .slickgrid_298815 .r1 { }</style>

in head tag

it will cause the bad performance.
when I try to delete all of them

for (let i = document.head.children.length - 2 ; i >=0 ; i--) { if (document.head.children[i].attributes[1].name == "rel" && document.head.children[i].attributes[1].value == "stylesheet") {document.head.children[i].remove();}}

the numbers jump become faster

Please Help to fix about this @MarcSkovMadsen @philippjfr @mattpap
when rebuild , the style tag not deleted left in head , cause performance problem.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions