Startup optimization of session for panel server embedded in web app

I have an application originally written as a bokeh server app that is embedded in another web framework (e.g. Flask/gunicorn). This has been successfully refactored into a combined panel/bokeh application which I can also serve through Flask/gunicorn. See Panel Discourse Topic 978.

The purpose of this topic is to seek advice on what possibilities exist to speed up the time it takes to start a client session.

In the pure bokeh solution, the process to add roots to a document D is accomplished as follows. Per the profiling information this takes approx. 0.5s on the server computer.

_ = [D.add_root(r) for r in C.roots]

The corresponding step in the panel/bokeh implementation creates a panel Column from a list of panel viewables and invokes server_doc() on the bokeh document D so that the items are added to the client’s web page. This takes approx. 2s on the same server computer.

pn.Column(*_ll).server_doc(D)

Are there any tips to try to bring these two closer to parity in terms of execution time?

1 Like

Interesting, thanks for reporting this. Could you maybe file an issue? I suspect this is to do with longer import times. We should look at reducing the import time of Panel to bring it to parity with Bokeh.

1 Like

A very basic comparison already reveals the following:

__import__('bokeh')
__import__('bokeh.models')
__import__('bokeh.core.templates')
    500948 function calls (470340 primitive calls) in 0.585 seconds
__import__('panel')
    974795 function calls (933802 primitive calls) in 1.386 seconds

We should aim to get those as close to parity as possible.

1 Like