libsysprof-analyze: index jitmaps for faster access

We want quick access to these for the jitmap symbolizer, so index them
like we do other important types with GtkBitset to get their frame
positions.
This commit is contained in:
Christian Hergert
2023-05-22 12:25:55 -07:00
parent 8abc55f0e6
commit aab4408f73
3 changed files with 31 additions and 2 deletions

View File

@ -30,6 +30,7 @@
#include "sysprof-document-file-chunk.h"
#include "sysprof-document-file-private.h"
#include "sysprof-document-frame-private.h"
#include "sysprof-document-jitmap.h"
#include "sysprof-document-mmap.h"
#include "sysprof-document-process-private.h"
#include "sysprof-document-symbols-private.h"
@ -58,6 +59,7 @@ struct _SysprofDocument
GtkBitset *mmaps;
GtkBitset *overlays;
GtkBitset *pids;
GtkBitset *jitmaps;
GHashTable *files_first_position;
GHashTable *pid_to_process_info;
@ -197,6 +199,7 @@ sysprof_document_finalize (GObject *object)
g_clear_pointer (&self->frames, g_array_unref);
g_clear_pointer (&self->file_chunks, gtk_bitset_unref);
g_clear_pointer (&self->jitmaps, gtk_bitset_unref);
g_clear_pointer (&self->mmaps, gtk_bitset_unref);
g_clear_pointer (&self->overlays, gtk_bitset_unref);
g_clear_pointer (&self->pids, gtk_bitset_unref);
@ -226,6 +229,7 @@ sysprof_document_init (SysprofDocument *self)
self->frames = g_array_new (FALSE, FALSE, sizeof (SysprofDocumentFramePointer));
self->file_chunks = gtk_bitset_new_empty ();
self->jitmaps = gtk_bitset_new_empty ();
self->mmaps = gtk_bitset_new_empty ();
self->overlays = gtk_bitset_new_empty ();
self->pids = gtk_bitset_new_empty ();
@ -502,6 +506,10 @@ sysprof_document_load_worker (GTask *task,
gtk_bitset_add (self->file_chunks, self->frames->len);
break;
case SYSPROF_CAPTURE_FRAME_JITMAP:
gtk_bitset_add (self->jitmaps, self->frames->len);
break;
case SYSPROF_CAPTURE_FRAME_MAP:
gtk_bitset_add (self->mmaps, self->frames->len);
break;
@ -826,6 +834,23 @@ sysprof_document_list_processes (SysprofDocument *self)
return _sysprof_document_bitset_index_new (G_LIST_MODEL (self), self->processes);
}
/**
* sysprof_document_list_jitmaps:
* @self: a #SysprofDocument
*
* Gets a #GListModel containing #SysprofDocumentJitmap found within
* the #SysprofDocument.
*
* Returns: (transfer full): a #GListModel of #SysprofDocumentJitmap
*/
GListModel *
sysprof_document_list_jitmaps (SysprofDocument *self)
{
g_return_val_if_fail (SYSPROF_IS_DOCUMENT (self), NULL);
return _sysprof_document_bitset_index_new (G_LIST_MODEL (self), self->jitmaps);
}
/**
* sysprof_document_symbolize_traceable: (skip)
* @self: a #SysprofDocument

View File

@ -45,6 +45,8 @@ GListModel *sysprof_document_list_traceables (SysprofDocument
SYSPROF_AVAILABLE_IN_ALL
GListModel *sysprof_document_list_processes (SysprofDocument *self);
SYSPROF_AVAILABLE_IN_ALL
GListModel *sysprof_document_list_jitmaps (SysprofDocument *self);
SYSPROF_AVAILABLE_IN_ALL
guint sysprof_document_symbolize_traceable (SysprofDocument *self,
SysprofDocumentTraceable *traceable,
SysprofSymbol **symbols,

View File

@ -28,6 +28,7 @@ main (int argc,
{
g_autoptr(SysprofDocumentLoader) loader = NULL;
g_autoptr(SysprofDocument) document = NULL;
g_autoptr(GListModel) model = NULL;
g_autoptr(GError) error = NULL;
guint n_items;
@ -46,11 +47,12 @@ main (int argc,
return 1;
}
n_items = g_list_model_get_n_items (G_LIST_MODEL (document));
model = sysprof_document_list_jitmaps (document);
n_items = g_list_model_get_n_items (model);
for (guint i = 0; i < n_items; i++)
{
g_autoptr(SysprofDocumentFrame) frame = g_list_model_get_item ((GListModel *)document, i);
g_autoptr(SysprofDocumentFrame) frame = g_list_model_get_item (model, i);
if (SYSPROF_IS_DOCUMENT_JITMAP (frame))
{