Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
gstreamer
gstreamer
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 409
    • Issues 409
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 84
    • Merge Requests 84
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • GStreamer
  • gstreamergstreamer
  • Issues
  • #519

Closed
Open
Opened Mar 09, 2020 by Edward Hervey@bilboed🤘Owner

Reduce number of allocations for events/messages/queries/caps and structures in general

(Originally in #291)

status

  • structurefields are inlined in GstStructure : !392 (merged)
  • GstValueList and GstValueArray have been inlined : !402 (merged)

overview

Right now for events, messages and queries we have the following:

  • One allocation for GstEvent (or GstMessage or GstQuery)
  • One allocation for GstStructure
  • One allocation for GArray
  • Allocations for the contents of that array : GQuark + GValue

Ideally we should fold those altogether (like GstBufferList does) by inlining as much as possible in the top-level structure. Something like this :

typedef struct {
  GstMessage message;

  GstStructureImpl structure; /* Note: not a pointer */
} GstMessageImpl;

struct _GstStructureField /* Same as existing */
{
  GQuark name;
  GValue value;
};

typedef struct {
  GstStructure s;

  gint *parent_refcount;

  guint fields_len;
  guint fields_alloc;

  GstStructureField *fields;

  GstStructureField arr[1]; /* self-allocated, expands at the end */
} GstStructureImpl;

The above could improve:

  • Locality of data
  • Less micro-allocations (with the overhead of whatever slice/tcmalloc/whatever allocator you're using)

Note : Unfortunately GArray can't be initialized statically (i.e. you provide the pointer instead of glib allocating it). We also don't need some features (zero-terminated, destroynotify, ...) of it. So we could implemented our own GstStructureArray internal variant which would allow us to inline even more.

Note : This would also require modifying slightly how queries/events/messages are currently created. You'd have to first figure out the ideal number of fields to be allocated (including number of answer fields for queries and padding for some external users) and then fill in the structure.

Edited Mar 19, 2020 by Edward Hervey
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: gstreamer/gstreamer#519