summaryrefslogtreecommitdiff
path: root/gjs
diff options
context:
space:
mode:
authorChristian Hergert <chergert@redhat.com>2019-06-05 16:22:02 -0700
committerChristian Hergert <chergert@redhat.com>2019-06-06 17:29:21 -0700
commit0218b1232da179adf230b5bd09dcfdc2baf7f1d5 (patch)
tree0d1b77f70cf3062da6ea17f86f0432834a241650 /gjs
parent20854ba3c2acd45c3a3083ceee21108659388b6c (diff)
downloadgjs-0218b1232da179adf230b5bd09dcfdc2baf7f1d5.tar.gz
profiler: auto-flush capture writer every 3 seconds
To reduce the amount of data that could be lost in the buffer during a terminating signal scenario, GJS can use the auto-flush feature of SysprofCaptureWriter. Related to GNOME/Initiatives#10
Diffstat (limited to 'gjs')
-rw-r--r--gjs/profiler.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/gjs/profiler.cpp b/gjs/profiler.cpp
index a8522317..c28080ea 100644
--- a/gjs/profiler.cpp
+++ b/gjs/profiler.cpp
@@ -50,6 +50,8 @@
# include <sysprof-capture.h>
#endif
+#define FLUSH_DELAY_SECONDS 3
+
/*
* This is mostly non-exciting code wrapping the builtin Profiler in
* mozjs. In particular, the profiler consumer is required to "bring your
@@ -425,6 +427,11 @@ gjs_profiler_start(GjsProfiler *self)
return;
}
+ /* Automatically flush to be resilient against SIGINT, etc */
+ sysprof_capture_writer_set_flush_delay(self->capture,
+ g_main_context_get_thread_default(),
+ FLUSH_DELAY_SECONDS);
+
if (!gjs_profiler_extract_maps(self)) {
g_warning("Failed to extract proc maps");
g_clear_pointer(&self->capture, sysprof_capture_writer_unref);