GNOME Bugzilla – Bug 750658
invoke/closure: reduce g_slice_alloc usage
Last modified: 2015-09-27 14:48:16 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.
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.
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.
Review of attachment 304887 [details] [review]: Makes sense, thanks.
Review of attachment 304892 [details] [review]: Sure.
Thanks! Just noticed that bug 752252 touches the same code/types; I'll wait for that to land first.
Created attachment 312214 [details] [review] invoke/closure: reduce g_slice_alloc usage synced with master
Created attachment 312215 [details] [review] invoke state: add a free memory cache for PyGIInvokeArgState synced with master
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
https://git.gnome.org/browse/pygobject/commit/?id=f72b6434de82ffa1950ff45a4daf80c84f58eca6 https://git.gnome.org/browse/pygobject/commit/?id=e1921b7224ca1e909d9fe5483a09414742d0baf4