-----BEGIN PGP SIGNED MESSAGE----- Moin,
On Sunday 26 June 2005 13:09, Dave Mitchell wrote: > On Sun, Jun 26, 2005 at 11:00:31AM +0200, Tels wrote: > > in my quest to rescue^Wpreserve memory, here is the second patch in > > my noCarp series. The first one can be found here: > > Are you sure that this is a net gain in memory or speed? Carp.pm is > itself very lightweight these days: it is basically a wrapper that > loads Carp::Heavy on demand. > Since any code of any significant size is likely to have indirectly > require'd Carp through some included module anyway, surely now the code > is just burdened with a bunch of croak() wrapper functions in every > namespace in *addition* to Carp.pm? I think we did have this discussion before :) * Speed: I do think there is no much difference in loading Carp or not. avings here will be tiny. * Memory: Yes, it makes a differences. Due to the waterfall effect you mentioned this is a bit masked, but I am working on that. Many modules go to great lengths to not load unnec. code and their efforts are twarted when Perl's basic modules load it for them, anyway. Example with bleadperl (because there "use vars" doesn't load Carp): # ./perl -Ilib -Mvars -le 'print $Carp::VERSION; sleep(1000)' PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 29700 te 17 0 4272 1628 1296 S 0.0 0.2 0:00.00 perl #./perl -Ilib -Mvars -MCarp -le 'print $Carp::VERSION; sleep(1000)' 1.04 PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 29702 te 17 0 4404 1720 1328 S 0.0 0.2 0:00.00 perl The lines are from top and you can see that there is a big difference in memory: -132 -92 -32 Kbytes (If added, the two subroutine wrappers do not even show up on my top radar.) My primary concerns is with embeded systems, where you have like 64 Mbyte memory, and that includes the space for the file system in the ramdisk. Saving 132 Kbyte on these systems is quite a lot. (Btw, compare this to a few bytes saved per Scalar, or 8 Kbyte saved by restructuring the allocation for the filehandles - these are much deeper changes and they save not as much memory (depending on usage, of course) as not loading unwanted code). As for the wrapper functions: Many modules have code like: croak "blah foo" if $condition; The wrapper function makes that work without having to touch any of the other code, which is for me a much nicer change than to rewrite every place as: if ($condition) { require Carp; Carp::croak ("blah foo"); } Best wishes, Tels - -- Signed on Sun Jun 26 13:29:21 2005 with key 0x93B84C15. Visit my photo gallery at http://bloodgate.com/photos/ PGP key on http://bloodgate.com/tels.asc or per email. This email violates U.S. patent #4,197,590: for (x = 0; x < widht; x++) { for (y = 0; y < height; y++) { setPixel (x+xm, y+ym, getPixel(x+xm,y+ym) ^ getCursorPixel(x,y); } } -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iQEVAwUBQr6UuHcLPEOTuEwVAQFs+Af/S6sVsBL2r7+zP/IbX69OJLz7kBvkZhXn zZvxlTc1ub9tU5/+DqJsS55E5dzH/4ttJrIPMvkvKmHrmO5iWk+WsZuZ/wb1DbZ3 6T1pibocFyzagrAU8pZSjm3HSsOdANo7HABUCezIbW/jiPbkuS2AB1az26euVukh 1pNbfF6WYPS4G7+pzVBPY9TVWz8cuMhqLnLZgiTnjIs6ELOPnhAJ7qoFaZEs115e ZQUllo7RVHZ5qz+TLGnAuW+Ul1on94v0lVJ4guwYEwNwaDQFPLA0Tdy2y6qxo61X mq/u8zTlxb7LyJbg2zCUTd+0XqToAyT1PfgEbhJLjS2rMSKGFLMyrQ== =Y0e1 -----END PGP SIGNATURE-----