in reply to Re^3: Using $a and $b from XS
in thread Using $a and $b from XS
Having got this to work reliably, it seems obvious that whilst Inline::C is convenient relative to XS, it has limitations and imposes overheads that make it less than ideal for the writing of this type of extension.
Looking closely at the code for the callComp() function, whilst moving the callback into a separate sub allowed me to get something to work, the overhead it adds is skewing the results. This is especially true of the current implementation of the AB version which is fetching the globals $a and $b for every invocation. That could be fixed, but all my attempts to inline the callback code go nowhere.
There is also a saving to be made by not creating a separate array of SV*s to hold the topNs and then later copying them to the stack. They could be written to and manipulated directly on the stack using EXTEND(SP,n) and ST(n). Or maybe using TARGS? but XS uses dSP; Inline C uses dXARGS; and TARGS requires dTARGS; all of which seem to conflict with one another.
Maybe what is really needed is an Inline XS? The convenience of "Run, tweak. Run, tweak." with the "project management" taken care of, but without the mismatch between the C being converted XS being converted to C and their disparate environmental setups.
I tried lifting the code for reduce() from List::Util as a model of XS done well and trying pursuade Inline C to manage it for me, but again, the environment that Inline C gives you does not work with the XS macros it uses.
I said somwehere else, I feel a little like Pandora. I've resisted getting into XS till now, and I'm beginning to wish I had kept up that resistance. Inline C is seductive in it's simplicity of converting opcode intensive Perl code into fast running C, but it's limitations push you towards XS if you try to do something more than manipulated a few numbers or strings and the return a result. The need to call back to Perl, and Inline Cs apparent limitations in that area push you into another ballpark--and as I said in the other thread--it's a ballgame that I am not sure that I wish to be playing. It has complicated rules, a very sparse playbook and not much by way of a "noobie school"!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Using $a and $b from XS
by tall_man (Parson) on Feb 07, 2005 at 01:28 UTC | |
by BrowserUk (Patriarch) on Feb 07, 2005 at 02:22 UTC | |
by BrowserUk (Patriarch) on Feb 07, 2005 at 11:38 UTC | |
by tall_man (Parson) on Feb 07, 2005 at 20:44 UTC | |
by BrowserUk (Patriarch) on Feb 08, 2005 at 01:52 UTC | |
by tall_man (Parson) on Feb 08, 2005 at 03:10 UTC | |
| |
by BrowserUk (Patriarch) on Feb 07, 2005 at 05:34 UTC |