develooper Front page | perl.perl5.porters | Postings from January 2016

[perl #127392] module constant.pm uses +1000 kB in 522 compare to514

Thread Previous
From:
Atoomic
Date:
January 27, 2016 19:38
Subject:
[perl #127392] module constant.pm uses +1000 kB in 522 compare to514
Message ID:
rt-4.0.18-20127-1453923463-821.127392-75-0@perl.org
# New Ticket Created by  Atoomic 
# Please include the string:  [perl #127392]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=127392 >


The memory increase is not explained by one single commit, it's probably an addition of few more things.
But we can identify one commit between v5.19.7 and v5.19.8 which explains the main increase of memory.

# use perl5.22.1 version of constant
> perl514 -I~/perl/522/lib/perl5/5.22.1/ -e 'use constant; print qx{grep VmRSS /proc/$$/status}'; 
VmRSS:      1920 kB
> perl522 -e 'use constant; print qx{grep VmRSS /proc/$$/status}'
VmRSS:      3048 kB

After applying the suggested patch to constant this can be reduced by ~800 kB
the memory increase is mainly coming from the optional _ at the beginning of the regexp 
my $normal_constant_name = qr/^_?[^\W_0-9]\w*\z/;

> perl514 -I~/perl/522/lib/perl5/5.22.1/ -e 'use constant; print qx{grep VmRSS /proc/$$/status}'; 
VmRSS:      1920 kB
> perl522 -e 'use constant; print qx{grep VmRSS /proc/$$/status}'
VmRSS:      2260 kB


Doing a git bisect I could identify this commit as one of the biggest memory increase:
http://perl5.git.perl.org/perl.git/commitdiff/bcb875216f24899d543c036aebdba0835f8d22e6

Before commit HEAD=bcb8752^

> /root/perlbin_tmp/bin/perl -e 'my $f = $ENV{user} =~ qr{_?[\W\_]}; print qx{grep VmRSS /proc/$$/status}'
VmRSS:	    1684 kB
> /root/perlbin_tmp/bin/perl -e 'use constant FOO => 42; print qx{grep VmRSS /proc/$$/status}'
VmRSS:	    2292 kB


With HEAD=bcb8752

> /root/perlbin_tmp/bin/perl -e 'my $f = $ENV{user} =~ qr{_?[\W\_]}; print qx{grep VmRSS /proc/$$/status}'
VmRSS:	    1996 kB
> /root/perlbin_tmp/bin/perl -e 'use constant FOO => 42; print qx{grep VmRSS /proc/$$/status}'
VmRSS:	    2644 kB

More detailed analysis of memory usage over versions

# 5.14.4
> p14 -e 'my $f = $ENV{user} =~ qr{_?[\W\_]}; print qx{grep VmRSS /proc/$$/status}'
VmRSS:	    1488 kB
 
# 5.18.1
> /root/perlbin_tmp/bin/perl5.18.1 -e 'my $f = $ENV{user} =~ qr{_?[\W\_]}; print qx{grep VmRSS /proc/$$/status}'
VmRSS:	    1616 kB
 
# 5.18.4
> /root/perlbin_tmp/bin/perl5.18.4 -e 'my $f = $ENV{user} =~ qr{_?[\W\_]}; print qx{grep VmRSS /proc/$$/status}'
VmRSS:	    1612 kB
 
# 5.19.0
> /root/perlbin_tmp/bin/perl5.19.0 -e 'my $f = $ENV{user} =~ qr{_?[\W\_]}; print qx{grep VmRSS /proc/$$/status}'
VmRSS:	    1604 kB
 
# 5.19.6
> /root/perlbin_tmp/bin/perl -e 'my $f = $ENV{user} =~ qr{_?[\W\_]}; print qx{grep VmRSS /proc/$$/status}'
VmRSS:	    1664 kB
 
# 5.19.7
> /root/perlbin_tmp/bin/perl -e 'my $f = $ENV{user} =~ qr{_?[\W\_]}; print qx{grep VmRSS /proc/$$/status}'
VmRSS:	    1648 kB
 
# 5.19.8
> /root/perlbin_tmp/bin/perl -e 'my $f = $ENV{user} =~ qr{_?[\W\_]}; print qx{grep VmRSS /proc/$$/status}'
VmRSS:	    1980 kB
 
# 5.19.9
> /root/perlbin_tmp/bin/perl -e 'my $f = $ENV{user} =~ qr{_?[\W\_]}; print qx{grep VmRSS /proc/$$/status}'
VmRSS:	    2020 kB
 
# 5.19.11
> /root/perlbin_tmp/bin/perl -e 'my $f = $ENV{user} =~ qr{_?[\W\_]}; print qx{grep VmRSS /proc/$$/status}'
VmRSS:	    2028 kB
 
# 5.20.0
> /root/perlbin_tmp/bin/perl -e 'my $f = $ENV{user} =~ qr{_?[\W\_]}; print qx{grep VmRSS /proc/$$/status}'
VmRSS:	    2000 kB
 
# 5.20.1
> /root/perlbin_tmp/bin/perl -e 'my $f = $ENV{user} =~ qr{_?[\W\_]}; print qx{grep VmRSS /proc/$$/status}'
VmRSS:	    2000 kB
 
# 5.22.1
> /root/perlbin_tmp/bin/perl -e 'my $f = $ENV{user} =~ qr{_?[\W\_]}; print qx{grep VmRSS /proc/$$/status}'
VmRSS:	    2160 kB




Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About