Skip to content

object, args-cache: Improve performance with properties basic types

Marco Trevisan requested to merge 3v1n0/gjs:property-optimizations into master

All this started with the intent of handling #524 but eventually it grew up a bit more because I've noticed that:

  • Our properties implementation handling had room for improvement (both memory and CPU wise)
  • Once I got at using the acessors, the performance improvement wasn't dramatic as I was hoping

So, first of going into that, I thought was better to propose some preliminary cleanups, in particular:

  • Use direct access to GValue basic types when possible (and safe)
  • Remove the usage of GIPropertyInfo's and GIPropertyFlagInfo caches for each object, that are now bound to the actual getters/setters allowing direct access to the property and less memory usage.
  • Remove getter/setter duplications for multiple property ids (camel-case or param-case use now the same objects)
  • Generate typed property setters and getters for basic types so that we don't have to go into any logic at runtime
  • Improve arg-cache for basic types to have more direct-types conversions with reduced overhead

Putting this in numbers, with current master when doing lots of set/get's with the GIMarshalling tests properties (so covering most types) I was getting:

Gjs-Console-Message: 02:34:39.507: Testing PropertiesObject get/set 10000 times: 9058.768 ms
Gjs-Console-Message: 02:34:41.752: Testing PropertiesObject get 10000 times: 2244.309 ms
Gjs-Console-Message: 02:34:46.388: Testing PropertiesObject set 10000 times: 4635.425 ms

With this branch we reach:

Gjs-Console-Message: 02:36:51.091: Testing PropertiesObject get/set 10000 times: 7379.213 ms
Gjs-Console-Message: 02:36:52.712: Testing PropertiesObject get 10000 times: 1620.643 ms
Gjs-Console-Message: 02:36:56.590: Testing PropertiesObject set 10000 times: 3877.520 ms
Edited by Marco Trevisan

Merge request reports