[gjs: 2/12] context: Add more logging around garbage collection
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 2/12] context: Add more logging around garbage collection
- Date: Tue, 20 Aug 2019 19:23:57 +0000 (UTC)
commit a85de43cc3082ee5d6fe25d5263f546e43e3436c
Author: Philip Chimento <philip chimento gmail com>
Date: Sat Aug 10 11:19:48 2019 -0700
context: Add more logging around garbage collection
These log messages are useful while testing the garbage collection
performance.
See #217.
gjs/context.cpp | 10 +++++++---
gjs/engine.cpp | 6 +++++-
modules/system.cpp | 3 +++
3 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/gjs/context.cpp b/gjs/context.cpp
index d9812728..ae06ed39 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -583,11 +583,12 @@ gboolean GjsContextPrivate::trigger_gc_if_needed(void* data) {
auto* gjs = static_cast<GjsContextPrivate*>(data);
gjs->m_auto_gc_id = 0;
- if (gjs->m_force_gc)
+ if (gjs->m_force_gc) {
+ gjs_debug_lifecycle(GJS_DEBUG_CONTEXT, "Big Hammer hit");
JS_GC(gjs->m_cx);
- else
+ } else {
gjs_gc_if_needed(gjs->m_cx);
-
+ }
gjs->m_force_gc = false;
return G_SOURCE_REMOVE;
@@ -599,6 +600,9 @@ void GjsContextPrivate::schedule_gc_internal(bool force_gc) {
if (m_auto_gc_id > 0)
return;
+ if (force_gc)
+ gjs_debug_lifecycle(GJS_DEBUG_CONTEXT, "Big Hammer scheduled");
+
m_auto_gc_id = g_timeout_add_seconds_full(G_PRIORITY_LOW, 10,
trigger_gc_if_needed, this,
nullptr);
diff --git a/gjs/engine.cpp b/gjs/engine.cpp
index 80c892a8..2b61d98b 100644
--- a/gjs/engine.cpp
+++ b/gjs/engine.cpp
@@ -181,8 +181,12 @@ static void on_garbage_collect(JSContext*, JSGCStatus status, void*) {
* so that we can collect the JS wrapper objects, and in order to minimize
* the chances of objects having a pending toggle up queued when they are
* garbage collected. */
- if (status == JSGC_BEGIN)
+ if (status == JSGC_BEGIN) {
+ gjs_debug_lifecycle(GJS_DEBUG_CONTEXT, "Begin garbage collection");
gjs_object_clear_toggles();
+ } else if (status == JSGC_END) {
+ gjs_debug_lifecycle(GJS_DEBUG_CONTEXT, "End garbage collection");
+ }
}
GJS_JSAPI_RETURN_CONVENTION
diff --git a/modules/system.cpp b/modules/system.cpp
index f748aac2..65494bfa 100644
--- a/modules/system.cpp
+++ b/modules/system.cpp
@@ -143,6 +143,9 @@ gjs_dump_heap(JSContext *cx,
js::DumpHeap(cx, stdout, js::IgnoreNurseryObjects);
}
+ gjs_debug(GJS_DEBUG_CONTEXT, "Heap dumped to %s",
+ filename ? filename.get() : "stdout");
+
args.rval().setUndefined();
return true;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]