Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^8: Inline::C on Windows: how to improve performance of compiled code?

by syphilis (Archbishop)
on Jun 17, 2018 at 03:33 UTC ( [id://1216802]=note: print w/replies, xml ) Need Help??


in reply to Re^7: Inline::C on Windows: how to improve performance of compiled code?
in thread Inline::C on Windows: how to improve performance of compiled code?

T'is unfortunate that almost every function that does anything useful needs to call at least one perl API

Indeed ... though it's also often the case that many functions that call the Perl API don't really need to.
Here's a simplistic example:
use strict; use warnings; use Inline C => Config => PRE_HEAD => '#define PERL_NO_GET_CONTEXT 1', ; use Inline C => <<'EOC'; /* SV * foo(int x) { return newSViv(x); } */ int foo(int x) { return x; } EOC my $x = foo(-1234);https://perlconference.us/tpc-2018-slc/ print $x;
Both renditions of foo() do essentially the same thing.
But the rendition that has been commented out won't work when PERL_NO_GET_CONTEXT is defined, whereas the other rendition will.

So there are possibilities even with the current Inline::C, depending upon how much time and energy you're prepared to devote in order to avoid the Perl API.
But mostly, it's not worth the effort.
(Of course, ideally you wouldn't even have to concern yourself with such matters when using Inline::C - and Ingy has indicated (in the link I provided earlier) that this might all be fixed in Inline::C following the Perl Conference that begins in the next day or so.
In the meantime, if you want to define PERL_NO_GET_CONTEXT, then I think you're generally going to have to create an XS module.

Cheers,
Rob
  • Comment on Re^8: Inline::C on Windows: how to improve performance of compiled code?
  • Download Code

Replies are listed 'Best First'.
Re^9: Inline::C on Windows: how to improve performance of compiled code?
by BrowserUk (Patriarch) on Jun 17, 2018 at 04:07 UTC
    Both renditions of foo() do essentially the same thing. But the rendition that has been commented out won't work when PERL_NO_GET_CONTEXT is defined, whereas the other rendition will.

    But all that does is move the mapping from int to SV from explicit to implicit. Ie. moves the mapping from the C function to the IC wrapper code.

    And 95% of the overhead is (already) in the wrapper code.

    Maybe the benefits of PERL_NO_GET_CONTEXT are confined to gcc/mingw, but I have just tried it in two different pieces of code (and previously when it came up also) and it never seems to make a jot of difference.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
    In the absence of evidence, opinion is indistinguishable from prejudice. Suck that fhit

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1216802]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-19 23:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found