I am extremely happy to announce that I have successfully completed my GSoC project!
I would like to take this opportunity to thank the community for this wonderful learning experience. It has really helped me to add a new dimension to my knowledge while at the same time introducing me to the world of open-source projects.
Most importantly, I would like to thank my mentor Reini Urban (rurban) for the tremendous help he offered me, ever since my first contact with the community. As a matter of fact, without his ideas and invaluable guidance, completing the project would have been an impossible task. I would also like to thank my co-mentor Bruce Gray (Util) for guiding us throughout the project and providing us with valuable inputs to overcome the many hurdles we faced.
In this blog, I will attempt to summarize the work I have completed through my project.
My project's primary objective was to improve the performance of the method signatures. My project was divided into three tasks:-
Optimize GC Write Barriers in the PMCs
With this task, pmc2c could generate GC write barriers automatically for SELF in the PMC VTABLE Methods.
Also, there is an option for manual optimization by using the :manual_wb and :no_wb annotations.
(Please refer - https://github.com/parrot/parrot/blob/master/docs/pmc.pod#pmcs-and-gc)
This work gave us a good performance gain of 2.5% - 5% and was part of our 6.5.0 release.
Compile-time expand PCC params and set the return result
In this task, PCCMETHODS were optimized to omit the run-time call to Parrot_pcc_fill_params_from_c_args(interp, _call_object, sig, &_self, args...);.
Similarly, for assigning the RETURN result, a call to Parrot_pcc_set_call_from_c_args(interp, _call_object, rettype, result); was omitted.
To achieve this, pmc2c was directly modified. My work also allowed handling of :optional argument at compile time itself. This work was further improved by rurban and he also took care of :opt_flag and added an arity check.
This work resulted in the creation of a lesser number of PMCs, lesser branches and got rid of the 2 costly C functions per method call.
We achieved a minimal performance gain of 0.5% but a 4-10% speed gain per method call. This work was part of our 6.6.0 release.
Export CallContext Methods
This task required the optimization of the internal PCC CallContext calls.
My initial work included optimizing PCC (src/call/pcc.c) by inlining VTABLE calls in Parrot_pcc_add_invocant and further by expanding Parrot_pcc_add_invocant in the definition for Parrot_pcc_invoke_method_from_c_args.
However, we realized that an indirect call was still being made to the VTABLE methods and hence, a performance improvement could not be expected.
To correct this, the internally needed CallContext VTABLE methods were first exported with manual changes to the header file. This work was later automated by making the methods non-static through the pmc2c itself. The exported methods are now used to make direct calls instead of the indirect VTABLE calls that were being made in src/call/*.c.
Furthermore, the task also inlined the CallContext ATTR accessors to omit the obj check.
Through this task, we achieved a performance gain of around 0-1.6%. This work will be part of our 6.7.0 release.
Please take a look at parrot-bench for the benchmark data and graph:
During my project, I carried out profiling for Parrot's releases 2.7 - 3.0. The main objective for the profiling was to determine the highest overhead to be targeted for refactor.
The list of all the identified overheads is as follows -
During the course of the project, we also concluded that the PMC-fication task that was carried out by bacek did not attribute too much slowdown.
In fact, the autoboxing of PMCs that Whiteknight suspected in his blogs, might still be the biggest problem that needs to be solved.
However, given the scope of this task and the GSoC timeline, it would have been very difficult to make an attempt to solve this problem.
Since I really want to continue contributing, I really look forward to tackling the "autoboxing" problem and any other optimizations that would help to make Parrot run faster!
Finally, I once again thank everyone for letting me be a part of the community. I really look forward to continue being a part of it and doing my bit!
This is Chirag Agrawal (ZYRO) - signing off my project for GSoC 2014! :)