develooper Front page | perl.perl5.porters | Postings from May 2013

Re: [perl #118055] miniperl fails with SIGBUS on sparc(usethreads+use64bitint)

Thread Previous | Thread Next
From:
Andrew Dougherty
Date:
May 25, 2013 15:27
Subject:
Re: [perl #118055] miniperl fails with SIGBUS on sparc(usethreads+use64bitint)
Message ID:
alpine.DEB.2.02.1305251119390.889@fractal.phys.lafayette.edu
On Sat, 25 May 2013, Nicholas Clark wrote:

> On Sat, May 25, 2013 at 10:57:47AM -0400, Andy Dougherty wrote:
> 
> > It's just taking a long time to actually finish.  I'll report back when it 
> > does.
> > 
> > Meanwhile, what would you think about tweaking it like this:
> > 
> > diff --git a/op.c b/op.c
> > index 792e8d6..fd69c56 100644
> > --- a/op.c
> > +++ b/op.c
> > @@ -175,7 +175,7 @@ Perl_Slab_Alloc(pTHX_ size_t sz)
> >       || (CvSTART(PL_compcv) && !CvSLABBED(PL_compcv)))
> >  	return PerlMemShared_calloc(1, sz);
> >  
> > -#if defined(USE_ITHREADS) && IVSIZE > U32SIZE
> > +#if defined(USE_ITHREADS) && IVSIZE > U32SIZE && !defined(__x86_64__)
> >      /* Work around a goof with alignment on our part. For sparc32 (and
> >         possibly other architectures), if built with -Duse64bitint, the IV
> >         op_pmoffset in struct pmop should be 8 byte aligned, but the slab
> 
> Good point. But I think that that's more restrictive than it needs to be.
> I think that this would be valid:
> 
> #if defined(USE_ITHREADS) && IVSIZE > U32SIZE && IVSIZE > PTRSIZE

Yes, that would catch the relevant SPARC case (-Duse64bitint on an 
otherwise 32-bit build).

> (but I have not yet tested it)
> 
> > As far as I am aware, the alignment isn't an issue on x86_64, but there is 
> > a small, but barely measureable, cost to the if(sz == sizeof(struct pmop)) 
> > test even in cases where it isn't used.  Fiddling a bit with perbench 
> > benchmarks, this modified version of one of the hash tests:
> 
> and would avoid that cost on other 64 bit platforms.
> 
> > my $i = "abcdefg";
> > for (1..2000) {
> >     for my $j (1..2000) {
> > 	$hash{$i} = $j;
> >     }
> >     $i++;
> > }
> > 
> > my $k;
> > foreach $k (keys %hash) {
> >    my $v = $hash{$k};
> > }
> > 
> > ran slightly quicker on x86_64 (differences were consistently at the 2-3 
> > sigma level as reported by dumbbench) with that suggested tweak.
> 
> That's a test doing work at runtime, which is affected by a compile-time
> change? As best I can work out, there are no OPs allocated at runtime by
> that code.

Correct.  With current blead on Linux x86_64, every op allocation still 
tests

    if(sz == sizeof(struct pmop) 

and even though the test is always false for that program, the cummulative 
cost of doing the test is (just barely) measurable.

Anyway, it works as is.  I think your suggested change should be an 
improvement.  I'll go ahead and run some tests, but it looks like it 
should be fine and safe to backport to 5.18.0.

-- 
    Andy Dougherty		doughera@lafayette.edu


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About