compositor: Allow disabling default flight recorders

Add a command line option to disable the default flight recorders
so we can save a little bit of CPU and memory on systems where
this isn't necessary.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
dev
Derek Foreman 3 years ago committed by Marius Vlad
parent 56958aa6e9
commit 60ab03640a
  1. 28
      compositor/main.c
  2. 3
      man/weston.man

@ -69,6 +69,7 @@
#define WINDOW_TITLE "Weston Compositor" #define WINDOW_TITLE "Weston Compositor"
/* flight recorder size (in bytes) */ /* flight recorder size (in bytes) */
#define DEFAULT_FLIGHT_REC_SIZE (5 * 1024 * 1024) #define DEFAULT_FLIGHT_REC_SIZE (5 * 1024 * 1024)
#define DEFAULT_FLIGHT_REC_SCOPES "log,drm-backend"
struct wet_output_config { struct wet_output_config {
int width; int width;
@ -3197,18 +3198,13 @@ weston_log_subscribe_to_scopes(struct weston_log_context *log_ctx,
const char *log_scopes, const char *log_scopes,
const char *flight_rec_scopes) const char *flight_rec_scopes)
{ {
if (log_scopes) if (logger && log_scopes)
weston_log_setup_scopes(log_ctx, logger, log_scopes); weston_log_setup_scopes(log_ctx, logger, log_scopes);
else else
weston_log_subscribe(log_ctx, logger, "log"); weston_log_subscribe(log_ctx, logger, "log");
if (flight_rec_scopes) { if (flight_rec && flight_rec_scopes)
weston_log_setup_scopes(log_ctx, flight_rec, flight_rec_scopes); weston_log_setup_scopes(log_ctx, flight_rec, flight_rec_scopes);
} else {
/* by default subscribe to 'log', and 'drm-backend' */
weston_log_subscribe(log_ctx, flight_rec, "log");
weston_log_subscribe(log_ctx, flight_rec, "drm-backend");
}
} }
WL_EXPORT int WL_EXPORT int
@ -3305,7 +3301,12 @@ wet_main(int argc, char *argv[], const struct weston_testsuite_data *test_data)
weston_log_set_handler(vlog, vlog_continue); weston_log_set_handler(vlog, vlog_continue);
logger = weston_log_subscriber_create_log(weston_logfile); logger = weston_log_subscriber_create_log(weston_logfile);
flight_rec = weston_log_subscriber_create_flight_rec(DEFAULT_FLIGHT_REC_SIZE);
if (!flight_rec_scopes)
flight_rec_scopes = DEFAULT_FLIGHT_REC_SCOPES;
if (flight_rec_scopes && strlen(flight_rec_scopes) > 0)
flight_rec = weston_log_subscriber_create_flight_rec(DEFAULT_FLIGHT_REC_SIZE);
weston_log_subscribe_to_scopes(log_ctx, logger, flight_rec, weston_log_subscribe_to_scopes(log_ctx, logger, flight_rec,
log_scopes, flight_rec_scopes); log_scopes, flight_rec_scopes);
@ -3320,6 +3321,7 @@ wet_main(int argc, char *argv[], const struct weston_testsuite_data *test_data)
free(cmdline); free(cmdline);
log_uname(); log_uname();
weston_log("Flight recorder: %s\n", flight_rec ? "enabled" : "disabled");
verify_xdg_runtime_dir(); verify_xdg_runtime_dir();
display = wl_display_create(); display = wl_display_create();
@ -3393,9 +3395,10 @@ wet_main(int argc, char *argv[], const struct weston_testsuite_data *test_data)
if (debug_protocol) if (debug_protocol)
weston_compositor_enable_debug_protocol(wet.compositor); weston_compositor_enable_debug_protocol(wet.compositor);
weston_compositor_add_debug_binding(wet.compositor, KEY_D, if (flight_rec)
flight_rec_key_binding_handler, weston_compositor_add_debug_binding(wet.compositor, KEY_D,
flight_rec); flight_rec_key_binding_handler,
flight_rec);
if (weston_compositor_init_config(wet.compositor, config) < 0) if (weston_compositor_init_config(wet.compositor, config) < 0)
goto out; goto out;
@ -3534,7 +3537,8 @@ out_display:
weston_log_scope_destroy(log_scope); weston_log_scope_destroy(log_scope);
log_scope = NULL; log_scope = NULL;
weston_log_subscriber_destroy(logger); weston_log_subscriber_destroy(logger);
weston_log_subscriber_destroy(flight_rec); if (flight_rec)
weston_log_subscriber_destroy(flight_rec);
weston_log_ctx_destroy(log_ctx); weston_log_ctx_destroy(log_ctx);
weston_log_file_close(); weston_log_file_close();

@ -157,7 +157,8 @@ start-up code.
Specify to which scopes should subscribe to. Useful to control which streams to Specify to which scopes should subscribe to. Useful to control which streams to
write data into the flight recorder. Flight recorder has limited space, once write data into the flight recorder. Flight recorder has limited space, once
the flight recorder is full new data will overwrite the old data. Without any the flight recorder is full new data will overwrite the old data. Without any
scopes specified, it subscribes to 'log' and 'drm-backend' scopes. scopes specified, it subscribes to 'log' and 'drm-backend' scopes. Passing
an empty value would disable the flight recorder entirely.
.TP .TP
.BR \-\-version .BR \-\-version
Print the program version. Print the program version.

Loading…
Cancel
Save