Front page | perl.perl5.porters |
Postings from January 2008
struct context now 12.5% smaller than 5.10
Thread Next
From:
Nicholas Clark
Date:
January 24, 2008 06:25
Subject:
struct context now 12.5% smaller than 5.10
Message ID:
20080124142504.GR23790@plum.flirble.org
I'm afraid that $other_things have been somewhat delayed because I've been
hacking on 5.11 a bit. I put various parts of struct context onto a diet, and
made it one pointer and one IV smaller than 5.10.
(In particular, by shrinking struct block_loop, by eliminating label, which
duplicates information accessibly by blk_oldcop, and by noting that only 2
out 3 of itermax, iterlval and iterary were used at once. (After removing the
only 3 out of 3 case by other means). But struct subst and struct block_sub
have also been shrunk)
For comparison, all on x86 FreeBSD, ILP32, with 32 bit IVs:
$ ./context
This is Perl v5.8.8
struct jmpenv 60
struct cop 56
struct block_sub 32
struct block_eval 28
struct block_loop 48
struct block 76
struct subst 52
struct context 80
struct stackinfo 32
$ ./context
This is Perl v5.10.0
struct jmpenv 60
struct cop 52
struct block_sub 36
struct block_eval 28
struct block_loop 40
struct block_givwhen 4
struct block 64
struct subst 52
struct context 64
struct stackinfo 32
$ ./context
This is Perl v5.11.0
struct jmpenv 60
struct cop 52
struct block_sub 24
struct block_format 16
struct block_eval 24
struct block_loop 32
struct block_givwhen 4
struct block 56
struct subst 48
struct context 56
struct stackinfo 32
This should make the context stack more efficient.
$ cat context.c
#include "EXTERN.h"
#include "perl.h"
#include <stdio.h>
int main() {
printf("This is Perl v%d.%d.%d\n",
PERL_REVISION, PERL_VERSION, PERL_SUBVERSION);
printf("struct jmpenv\t%lu\n", sizeof(struct jmpenv));
printf("struct cop\t%lu\n", sizeof(struct cop));
printf("struct block_sub\t%lu\n", sizeof(struct block_sub));
#if PERL_VERSION > 10
printf("struct block_format\t%lu\n", sizeof(struct block_format));
#endif
printf("struct block_eval\t%lu\n", sizeof(struct block_eval));
printf("struct block_loop\t%lu\n", sizeof(struct block_loop));
#if PERL_VERSION > 8
printf("struct block_givwhen\t%lu\n", sizeof(struct block_givwhen));
#endif
printf("struct block\t%lu\n", sizeof(struct block));
printf("struct subst\t%lu\n", sizeof(struct subst));
printf("struct context\t%lu\n", sizeof(struct context));
printf("struct stackinfo\t%lu\n", sizeof(struct stackinfo));
return 0;
}
Hmmm, maybe I should be polishing my CV. If I can do this to code that
many smart people been looking at for 13 years without spotting this sort
of thing, think what I could do to code that few people have looked at...
Nicholas Clark
Thread Next
-
struct context now 12.5% smaller than 5.10
by Nicholas Clark