bencher.bench_plot_server
A server for display plots of benchmark results
Attributes
Classes
A Tornado static file handler that adds CORS headers. |
|
A server for display plots of benchmark results |
Module Contents
- bencher.bench_plot_server._PORT_RANGE_MIN = 49152
- bencher.bench_plot_server._PORT_RANGE_MAX = 65535
- bencher.bench_plot_server._PORT_PROBE_ATTEMPTS = 100
- class bencher.bench_plot_server._CorsStaticHandler(application: Application, request: tornado.httputil.HTTPServerRequest, **kwargs: Any)
Bases:
tornado.web.StaticFileHandlerA Tornado static file handler that adds CORS headers.
Required for rerun integration: the rerun web viewer fetches .rrd files from the Panel server. Without Access-Control-Allow-Origin and OPTIONS preflight handling the browser silently blocks the cross-origin fetch and the viewer shows 0 B.
Note:
Allow-Origin: *is appropriate here because this server is intended for local development only, not public-facing deployments.- data_received(chunk)
Implement this method to handle streamed request data.
Requires the .stream_request_body decorator.
May be a coroutine for flow control.
- set_default_headers()
Override this to set HTTP headers at the beginning of the request.
For example, this is the place to set a custom
Serverheader. Note that setting such headers in the normal flow of request processing may not do what you want, since headers may be reset during error handling.
- options(*_args)
- class bencher.bench_plot_server.BenchPlotServer
A server for display plots of benchmark results
- plot_server(bench_name: str, plot_cfg: bencher.bench_cfg.BenchPlotSrvCfg | None = None, plots_instance=None) threading.Thread
Load previously calculated benchmark data from the database and start a plot server to display it
- Parameters:
bench_name (str) – The name of the benchmark and output folder for the figures
plot_cfg (BenchPlotSrvCfg, optional) – Options for the plot server. Defaults to None.
- Raises:
FileNotFoundError – No data found was found in the database to plot
- load_data_from_cache(bench_name: str) tuple[bencher.bench_cfg.BenchCfg, list[panel.panel]] | None
Load previously calculated benchmark data from the database and start a plot server to display it
- Parameters:
bench_name (str) – The name of the benchmark and output folder for the figures
- Returns:
benchmark result data and any additional panels
- Return type:
tuple[BenchCfg, list[pn.panel]] | None
- Raises:
FileNotFoundError – No data found was found in the database to plot
- static _find_free_port() int
Find a free port by testing random ports in the dynamic/private range.
Using
port=0with Tornado/Bokeh can fail on some Linux kernels (notably 6.x) because the kernel deterministically assigns the same ephemeral port, causingEADDRINUSEwhen a previous server is still running. Picking a random port from the IANA dynamic range avoids this.Note: there is an inherent TOCTOU race between probing the port here and the actual
bind()inside Panel/Bokeh. In practice the window is very small and the random selection makes collisions unlikely, but callers should be prepared for a rareOSErroron server start.
- serve(bench_name: str, plots_instance: list[panel.panel], port: int | None = None, show: bool = True) threading.Thread
Launch a panel server to view results
- Parameters:
bench_cfg (BenchCfg) – benchmark results
plots_instance (list[pn.panel]) – list of panel objects to display
port (int) – use a fixed port to launch the server
- static _rrd_extra_patterns() list
Return Tornado route patterns for serving .rrd files with CORS headers.
Mounts
cachedir/rrd/at/rrd_static/so that the local rerun viewer can fetch.rrdfiles from the Panel server. See the module docstring inutils_rerun.pyfor the full architecture explanation.