develooper Front page | perl.perl5.porters | Postings from December 2005

Stack usage (in gv_stashpvn and others)

Thread Next
From:
Tels
Date:
December 29, 2005 09:43
Subject:
Stack usage (in gv_stashpvn and others)
-----BEGIN PGP SIGNED MESSAGE-----

Moin,

once again in gv_stashpvn:

Perl_gv_stashpvn(pTHX_ const char *name, U32 namelen, I32 create)
{
    char smallbuf[256];
    char *tmpbuf;
    HV *stash;
    GV *tmpgv;

The intention is good, a small buffer on the stack is used to avoid a 
malloc/free. The coverage http://www.maddingue.net/perlcover/--gv-c.html 
says the larger buffer is only needed 6 times.

However, I wonder whether the buffer couldn't be shrunk a bit. 256 Bytes 
is quite a bit, on systems with small stacks ( 8 or 4 Kbyte), this will 
stress the stack. Especially because stashpvn calls fetchpvn_flags, which 
also contains a 256 Byte stack buffer (around line 764), meaning whoever 
calls gv_stashpvn needs to have about 550 byte left on the stack, or bad 
things will happen.

(I am not sure how the compiler will allocate the buffer in 
gv_fetchpvn_flags because it is in a loop in the inside, but it will 
probably use the worst case and always allocate it once from the stack)

So, I propose to change the buffers to [128], that should suffice for the 
normal usage case, and shrink the stack usage a bit.

It would be good if we could find out how much stack each function uses, I 
know the linux kernel developers looked at this data to put stack usage 
on a diet.

Comments?

Best wishes,

Tels

- -- 
 Signed on Thu Dec 29 18:32:22 2005 with key 0x93B84C15.
 Visit my photo gallery at http://bloodgate.com/photos/
 PGP key on http://bloodgate.com/tels.asc or per email.

 'Wie Ludger Lügenboldt, Sprecher der Interessengemeinschaft Förderer der
 Prostitution International (I.F.P.I.) jetzt bekannt gab, entstehen der
 Zuhälterbrache jährlich Milliardenverluste durch kostenfreien Sex.
 "Bestimmt hätten unsere Mädels im Jahr 2003 alleine in Deutschland 2000
 Millionen Quickies mehr verkaufen können, wenn die Leute nicht immer
 mehr privat rumvögeln würden. Der uns entstandene Schaden beläuft sich
 auf mindestens 100000000000 Euro." Schuld sei nach Angaben Lügenboldts
 das Internet: "Flirtportale und Singlewebsites mit Kontaktbörsen machen
 unser Geschäft kaputt.  Amateure rauben uns unserer
 Geschäftsgrundlagen." Zehntausende von Arbeitsplätzen in Deutschland
 seien gefährdet, die überdies gerade geringer qualifizieren jungen
 Frauen ein Einkommen sicherten. Die I.F.P.I. fordert den Gesetzgeber
 auf, diesem Treiben umgehend Schranken zu setzen.' MI-Boykotteur at
 2004-05-07 at http://tinyurl.com/35qjo

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iQEVAwUBQ7QfoXcLPEOTuEwVAQFZcgf+NBYClH/sEPo2ocHnUusOx1SttGDNAYRu
SxJcSDjL6O3uA+xpunhaIBXRoMj9wLh24E9xj9sGjiDW0uYLdOJ6cFbrTFsbYaYg
pqGmoq6BLiWdbZDUJFiIXLGyoklIRBm92NkIQRweceH5AQpoEzsubTzsPBfeQYfU
KOMx+IDlCw8ElOMnzS2po72h+Ob4pBzsAMtVQ17ayHl5A0dysb2sr4HcSl+83TcM
8CPBPmuduBUWZwFRTwav9AXM00E5mHDqUgnhC+Wi611shEgctzuXC5sWodhxLSDk
hhCkb1eLVIQC52c7FeIGS/NapVc+yuCoopbKjo+RaaCWxZs+1nZxpw==
=EsJ+
-----END PGP SIGNATURE-----

Thread Next


Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About