Performance of DynamicMap vs Panel (param.Parameterized)

I was displaying a rasterized Trimesh on a tile background and using the Panel approach I am returning an overlay. I added a time slider for displaying the changing ‘z’ values on the Trimesh and the resulting animation flickered the screen as it updated.

I repeated the same with a DynamicMap approach and kept the tiles overlay out of the rasterized DynamicMap and the result was much smoother and faster.

Is this expected or is there a way to do the same in the param.Parameterized class approach that I was using? Or should I combine the two approaches by keeping some controls in the param.Parameterized and using DynamicMap . Advice please. Thanks

The DynamicMap approach is always going to be more optimized than using Panel param support since HoloViews automatically figures out a minimal diff to apply to the plot while Panel+Param generally triggers a full re-render of the plot. You can in fact use the exact syntax for both however, e.g. this is valid (pseudo-code):

@pn.depends('some_parameter')
def some_method(self):
    return some_holoviews_object

tiles * hv.DynamicMap(self.some_method)

So the best approach is to mix and match the two approaches as needed. I’m hoping to add a performance guide to the Panel docs in the near future which will have a section about HoloViews and DynamicMap.

2 Likes

@philippjfr That would be great. Also I see https://panel.holoviz.org/reference/panes/HoloViews.html for customizing DynamicMap widgets and so combining them is probably a best practice.