Scalar::Util is not using XS in Fedora 8, leading to performance problem

PERL

    Next

  • 1. Marc the Reaper
    Hello, I have a nightly build script which forks a lot of processes which may last long or not. I wanted to reap them before the end of the script. This addition made, I lose the exit code of my builds: they all pretend to fail, which I suspect to be false. So, I guess I was not able to read the perlipc page correctly. Here is a short script which behaves in the same way as my nightly build; foo: #!/usr/bin/perl -w use strict; use POSIX ":sys_wait_h"; sub child { system('date'); my $ec = $? >> 8; warn "Child exit code: $?\n"; exit $ec; } my %family; sub reaper { # from perlipc local ($!, $?); # don't let waitpid() overwrite current error my ($prd, $child) = ''; while (($child = waitpid(-1, WNOHANG)) > 0) { if (exists $family{$child}) { $prd = $family{$child}; delete $family{$child}; warn "Reaped $prd($child) with exit $?\n"; } } $SIG{CHLD} = \&reaper; } $SIG{CHLD} = \&reaper; if (my $pid = fork) { $family{$pid} = 'date'; } else { die "cannot fork: $!" unless defined($pid); child; } while (%family) { foreach my $kid (keys %family) { delete $family{$kid} if waitpid($kid, WNOHANG); } sleep 1; } warn "Parent exit\n"; exit 0; And an example run: $ ./foo Wed Sep 15 14:15:17 BST 2010 Child exit code: -1 Reaped date(21287) with exit 65280 Parent exit So, how to protect the return code? Thanks, Marc
  • 2. Typeglobs and References
    Hi everybody, I've read in Perl books that when used as lvalues, typeglobs are "equivalent" to references...something like this is constantly quoted as an example of selective aliasing: *b = \$a; # aliases $b to $a but leaves @b,%b,etc untouched Also, I've read about the *foo{THING} notation...accessing $a as: print ${*a{SCALAR}}; # prints the value of $a But what is this following code I see in some places: print ${*a}; # ALSO prints the value of $a I am confused.....how is ${*a} equivalent to ${*a{SCALAR}} ? If these 2 are equivalent, why follow the *foo{THING} notation at all...? Seems like the '{THING}' part is quite useless here? Am I wrong, or am I missing anything subtle/obvious here? Pls. enlighten.....thanks a lot. -Chaitanya

Scalar::Util is not using XS in Fedora 8, leading to performance problem

Postby Gizbo » Wed, 28 Nov 2007 11:22:30 GMT

Hi,

I've very recently upgraded to Fedora 8 (with perl 5.8.8), and the
performance of my perl code tanked.  With the help obtained in a
previous post (today's "performance problem" post, link below), I've
determined that the problem is the very high number of calls to
Scalar::Utils::refaddr(), for which the perl implementation is being
called instead of the C one.

The following shows that Scalar::Util does not see XS, for whatever
reason, and falls back to the slow perl implementation.

[me@hostname]$ perl -MScalar::Util=dualvar -e1
 is only avaliable with the XS version at -e line 0
BEGIN failed--compilation aborted.

I am not sure what to do next -- no experience with XS.  It was
suggested I reinstall Scalar::Util, but not sure if I do this via cpan
somehow, or even if that will fix the problem.  Is there a CPAN module
I can install to fix this?

Thanks

 http://www.**--****.com/ #0e8cd72a3e43af21


Re: Scalar::Util is not using XS in Fedora 8, leading to performance problem

Postby Gizbo » Wed, 28 Nov 2007 11:28:17 GMT

Well, I solved the problem after some more googling.  For those it may
help, I simply did a force install of Scalar::Util, within the cpan
shell:

bash%  cpan
cpan> force install Scalar::Util

This completely resolved the problem.  Thanks to the guy in my
previous post who pointed me in the right direction.

Re: Scalar::Util is not using XS in Fedora 8, leading to performance problem

Postby Ben Morrow » Wed, 28 Nov 2007 12:10:58 GMT

Quoth Gizbo < XXXX@XXXXX.COM >:

Just out of interest: where did your original copy of S::U come from?
Did it come out of a rpm, or did you install it yourself and it failed
to find gcc? If Redhat are providing rpms with the pure-Perl version of
S::U, this could be quite a problem... :(.

Ben


Re: Scalar::Util is not using XS in Fedora 8, leading to performance problem

Postby Gizbo » Thu, 29 Nov 2007 02:17:36 GMT

> Just out of interest: where did your original copy of S::U come from?

Hi Ben,

As far as I know, our sysadmin installed the Red Hat distribution as
is, and we do have gcc installed.  I can't say definitively whether
this is a problem with our installation or the distribution though.


Similar Threads:

1.Scalar::Util is not using XS in Fedora 8, leading to performance problem

>>>>> "BM" == Ben Morrow < XXXX@XXXXX.COM > writes:

    BM> Just out of interest: where did your original copy of S::U
    BM> come from?  Did it come out of a rpm, or did you install it
    BM> yourself and it failed to find gcc? If Redhat are providing
    BM> rpms with the pure-Perl version of S::U, this could be quite a
    BM> problem... :(.

They are (or at least were, the last time I dealt with them), and it
is.

Charlton




-- 
Charlton Wilbur
 XXXX@XXXXX.COM 

2.Perl DBI 1.50 Scalar::Util::weaken support test bug

3.&Compress::Zlib::gzopen and Scalar::Util errors

4.Problem using more than 1 module in Windows (XS) - please help

Hi all
	I have a problem that I am running into while using Perl XS to build
an interface to my C++ library. This is on a windows machine with perl
5.6.1. I was able to use PerlXS to expose out different 'c++
classes' that my API supports. I wrote the .XS files for each of
these objects and now I am able to make a simple test.pl file and use
these objects from Perl. The problem comes when I try to use more than
1 object (module) in a single .pl file. Here would an example

========== working example perl script  ================

use lib "C:/Documents and Settings/myusername/Desktop/perl
experiment/api";
use MyDataReader;
my $dr = new MyDataReader("hsd_demo_pre");
$dr->execQuery("select * from bug");
print "fields: " . $dr->getFieldCount() . "\n";


================== perl script giving problem =============
use lib "C:/Documents and Settings/myusername/Desktop/perl
experiment/api";
use MyDataReader;

use MyAdmin;   # Adding this line gives problems


my $dr = new MyDataReader("hsd_demo_pre");
$dr->execQuery("select * from bug");
print "fields: " . $dr->getFieldCount() . "\n";


========= Error Message ==================

C:\Documents and Settings\myusername\Desktop\perl experiment\api>perl
test.pl
Can't load 'C:\Documents and Settings\ myusername \Desktop\perl
experiment\api/5.6.1
/MyAdmin.dll' for module MyAdmin: load_file:Attempt to access invalid
address at C
:/Perl/lib/DynaLoader.pm line 206.
Compilation failed in require at test.pl line 11.
BEGIN failed--compilation aborted at test.pl line 11.


So the problem shows up when I use more than one 'use' statements
in a perl script. Its important to note here that I can use the
'MyAdmin' module by itself just fine. So its not aproblem with that
module. The problem is only when I try to use more than 1 module in a
single perl script.

==================== Makefile.PL ===================
use ExtUtils::MakeMaker;
$CC = 'cl';
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile( 'NAME' => 'MyDataReader',
               'VERSION' => '0.10',
               'DEFINE'	=> '-TP -EHsc',     # e.g., '-DHAVE_SOMETHING'
               'CC' => $CC,
               'LDDLFLAGS' => '-nologo -libpath:"C:\Perl\lib\CORE"
-machine:x86',
			   'LIBC' => 'msvcrtd.lib',
			   'LDLOADLIBS' => 'oldnames.lib kernel32.lib user32.lib gdi32.lib
winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib  netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib
version.lib odbc32.lib odbccp32.lib msvcrtd.lib',
			   'CCFLAGS' => '-nologo -O1 -MDd -DNDEBUG -DWIN32 -D_CONSOLE
-DNO_STRICT -DHAVE_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT
-DPERL_IMPLICIT_SYS -DPERL_MSVCRT_READFIX',
               'LD' => '$(CC)',
               'XSOPT' => '-C++',
			   'OPTIMIZE' => '-O1 -MDd -DNDEBUG',
               'PERM_RW' => '664',
               'PERM_RWX' => '775',
               'TYPEMAPS' => ['perlobject.map']    ,
			    'INC'      => "-Iinclude",
          	'MYEXTLIB' => 'lib\myexternalapi.lib'
		       );

========== end =========

5.I am having problems installing PDL using CPAN

6. Slow Performance When Using DBI, otherwise Not

7. log out to file using mp2 and apache2 on Fedora

8. Problems installing DBD-Interbase on Fedora



Return to PERL

 

Who is online

Users browsing this forum: No registered users and 76 guest