The following simple patch decreases the overhead of creation/destruction of objects 3-4 times (estimated for optimized build: I get 2.2x times speedup for -g build). Tested with: create an array reference with 100 objects with make_many(100) in a loop: $x = make_many(100) while --$c; (XSUB code at the end). My estimates: if the time to create one object is 1 unit, then the time to DESTROY it is around 1 unit, and the time to (re)store signals is around 9 units. [The rest is the dispatch overhead.] Enjoy, Ilya P.S. Well, I applied another patch to my Perl so it has a sped-up DESTROY. But the digits without this additional patch should be the same. --- ./config.h~ Fri Nov 17 02:57:04 2000 +++ ./config.h Fri Dec 15 03:20:13 2000 @@ -1905,7 +1905,7 @@ * traditional longjmp() if siglongjmp isn't available. * See HAS_SIGSETJMP. */ -#define HAS_SIGSETJMP /**/ +/*#define HAS_SIGSETJMP*/ /**/ #ifdef HAS_SIGSETJMP #define Sigjmp_buf sigjmp_buf #define Sigsetjmp(buf,save_mask) sigsetjmp((buf),(save_mask)) ================================================================== int no_object; #define noobject() (no_object = 1) #define DESTROY(sv) 1 HV *mystash; SV* make_many(int c) { SV *rv; AV *av = newAV(); av_extend(av,c-1); while (c--) { SV *ss = NEWSV(833, 0); SV *sv = newRV_noinc(ss); sv_bless(sv, mystash); if (no_object) { SvOBJECT_off(ss); SvREFCNT_dec(mystash); } av_store(av, c, sv); } return newRV_noinc((SV*)av); } MODULE = time_DESTROY PACKAGE = time_DESTROY_d void DESTROY(sv) SV *sv MODULE = time_DESTROY PACKAGE = time_DESTROY void noobject() SV* make_many(c) int c BOOT: mystash = gv_stashpv("time_DESTROY", 1);Thread Previous | Thread Next