in reply to Re^9: Use perl type without perl
in thread Use perl type without perl
My new motto, death by a thousand cuts.Ignoring that I don't know what "GLR and SLR" are -- and you do not bother to explain them -- I'd be interested to see proof of that "much faster". Faster I have no doubts, but much faster?
See "TlsGetValue was implemented with speed as the primary goal."
And I counter that assertion with: speed isn't everything.
void CxtSpeed() PREINIT: LARGE_INTEGER start; LARGE_INTEGER end; int i; PPCODE: QueryPerformanceCounter(&start); for(i=0; i < 1000000000; i++){ no_cxt(); } QueryPerformanceCounter(&end); printf("no cxt %I64u\n", end.QuadPart-start.QuadPart); QueryPerformanceCounter(&start); for(i=0; i < 1000000000; i++){ cxt(aTHX); } QueryPerformanceCounter(&end); printf("cxt %I64u\n", end.QuadPart-start.QuadPart);
//separate compiland/obj file #define PERL_NO_GET_CONTEXT #include <EXTERN.h> #include <perl.h> #include <XSUB.h> __declspec(dllexport) int no_cxt(){ dTHX; return ((int) my_perl) >> 1; } __declspec(dllexport) int cxt(pTHX){ return ((int) my_perl) >> 1; }
Make sure to check disassembly to make it wasn't all inline optimized away. cxt() loop was completely removed in my 1st try.#in makefile.pl hash to WriteMakefile FUNCLIST => ['no_cxt', 'cxt'], dynamic_lib => { OTHERLDFLAGS => ' noopt.obj ' , INST_DYNAMIC_DEP => 'noopt.obj' },
Whole script took about 5-8 seconds. 1 Perl_get_context took 4.3 times more time than passing it on the C stack and of course everything tested fit L1 the whole time. I would much rather have my_perl on the C stack or in a register (compiler's choice) than call Perl_get_context half a dozen or more times in every Perl C function. If you want to know why TlsGetValue is never optimized away to inline assembly, ask MS. I didn't write Kernel32.C:\Documents and Settings\Owner\Desktop\cpan libs\lxs>perl -MLocal::XS + -e "Local:: XS::CxtSpeed();" no cxt 48160819 cxt 11096124 C:\Documents and Settings\Owner\Desktop\cpan libs\lxs>
Should I delete my post and post it to the other post?Which is why I think your post would have been better directed at the alternative you suggested.
The OP was vague and didn't concisely explain anything, so I had to consult with my crystal ball that I got at the pound shop made from lead wiring, chip board and bitumen, to read the OP's mind. My crystal ball said he is using Perl in a DLL that doesn't link with Perl but includes Perl's headers for Perl's GC. Should I use my O'Reilly brand tarot cards in the future?GObject and Perl's GC systems have many similarities. ... I am saying that would be a bad choice.Then why mention it? No one else did.
I gave an answerAren't you just as guilty of misdirection by bringing it up and leaving it hanging as the guy that suggested: "you'll be fine so long as you don't use threads"? Which seems to be the focus of your posts.
Someone who didn't read the manual will think they can use Perl C data structures without a "useless" Perl around instead of GObjectIf you read the manual (perlapi/perlguts/illguts/perlembed/perlxs), you will know that using Perl without an initialized interp is not supported by Perl.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^11: Use perl type without perl
by BrowserUk (Patriarch) on Sep 26, 2012 at 00:53 UTC | |
|
Re^11: Use perl type without perl
by BrowserUk (Patriarch) on Sep 26, 2012 at 03:41 UTC | |
by bulk88 (Priest) on Sep 27, 2012 at 08:09 UTC | |
by BrowserUk (Patriarch) on Sep 27, 2012 at 15:58 UTC | |
by bulk88 (Priest) on Sep 26, 2012 at 23:04 UTC | |
by BrowserUk (Patriarch) on Sep 27, 2012 at 00:37 UTC |