Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • gtk gtk
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,477
    • Issues 1,477
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 247
    • Merge requests 247
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOME
  • gtkgtk
  • Merge requests
  • !2072

gtkbuilder: Eliminate array reallocations in get_parameters()

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Philip Withnall requested to merge pwithnall/gtk:builder-parameters-speedup-gtk-3 into gtk-3-24 Jun 10, 2020
  • Overview 5
  • Commits 1
  • Pipelines 1
  • Changes 3

gtk_builder_get_parameters() is a hot path, being called twice for each object in each UI file in an application. The majority of objects have ≤ 8 properties, which are each filtered into either parameters or filtered_parameters.

Unfortunately, both of those arrays are created as empty GArrays, and adding 8 elements to an empty GArray hits the worst possible case of reallocating and memcpy()ing the array 3 times. As the array size is doubled with each reallocation, the cost is not particularly well amortised when the array size is small.

From the ObjectInfo, we actually know how many properties there are in total, so just allocate the arrays at the right size to begin with.

This saves 7% of the instruction cycles needed to start up gnome-software to the point where it’s showing its main window, according to callgrind. gnome-software is making around 5500 calls to gtk_builder_get_parameters().

Signed-off-by: Philip Withnall withnall@endlessm.com

Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: builder-parameters-speedup-gtk-3