develooper Front page | perl.perl5.porters | Postings from February 2003

[perl #20799] Bug: 5.6 Win32-List context IO op hangs on second use when reading large files.

From:
Yves Orton
Date:
February 11, 2003 12:45
Subject:
[perl #20799] Bug: 5.6 Win32-List context IO op hangs on second use when reading large files.
Message ID:
rt-20799-50623.3.80499646514139@bugs6.perl.org
# New Ticket Created by  "Yves Orton" 
# Please include the string:  [perl #20799]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=20799 >



This is a bug report for perl from demerphq at hotmail.com,
generated with the help of perlbug 1.33 running under perl v5.6.1.


-----------------------------------------------------------------
[Please enter your report here]

It appears that under Win32 (98 and Win2k) that the IO operator in
list context when reading a file for the second time takes a very
long time.

If you slurp the file and then split it, or use while (<>) to push
onto a list the times are consistent and reasonable.

When the IO operator is used in list context the second read takes
a very long time. (I hit ctrl-c after 5 minutes)

The file is an 8.5MB word list. I profiled the memory usage and it stays 
stable.  No swapping.  CPU goes to max tho.

This doesn't appear to affect machines running under *nix.

Also is the variation in speeds to be expected?  First read for
split_slurp is ~1 second and its ~7 seconds for <> in list context.

C:\Temp>set prompt=$t $p$g

21:13:59.41 C:\Temp>perl test.pl split_slurp 
d:\perl\DevLib\Scrabble\dict.txt
Sun Feb  9 21:14:06 2003
Trying split_slurp 3 times
Try 1
Read 172456
Took 1 seconds.
Try 2
Read 172456
Took 3 seconds.
Try 3
Read 172456
Took 3 seconds.
Sun Feb  9 21:14:13 2003 Bye

21:14:13.20 C:\Temp>perl test.pl while_io d:\perl\DevLib\Scrabble\dict.txt
Sun Feb  9 21:14:25 2003
Trying while_io 3 times
Try 1
Read 172456
Took 3 seconds.
Try 2
Read 172456
Took 5 seconds.
Try 3
Read 172456
Took 5 seconds.
Sun Feb  9 21:14:38 2003 Bye

21:14:38.26 C:\Temp>perl test.pl list_io d:\perl\DevLib\Scrabble\dict.txt
Sun Feb  9 21:14:43 2003
Trying list_io 3 times
Try 1
Read 172456
Took 7 seconds.
Try 2
^C
21:19:13.60 C:\Temp>

#!perl

#test.pl
use strict;
use warnings;
$|++;

my %subs = (
            list_io =>
            sub {
        		# Second time round this will take
        		# a loooooong time.
				my $file=shift;
				my @line;
				open my($fh), $file;
				@line= <$fh>;
				close($fh);
				return \@line;
			},

			split_slurp =>
			sub {
				my $file=shift;
				my @line;
				local $/;
			  	open my($fh), $file;
				@line=split /\n/,<$fh>;
				close($fh);
				return \@line;
			},

            while_io =>
            sub {
				my $file=shift;
				my @line;
			 	open my($fh), $file;
			 	push @line,$_ while <$fh>;
				close($fh);
				return \@line;
			},
          );


my $test = shift @ARGV;
my $file = shift @ARGV;

$subs{$test} or die "Don't know test $test\n";

print localtime()."\nTrying $test 3 times\n";
for my $try (1..3)  {
	print "Try $try\n";
	my $start=time;

	my $lines = $subs{$test}->($file);
	print "Read ".scalar(@$lines)."\n";
	print "Took ".(time-$start)." seconds.\n";
}
print localtime()." Bye\n";




[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=medium
---
Site configuration information for perl v5.6.1:

Configured by ActiveState at Mon Jun 17 21:32:50 2002.

Summary of my perl5 (revision 5 version 6 subversion 1) configuration:
  Platform:
    osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    usethreads=undef use5005threads=undef useithreads=define 
usemultiplicity=define
    useperlio=undef d_sfio=undef uselargefiles=undef usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
  Compiler:
    cc='cl', ccflags ='-nologo -O1 -MD -DNDEBUG -DWIN32 -D_CONSOLE 
-DNO_STRICT -DHAVE_DES_FCRYPT  -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS 
-DPERL_MSVCRT_READFIX',
    optimize='-O1 -MD -DNDEBUG',
    cppflags='-DWIN32'
    ccversion='', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', 
lseeksize=4
    alignbytes=8, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='link', ldflags ='-nologo -nodefaultlib -release  
-libpath:"D:/Perl\lib\CORE"  -machine:x86'
    libpth="D:\Perl\lib\CORE"
    libs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib 
uuid.lib wsock32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib 
msvcrt.lib
    perllibs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib 
uuid.lib wsock32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib 
msvcrt.lib
    libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl56.lib
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -release  
-libpath:"D:/Perl\lib\CORE"  -machine:x86'

Locally applied patches:
    ACTIVEPERL_LOCAL_PATCHES_ENTRY

---
@INC for perl v5.6.1:
    D:/Perl/lib
    D:/Perl/site/lib
    .

---
Environment for perl v5.6.1:
    HOME (unset)
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=D:\Perl\bin\
    SHELL (unset)





_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE* 
http://join.msn.com/?page=features/junkmail





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