Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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

by BrowserUk (Patriarch)
on Jun 16, 2018 at 17:48 UTC ( [id://1216787]=note: print w/replies, xml ) Need Help??


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

(I've ignored the CCFLAGS output that is also produced.)

Just debug.

AIUI, the problem with defining PERL_NO_GET_CONTEXT in Inline::C scripts is that it causes breakage if any of the Inline::C functions call Perl API functions. But none of the functions in your script call Perl API functions, so it's ok to define PERL_NO_GET_CONTEXT.

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

It is the case that many, if not all-but-one, of the Perl_get_context() calls get optimised away, but getting your hands on the post-optimised assembly is only possible by using a debugger, and it means relating any bug back to the pre-optimised C is a nightmare.

Could it be that the hint that vr is looking for is simply to "define PERL_NO_GET_CONTEXT" ?

Possibly; but getting his hands on the assembler output would be the surest way of finding out. That has to be possible with gcc/mingw right?

I still think that the chances are that gcc is optimising his c-stub and perl callable wrapper away completely.


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
  • Comment on Re^7: Inline::C on Windows: how to improve performance of compiled code?

Replies are listed 'Best First'.
Re^8: Inline::C on Windows: how to improve performance of compiled code?
by syphilis (Archbishop) on Jun 17, 2018 at 03:33 UTC
    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
      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://1216787]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-19 20:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found