Closed p5pRT closed 4 years ago
See attached patch.
Memory savings statistics. Win32 Perl on WinXP with VC 2003. First number in the 400s is starting point (the first system 'pause') memory usage in KBs. The 2nd number is memory usage in KBs at the second system 'pause'. Memory usage is Private Bytes in Process Explorer\, which is all process unique memory given by the OS to the process. This number includes all "malloc" memory but not any memory mapped files (most of perl.exe/most of perl523.dll/etc) backed by disk storage\, or inter-process shared memory areas. The memory counts can only change in units of 4 KB (x86 page size). I am not sure why different runs produce slightly different amounts of mem usage (maybe perl hash seed randomization means different split levels\, malloc randomization by the OS).
ExtUtils::Constant is abandoned on CPAN with no maintainer so core patching is the only option. An existing note in Maintainers.pl refers to ExtUtils::Constant having questionable maintenance.
These patches are low impact patches which dont involve adding new APIs. I plan to completely rewrite how perl handles storing file paths\, which means new APIs and a higher risk of it being reverted. These are the last possible optimizations under the old (current) API.
no threads before perl -e"BEGIN{$^P = $^P | 0x0; system 'pause';} use Test::Harness; use Test::More; use CPAN; use CPAN::Meta; use ExtUtils::MakeMaker; use Pod::Perldoc;system 'pause';" 468 16304 468 16312 468 16312 468 16312 468 16308
no threads before perl -e"BEGIN{$^P = $^P | 0x2; system 'pause';} use Test::Harness; use Test::More; use CPAN; use CPAN::Meta; use ExtUtils::MakeMaker; use Pod::Perldoc;system 'pause';" 476 22624 476 22628 476 22620 476 22624 476 22620
no threads after perl -e"BEGIN{$^P = $^P | 0x0; system 'pause';} use Test::Harness; use Test::More; use CPAN; use CPAN::Meta; use ExtUtils::MakeMaker; use Pod::Perldoc;system 'pause';" 468 16280 468 16288 468 16292 468 16292 468 16292
no threads after perl -e"BEGIN{$^P = $^P | 0x2; system 'pause';} use Test::Harness; use Test::More; use CPAN; use CPAN::Meta; use ExtUtils::MakeMaker; use Pod::Perldoc;system 'pause';" 476 22620 476 22620 476 22616 476 22620 476 22616
threads before perl -e"BEGIN{$^P = $^P | 0x0; system 'pause';} use Test::Harness; use Test::More; use CPAN; use CPAN::Meta; use ExtUtils::MakeMaker; use Pod::Perldoc;system 'pause';" 492 18968 492 18972 492 18976 492 18976 492 19972
threads before perl -e"BEGIN{$^P = $^P | 0x2; system 'pause';} use Test::Harness; use Test::More; use CPAN; use CPAN::Meta; use ExtUtils::MakeMaker; use Pod::Perldoc;system 'pause';" 496 26004 496 26004 496 26008 496 25996 496 26004
threads after perl -e"BEGIN{$^P = $^P | 0x0; system 'pause';} use Test::Harness; use Test::More; use CPAN; use CPAN::Meta; use ExtUtils::MakeMaker; use Pod::Perldoc;system 'pause';" 492 18976 492 18976 492 18968 492 18972 492 18976
threads after perl -e"BEGIN{$^P = $^P | 0x2; system 'pause';} use Test::Harness; use Test::More; use CPAN; use CPAN::Meta; use ExtUtils::MakeMaker; use Pod::Perldoc;system 'pause';" 496 25996 496 25988 496 25996 496 25988 496 25992
Cannot you put this in a git branch somewhere please? It affects me a lot\, and it's a lot of work to update with patches only.
I like the idea\, but I want to check the cornercases. -- Reini Urban
The RT System itself - Status changed from 'new' to 'open'
On Wed Jul 08 22:33:46 2015\, rurban wrote:
Cannot you put this in a git branch somewhere please? It affects me a lot\, and it's a lot of work to update with patches only.
I like the idea\, but I want to check the cornercases.
try threaded and unthreaded builds\, there is different behavior (or preserving of existing different behavior)
https://github.com/bulk88/perl/tree/pmfiledebugglob https://github.com/bulk88/perl/tree/removecvfile https://github.com/bulk88/perl/tree/cvfilelessalloc
-- bulk88 ~ bulk88 at hotmail.com
On Tue Jul 07 07:21:04 2015\, bulk88 wrote:
Memory savings statistics. Win32 Perl on WinXP with VC 2003. First number in the 400s is starting point (the first system 'pause') memory usage in KBs. The 2nd number is memory usage in KBs at the second system 'pause'. Memory usage is Private Bytes in Process Explorer\, which is all process unique memory given by the OS to the process. This number includes all "malloc" memory but not any memory mapped files (most of perl.exe/most of perl523.dll/etc) backed by disk storage\, or inter-process shared memory areas. The memory counts can only change in units of 4 KB (x86 page size). I am not sure why different runs produce slightly different amounts of mem usage (maybe perl hash seed randomization means different split levels\, malloc randomization by the OS).
ExtUtils::Constant is abandoned on CPAN with no maintainer so core patching is the only option. An existing note in Maintainers.pl refers to ExtUtils::Constant having questionable maintenance.
These patches are low impact patches which dont involve adding new APIs. I plan to completely rewrite how perl handles storing file paths\, which means new APIs and a higher risk of it being reverted. These are the last possible optimizations under the old (current) API.
This breaks Devel::Profit\, which I suspect will need a simple fix.
I expect it to (further) break Enbugger\, but that's failing fairly hard on blead already (and 5.20\, 5.22.)
Tony
On Tue Jul 14 23:50:31 2015\, tonyc wrote:
This breaks Devel::Profit\, which I suspect will need a simple fix.
There are 3 potential ways to fix Devel::Profit.
#1 PL_perldb |= PERLDBf_LINE;
But that probably slows down perl since it turns on debugging facilities\, DB callouts\, storing extra stuff. If the point of a profiler is to show difference in scale between code parts\, it is fine\, but PERLDBf_LINE will probably be slowing down the code even more from a unprofiled process. That might be an acceptable tradeoff.
#2 Create CopFILESVn(cop)
vivifies the GV and SCALAR of GV if needed\, with a private SV * Perl_gv_fetchfilesv(GV* gv) function to vivify SCALAR if SCALAR is NULL. Probably overkill since CopFILESV isn't public API and sparsely used http://grep.cpan.me/?q=CopFILESV+-file%3Appport.h (note indirect.xs's design\, that will probably need to be changed to #if defined(USE_ITHREADS) || PERLVER >= 5.023002 )
#3 Dont use CopFILESV\, instead use CopFILE. CopFILE is much more popular than CopFILESV on CPAN http://grep.cpan.me/?q=CopFILE\W+-file%3Appport.h (one day I am planning that there might be a CopFILEHEK instead of the current malloced char * on ithreads and GV * on unthreaded\, so CopFILESV shouldn't be encouraged on CPAN\, turning a HEK into a char * is just adding a fixed constant to the HEK *)
I attached patch for Profit.xs that does #1 and #3. Do you TonyC actually use Devel::Profit regularly or is was it just for testing?
-- bulk88 ~ bulk88 at hotmail.com
On Thu Jul 23 20:00:25 2015\, bulk88 wrote:
On Tue Jul 14 23:50:31 2015\, tonyc wrote:
This breaks Devel::Profit\, which I suspect will need a simple fix.
There are 3 potential ways to fix Devel::Profit.
#1 PL_perldb |= PERLDBf_LINE; *******stuff cut*************
Bump.
-- bulk88 ~ bulk88 at hotmail.com
On Thu Jul 23 20:00:25 2015\, bulk88 wrote:
On Tue Jul 14 23:50:31 2015\, tonyc wrote:
This breaks Devel::Profit\, which I suspect will need a simple fix.
There are 3 potential ways to fix Devel::Profit. ... I attached patch for Profit.xs that does #1 and #3. Do you TonyC actually use Devel::Profit regularly or is was it just for testing?
I've never used it\, it showed up when I used grep.cpan.me to try to see what the patch breaks.
I'm hesitant about applying the patch since I don't know what else it might break.
Does anyone else know of code this change might break?
Tony
* bulk88 via RT \perlbug\-followup@​perl\.org [2015-08-15T22:04:29]
Bump.
Bump. :-)
I've had this ticket flagged for a long time. I think it's reasonable for us to be cautious in the face of no expertise\, but right now it seems like "we're not sure what's up\, so we're doing nothing."
I wonder whether we're not better off trying it and seeing\, lest this patch languish forever. Alternately\, would someone like to work on becoming an expert on this area? :)
-- rjbs
On Thu Jan 28 15:01:20 2016\, perl.p5p@rjbs.manxome.org wrote:
* bulk88 via RT \perlbug\-followup@​perl\.org [2015-08-15T22:04:29]
Bump.
Bump. :-)
I've had this ticket flagged for a long time. I think it's reasonable for us to be cautious in the face of no expertise\, but right now it seems like "we're not sure what's up\, so we're doing nothing."
I wonder whether we're not better off trying it and seeing\, lest this patch languish forever. Alternately\, would someone like to work on becoming an expert on this area? :)
This patch series is sort of a precursor to sharing HEKs between ithreads. I have to review what cperl does and if rurban came up with his own solution or not and what can be borrowed from it if it exists\, but a COP's filename (used for all warning messages and perl debugger) is currently allocated\, with threads\, one malloc block per COP. That is insane. It means something like 25 bytes of overhead (lets round it to 32 or 64 bytes with malloc header)\, for almost EVERY line of perl source code with threads (lines that you can't set a breakpoint on\, have no COP op and therefore no file name).
My initial plans for shared filenames\, which are probably best implemented as a being a derivative of a HEK with a refcount as a struct field\, with most of the fields being compatible with HEKs. struct refcounted_he\, which looks like a "shared" rip off a SV looks too heavy weight. Filenames are always strings\, not IVs. Storing a filename as a "dualvar" is insane. Who has a perl source code file\, name "1"? Yes\, no .pl\, no .pm. Just a file called "1" on disk.
This part of taming source code file names in threaded perl got tamed\, http://perl5.git.perl.org/perl.git/commit/9b669ea1e2997fbb78558e1fc0a7ecae3aa23af0 but http://perl5.git.perl.org/perl.git/commit/9b669ea1e2997fbb78558e1fc0a7ecae3aa23af0 was a part of a number of ideas I had.
Shared HEKs are also best implemented (but not necessarily first implemented) with atomic CPU op refcounts\, instead of the current MUTEX_LOCK APIs in thread.h that use OS specific mutex function calls instead of CPU atomic instrinics. A global mutex for all SHEK opcounts is the first step\, like a number of other things in perl core that would be best done with atomics but instead are done with a global mutex for changing the count of a particular instance of a global struct. I have a patch to add CC atomics to perl that I never finished.
-- bulk88 ~ bulk88 at hotmail.com
On 29 Jan 2016\, at 12:37\, bulk88 via RT \perlbug\-followup@​perl\.org wrote: (*snip*) Who has a perl source code file\, name "1"? Yes\, no .pl\, no .pm. Just a file called "1" on disk.
FWIW\, I do. And β2β\, and β3β. Simple stuff I use during testing. Throwawayable for sure.
Also\, at former $work\, we had a lot of log files of which the name was simply the POSIX epoch at which they were generated (one for every second).
Just my 2c
Liz
* Elizabeth Mattijsen \liz@​dijkmat\.nl [2016-01-29 12:55]:
* On 29 Jan 2016\, at 12:37\, bulk88 via RT \perlbug\-followup@​perl\.org wrote:
Who has a perl source code file\, name "1"? Yes\, no .pl\, no .pm. Just a file called "1" on disk.
FWIW\, I do. And β2β\, and β3β. Simple stuff I use during testing. Throwawayable for sure.
Yeah. It wouldnβt do to restrict what filenames could be stored. But bulk88 actually kinda missed his own point here β whether anybody has files named like that is besides the point. This is what he wrote just before the part you quoted:
* bulk88 via RT \perlbug\-followup@​perl\.org [2016-01-29 12:40]:
Filenames are always strings\, not IVs. Storing a filename as a "dualvar" is insane.
So filenames that are just numbers could still be stored\, it would just not be possible to convert them to actual integers. Which I agree with him is⦠well\, maybe not insane outright\, but certainly a silly thing to spend resources on.
On Thu Jan 28 15:01:20 2016\, perl.p5p@rjbs.manxome.org wrote:
* bulk88 via RT \perlbug\-followup@​perl\.org [2015-08-15T22:04:29]
Bump.
Bump. :-)
I've had this ticket flagged for a long time. I think it's reasonable for us to be cautious in the face of no expertise\, but right now it seems like "we're not sure what's up\, so we're doing nothing."
I wonder whether we're not better off trying it and seeing\, lest this patch languish forever. Alternately\, would someone like to work on becoming an expert on this area? :)
Saving up to 24K of memory (and usually less) when loading all of Test::Harness\, Test::More\, CPAN\, CPAN::Meta\, ExtUtils::MakeMaker and Pod::Perldoc *and* their dependents doesn't seem worth the changes downstream code may need to make.
bulk88 provided a Devel::Profit patch*\, but what else does it break?
Tony
* which the maintainer can't use as is\, since it breaks the code on non-Win32
The proposed patches ( https://github.com/bulk88/perl/commit/ef023cf594697b1ef5538e87b977b8fb4ff06047 and https://github.com/bulk88/perl/commit/1bb089983281485e613a9f2fa8177a6dfec4e056 ) no longer apply.
Given no response from @bulk88, I'm going to close this.
If we want to pursue it further, it sounds like Devel::Profit needs a patch and perhaps we should move this to a PR?
Migrated from rt.perl.org#125569 (status was 'open')
Searchable as RT125569$