-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bryanv/reduce import code #8309
Conversation
cc @mrocklin possibly of interest to you. |
Oooh, I'm very glad to hear it :) This benefit will apply to dask-workers twice, so this is pretty substantial :) (we import bokeh, then spawn a process, then import bokeh again) |
Additionally, in 1.0 Bokeh is switching to "simple ids" by default, i.e. a simple monotonically increasing sequence of integers. This is ~2x improvement in time to generate IDs for models, but since you mention separate processes I will note just for completeness: if you are somehow constructing models for a single document across multiple processes (I very much doubt you or anyone is ever doing this), that's the one scenario where you'd need to set |
e87222d
to
2fcc317
Compare
image report looks good, changes are small and should be uncontroversial so merging now |
* remove docstring formatting and duplication for Figure/figure * use file system loader to avoid pkg_resources * defer expensive imports for sampledata
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This PR claims some low hanging fruit for reducing Bokeh import times:
Don't use
PackageLoader
for loading Bokeh Jinja templates (requiredpkg_resources
import is very expensive)defer non-stdlib imports in sampledata modules (downloading sampledata is rare usage)
reduce some dynamic docstring manipulations
All told this shaves ~200ms off
import bokeh.plotting
on my laptop. The results using:are:
About half of that ~600ms appears to be NumPy and Pandas, which is borne out by this very rough timing:
It's worth noting that 60-70 ms for computing
bokeh.__version__
disappears in real release packages where the version string is hardcoded.We can't do much about the NumPy/Pandas burden, but there are still some things we can do to reduce things on our end later:
bokeh.models
tobokeh._modules
so that individual models can be imported internally without importing everything inbokeh.models.__init__.py
I would estimate ~150ms (relative reference on this laptop) is probably a floor for
import bokeh.plotting