Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: [patch] PERL_MEM_LOG_STDERR is silly, *everyone* (saying PERL_MEM_LOG) wants the default logger

4 views
Skip to first unread message

Rafael Garcia-Suarez

unread,
Jun 20, 2009, 8:31:42 AM6/20/09
to Jim Cromie, Perl 5 Porters
2009/6/12 Jim Cromie <jim.c...@gmail.com>:
>
> this patch inverts it and renames it to PERL_MEM_LOG_NOIMPL
> so we get a working default with a shorter compile-line (and no rebuilds),
> and whomever gets the option they need.

Not sure -- I have never used those options. One thing is sure though,
you can't rename them in the code and not in perlhack.pod.

> This is just a build change right ?
> not frozen by stability ??
>
> PERL_MEM_LOG_ENV is also a reasonable default,
> unless you always want to look at all bajillion lines.
> I might just do this.

That sounds like a good idea.

Jim Cromie

unread,
Jun 20, 2009, 10:28:03 AM6/20/09
to Rafael Garcia-Suarez, Perl 5 Porters

I went a bit further with this 2nd step; I combined all env reads into 1,
which reads a string, then strchr's 4 separate tests on the string.
Ive taken it on faith that strchr will always be as fast or faster than getenv.

the doco touch from handy.h is hopefully clear enough:

- * -DPERL_MEM_LOG_ENV: if compiled in, at run time the environment
- * variables PERL_MEM_LOG and PERL_SV_LOG are checked (repeatedly).
- * If the integer values are true, the respective logging is done.
- * (Without this also defined, logging is voluminous)
+ * The default implementation reads a single envar; PERL_MEM_LOG,
+ * expecting one or more of the following:
+ *
+ * \d+ - fd fd to write to : must be 1st (atoi)
+ * 'm' - memlog was PERL_MEM_LOG=1
+ * 's' - svlog was PERL_SV_LOG=1
+ * 't' - timestamp was PERL_MEM_LOG_TIMESTAMP=1
*
- * -DPERL_MEM_LOG_TIMESTAMP: if compiled, a timestamp will be logged
- * before every memory logging entry. This can be turned off at run
- * time by setting the environment variable PERL_MEM_LOG_TIMESTAMP
- * to zero.
+ * This makes the logger controllable enough that it can reasonably be
+ * added to the system perl.
*/


I just coded that and moved on, will go back and verify it functions
with the (important) permutations of "2mst". So not attached yet..

If this isnt too radical, I'll patch perlhack for both of these
changes together.
(or just 1st, depending..)
(perlhack patch to follow for both together if thats ok)

Rafael Garcia-Suarez

unread,
Jun 21, 2009, 8:29:42 AM6/21/09
to Jim Cromie, Perl 5 Porters
2009/6/20 Jim Cromie <jim.c...@gmail.com>:
> following up;
>
> everything works as previously described, fresh patches attached:
>
> 0004-invert-and-rename-PERL_MEM_LOG_STDERR-to-PERL_MEM_LO.patch
> 0005-simplify-PERL_MEM_LOG.patch
> 0006-update-PERL_MEM_LOG-in-perlhack.pod.patch
>
> plus an extraneous update:
>
> 0001-point-illguts-at-perl.org.patch

Thanks, all applied, plus some nits, so I'll just show the relevant
git log entries here, from last to first:

commit 2e5b50041f3643ca27385b211da60add40857ec8
Author: Rafael Garcia-Suarez <rgarci...@gmail.com>
Date: Sun Jun 21 14:27:43 2009 +0200

A few docs nits after the few last commits

pod/perlhack.pod | 22 +++++++++++-----------
util.c | 4 ++--
2 files changed, 13 insertions(+), 13 deletions(-)

commit 4bd8fafa9f9185d83cee6991ca49c6ac9b8782a4
Author: Rafael Garcia-Suarez <rgarci...@gmail.com>
Date: Sun Jun 21 14:16:55 2009 +0200

Also replace PERL_MEM_LOG_STDERR by PERL_MEM_LOG_NOIMPL in the -V output

perl.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

commit fd5aa6c359a400a4ad1156429c8cc40e21a5bcad
Author: Rafael Garcia-Suarez <rgarci...@gmail.com>
Date: Sun Jun 21 14:15:34 2009 +0200

Regenerate headers

embed.h | 4 ++--
proto.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)

commit 10a879f5b15504fdd9aa98740d738732eeee2f22
Author: Jim Cromie <jim.c...@gmail.com>
Date: Sat Jun 20 09:43:43 2009 -0600

update PERL_MEM_LOG in perlhack.pod

pod/perlhack.pod | 44 +++++++++++++++++++++++---------------------
1 files changed, 23 insertions(+), 21 deletions(-)

commit 1cd8acb500c6fd96bf025feb0647211c271b7e2e
Author: Jim Cromie <jim.c...@gmail.com>
Date: Wed Jun 17 02:12:45 2009 -0600

simplify PERL_MEM_LOG

This combines multiple environment variable reads into 1,
where it looks for values like "2mst"
-2 leading digits are atoi()d to get FD
-m memory logging please
-s sv logging also
-t timestamp those please.

Combining these reduces overhead such that it seemed
worthwhile to drop all the ifdefs. TBD whether this works
in the environment that drove the original tradeoffs.

If it isnt enough, Id be tempted by a global static ptr,
and on 1st use, is read, seen 0, a lock is taken, and getenvar
run to populate it, unlocked, proceed. This would remove
iterative overheads.

util.c | 62 ++++++++++++++++++++++++--------------------------------------
1 files changed, 24 insertions(+), 38 deletions(-)

commit 73d1d97336c68e0f5b29937cb9347a00df4c645c
Author: Jim Cromie <jim.c...@gmail.com>
Date: Thu Jun 11 16:28:46 2009 -0600

invert and rename PERL_MEM_LOG_STDERR to PERL_MEM_LOG_NOIMPL

Most users who want PERL_MEM_LOG want the default implementation,
give it to them. Users providing their own implementation can
obtain current behavior by adding -DPERL_MEM_LOG_NOIMPL.
Frankly, the average user probably wants _ENV by default too.

embed.fnc | 2 +-
handy.h | 6 ++-
util.c | 104 +++++++++++++++++++++++++++++++++++++++---------------------
3 files changed, 72 insertions(+), 40 deletions(-)

commit de10be12cd3b4d2e91c136c495230f49b31a4511
Author: Jim Cromie <jim.c...@gmail.com>
Date: Fri Jun 12 15:27:11 2009 -0600

point illguts at perl.org

pod/perlhack.pod | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)

Jim Cromie

unread,
Jun 21, 2009, 10:00:58 AM6/21/09
to Rafael Garcia-Suarez, Perl 5 Porters
thanks R,

one of your nits prompted another -
drop now obsolete PERL_MEM_LOG_ENV* from -V output.

sorry for the incremental churn.

0002-drop-remaining-mentions-of-PERL_MEM_LOG_FOO-envars.patch

Rafael Garcia-Suarez

unread,
Jun 21, 2009, 11:29:33 AM6/21/09
to Jim Cromie, Perl 5 Porters
2009/6/21 Jim Cromie <jim.c...@gmail.com>:

Thanks, applied as b953482e2d970eeb88de96a38c087d03db83a5cd, plus a
little doc cleanup in handy.h.

0 new messages