After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 750658 - invoke/closure: reduce g_slice_alloc usage
invoke/closure: reduce g_slice_alloc usage
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: general
Git master
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2015-06-09 19:31 UTC by Christoph Reiter (lazka)
Modified: 2015-09-27 14:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
invoke/closure: reduce g_slice_alloc usage (25.88 KB, patch)
2015-06-09 19:33 UTC, Christoph Reiter (lazka)
none Details | Review
invoke state: add a free memory cache for PyGIInvokeArgState (4.80 KB, patch)
2015-06-09 20:03 UTC, Christoph Reiter (lazka)
none Details | Review
invoke/closure: reduce g_slice_alloc usage (25.83 KB, patch)
2015-09-26 19:34 UTC, Christoph Reiter (lazka)
committed Details | Review
invoke state: add a free memory cache for PyGIInvokeArgState (4.82 KB, patch)
2015-09-26 19:35 UTC, Christoph Reiter (lazka)
committed Details | Review

Description Christoph Reiter (lazka) 2015-06-09 19:31:46 UTC
While profiling for named return tuples I noticed that g_slice_alloc is responsible for a big chunk of time spend during marshaling. Here are my attempts to improve it by reducing its usage.
Comment 1 Christoph Reiter (lazka) 2015-06-09 19:33:03 UTC
Created attachment 304887 [details] [review]
invoke/closure: reduce g_slice_alloc usage

Instead of allocating multiple arrays, combine argument
data in a new PyGIInvokeArgState and allocate it in one go.

This reduces CPU time by 20% for simple functions and by 15%
for closures.
Comment 2 Christoph Reiter (lazka) 2015-06-09 20:03:48 UTC
Created attachment 304892 [details] [review]
invoke state: add a free memory cache for PyGIInvokeArgState

Keep one free allocation per argument count around
to reduce g_slice_alloc/free usage.

Reduces CPU time for simple functions by 10% and 5% for closures.
Comment 3 Simon Feltman 2015-07-17 04:53:28 UTC
Review of attachment 304887 [details] [review]:

Makes sense, thanks.
Comment 4 Simon Feltman 2015-07-17 04:55:36 UTC
Review of attachment 304892 [details] [review]:

Sure.
Comment 5 Christoph Reiter (lazka) 2015-07-17 09:05:41 UTC
Thanks! Just noticed that bug 752252 touches the same code/types; I'll wait for that to land first.
Comment 6 Christoph Reiter (lazka) 2015-09-26 19:34:41 UTC
Created attachment 312214 [details] [review]
invoke/closure: reduce g_slice_alloc usage

synced with master
Comment 7 Christoph Reiter (lazka) 2015-09-26 19:35:13 UTC
Created attachment 312215 [details] [review]
invoke state: add a free memory cache for PyGIInvokeArgState

synced with master
Comment 8 Christoph Reiter (lazka) 2015-09-26 19:38:20 UTC
before:

test_torture_profile (test_everything.TestTortureProfile) ... 
	torture test 1 (10000 iterations): 0.015659 secs
	torture test 2 (10000 iterations): 0.068277 secs
	torture test 3 (10000 iterations): 0.048858 secs
	torture test 4 (10000 iterations): 0.078052 secs
	====
	Total: 0.210846 sec

after:

test_torture_profile (test_everything.TestTortureProfile) ... 
	torture test 1 (10000 iterations): 0.009254 secs
	torture test 2 (10000 iterations): 0.062892 secs
	torture test 3 (10000 iterations): 0.043361 secs
	torture test 4 (10000 iterations): 0.069404 secs
	====
	Total: 0.184911 sec