diff options
author | Andreas Kling <kling@serenityos.org> | 2021-08-11 20:31:11 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-12 00:03:39 +0200 |
commit | 56e84a63cad9f4531ac110e6553f71ea4553d1b3 (patch) | |
tree | d1ba372b01360def3f2f4414298b73c09daa51b2 | |
parent | 3ed6c137df73b816216472834f4836d290df6c6a (diff) | |
download | serenity-56e84a63cad9f4531ac110e6553f71ea4553d1b3.zip |
LibJS: Emit a profile signpost when starting a garbage collection
-rw-r--r-- | Userland/Libraries/LibJS/Heap/Heap.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Heap/Heap.cpp b/Userland/Libraries/LibJS/Heap/Heap.cpp index a233864ef7..aee2ea837f 100644 --- a/Userland/Libraries/LibJS/Heap/Heap.cpp +++ b/Userland/Libraries/LibJS/Heap/Heap.cpp @@ -19,11 +19,24 @@ #include <LibJS/Runtime/WeakContainer.h> #include <setjmp.h> +#ifdef __serenity__ +# include <serenity.h> +#endif + namespace JS { +#ifdef __serenity__ +static constexpr FlatPtr gc_perf_string_id = 0x13378086; +#endif + Heap::Heap(VM& vm) : m_vm(vm) { +#ifdef __serenity__ + auto gc_signpost_string = "Garbage collection"sv; + perf_register_string(gc_perf_string_id, gc_signpost_string.characters_without_null_termination(), gc_signpost_string.length()); +#endif + if constexpr (HeapBlock::min_possible_cell_size <= 16) { m_allocators.append(make<CellAllocator>(16)); } @@ -72,6 +85,11 @@ void Heap::collect_garbage(CollectionType collection_type, bool print_report) VERIFY(!m_collecting_garbage); TemporaryChange change(m_collecting_garbage, true); +#ifdef __serenity__ + static size_t global_gc_counter = 0; + perf_event(PERF_EVENT_SIGNPOST, gc_perf_string_id, global_gc_counter++); +#endif + Core::ElapsedTimer collection_measurement_timer; collection_measurement_timer.start(); if (collection_type == CollectionType::CollectGarbage) { |