[Monetdb-developers] Functions & macros
Let me just check if I got this correctly: Is it a general rule that each call to a function generates overhead, that can be eliminated by replacing the function with a macro and "calling" the macro instead? Regards, Wouter.
On 10-11-2006 12:58:41 +0100, Wouter Scherphof wrote:
Let me just check if I got this correctly: Is it a general rule that each call to a function generates overhead, that can be eliminated by replacing the function with a macro and "calling" the macro instead?
You mean in C? If so, yes, but putting everything in a macro isn't the best thing either. Also macros aren't exactly the same as functions. Alternatively you can choose to inline functions.
Wouter Scherphof wrote:
Let me just check if I got this correctly: Is it a general rule that each call to a function generates overhead, that can be eliminated by replacing the function with a macro and "calling" the macro instead?
In general yes, but.... the exploded code may become more difficult to debug (using gdb), the code may become too large for compilers or cache, and you may run out of registers. But, used with some care you can indeed improve performance significantly.
Regards, Wouter.
------------------------------------------------------------------------
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
------------------------------------------------------------------------
_______________________________________________ Monetdb-developers mailing list Monetdb-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-developers
very quick and basic rule: function call are only expensive if they are called very often (i.e. in inner loops) and if the actual body of the function is very small/cheap. in such cases avoiding function calls by using marco can improve performance. in (most) other cases, function call cost "vanish" behind other costs. Stefan On Fri, Nov 10, 2006 at 07:40:20PM +0100, Martin Kersten wrote:
Wouter Scherphof wrote:
Let me just check if I got this correctly: Is it a general rule that each call to a function generates overhead, that can be eliminated by replacing the function with a macro and "calling" the macro instead?
In general yes, but.... the exploded code may become more difficult to debug (using gdb), the code may become too large for compilers or cache, and you may run out of registers.
But, used with some care you can indeed improve performance significantly.
Regards, Wouter.
------------------------------------------------------------------------
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
------------------------------------------------------------------------
_______________________________________________ Monetdb-developers mailing list Monetdb-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-developers
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Monetdb-developers mailing list Monetdb-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-developers
-- | Dr. Stefan Manegold | mailto:Stefan.Manegold@cwi.nl | | CWI, P.O.Box 94079 | http://www.cwi.nl/~manegold/ | | 1090 GB Amsterdam | Tel.: +31 (20) 592-4212 | | The Netherlands | Fax : +31 (20) 592-4312 |
participants (4)
-
Fabian Groffen
-
Martin Kersten
-
Stefan Manegold
-
Wouter Scherphof