Skip to content

Draft: object: Use property accessors to get/set properties when defined

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

This is based on !866 and given that such branch is already big enough for review, is probably better to go with that first.

Also because, despite all the optimizations done here, where we even avoid going through ffi, the performance gain isn't huge:

Gjs-Console-Message: 03:12:35.629: Testing PropertiesObject get/set 10000 times: 10243.679 ms
Gjs-Console-Message: 03:12:37.988: Testing PropertiesObject get 10000 times: 2359.106 ms
Gjs-Console-Message: 03:12:43.068: Testing PropertiesObject set 10000 times: 5079.146 ms
----------------------------------
Gjs-Console-Message: 03:12:53.208: Testing PropertiesAccessorsObject get/set 10000 times: 10138.496 ms
Gjs-Console-Message: 03:12:55.475: Testing PropertiesAccessorsObject get 10000 times: 2265.246 ms
Gjs-Console-Message: 03:13:00.247: Testing PropertiesAccessorsObject set 10000 times: 4772.064 ms

Latest commits can be probably be squashed, but there there are different approaches for handling this.

There's still room for optimization, if we accept having less debug data during property access (basically only remembering the function pointer to call and associating it to the getters/setters implementations).

In such case the improvement is noticeable (by doing as in 3v1n0/gjs@677b5d92):

Gjs-Console-Message: 03:31:43.965: Testing PropertiesObject get/set 10000 times: 8170.036 ms
Gjs-Console-Message: 03:31:45.839: Testing PropertiesObject get 10000 times: 1872.787 ms
Gjs-Console-Message: 03:31:50.218: Testing PropertiesObject set 10000 times: 4378.723 ms
----------------------------------
Gjs-Console-Message: 03:31:57.238: Testing PropertiesAccessorsObject get/set 10000 times: 7018.108 ms
Gjs-Console-Message: 03:31:58.691: Testing PropertiesAccessorsObject get 10000 times: 1452.402 ms
Gjs-Console-Message: 03:32:02.398: Testing PropertiesAccessorsObject set 10000 times: 3706.231 ms

Closes: #524

Merge request reports