Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH] Speedup io/through.t and io/crlf_through.t #13544

Closed
p5pRT opened this issue Jan 20, 2014 · 9 comments
Closed

[PATCH] Speedup io/through.t and io/crlf_through.t #13544

p5pRT opened this issue Jan 20, 2014 · 9 comments

Comments

@p5pRT
Copy link

p5pRT commented Jan 20, 2014

Migrated from rt.perl.org#121042 (status was 'open')

Searchable as RT121042$

@p5pRT
Copy link
Author

p5pRT commented Jan 20, 2014

From @wolfsage

Created by wolfsage@gmail.com

Currently, io/crlf.t and io/crlf_through.t takes ~10 seconds each
to run on my machine.

They are using sleeps that I'm not convinced are needed.

By removing all but the first sleep (incase that's needed for
process synchronization) I've reduced the runtime of each to 2
seconds.

I temporarily reverted the associated fix that came with the tests
(93c2c2e) to test that my versions still catch the issues, and they
do.

Patch attached. Thanks,

-- Matthew Horsfall (alh)

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.14.2:

Configured by Debian Project at Mon Mar 18 19:16:26 UTC 2013.

Summary of my perl5 (revision 5 version 14 subversion 2) configuration:

  Platform:
    osname=linux, osvers=2.6.42-37-generic,
archname=x86_64-linux-gnu-thread-multi
    uname='linux batsu 2.6.42-37-generic #58-ubuntu smp thu jan 24
15:28:10 utc 2013 x86_64 x86_64 x86_64 gnulinux '
    config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN
-Dcccdlflags=-fPIC -Darchname=x86_64-linux-gnu -Dprefix=/usr
-Dprivlib=/usr/share/perl/5.14 -Darchlib=/usr/lib/perl/5.14
-Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5
-Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local
-Dsitelib=/usr/local/share/perl/5.14.2
-Dsitearch=/usr/local/lib/perl/5.14.2 -Dman1dir=/usr/share/man/man1
-Dman3dir=/usr/share/man/man3 -Dsiteman1dir=/usr/local/man/man1
-Dsiteman3dir=/usr/local/man/man3 -Duse64bitint -Dman1ext=1
-Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh
-Ud_ualarm -Uusesfio -Uusenm -Ui_libutil -DDEBUGGING=-g -Doptimize=-O2
-Duseshrplib -Dlibperl=libperl.so.5.14.2 -des'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DDEBIAN
-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -g',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing
-pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.6.3', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib/x86_64-linux-gnu /lib/../lib
/usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib /usr/lib
    libs=-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt
    perllibs=-ldl -lm -lpthread -lc -lcrypt
    libc=, so=so, useshrplib=true, libperl=libperl.so.5.14.2
    gnulibc_version='2.15'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -g -L/usr/local/lib
-fstack-protector'

Locally applied patches:



@INC for perl 5.14.2:
    /etc/perl
    /usr/local/lib/perl/5.14.2
    /usr/local/share/perl/5.14.2
    /usr/lib/perl5
    /usr/share/perl5
    /usr/lib/perl/5.14
    /usr/share/perl/5.14
    /usr/local/lib/site_perl
    .


Environment for perl 5.14.2:
    HOME=/home/mhorsfall
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/mhorsfall/perl5/perlbrew/bin:/home/mhorsfall/bin:/home/mhorsfall/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
    PERLBREW_BASHRC_VERSION=0.66
    PERLBREW_HOME=/home/mhorsfall/.perlbrew
    PERLBREW_ROOT=/home/mhorsfall/perl5/perlbrew
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Jan 20, 2014

From @wolfsage

0001-Sleep-only-once-so-tests-finishes-quickly.-2s-instea.patch
From af63287cda4a3bdbae03f0d80e09ff0bdcabf1ba Mon Sep 17 00:00:00 2001
From: Matthew Horsfall <WolfSage@gmail.com>
Date: Mon, 20 Jan 2014 12:25:26 -0500
Subject: [PATCH] Sleep only once so tests finishes quickly. (~2s instead of
 ~10s)

---
 t/io/through.t |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/io/through.t b/t/io/through.t
index 315de90..8c3a39f 100644
--- a/t/io/through.t
+++ b/t/io/through.t
@@ -112,7 +112,7 @@ sub testfile ($$$$$$) {
 }
 
 # shell-neutral and miniperl-enabled autoflush? qq(\x24\x7c) eq '$|'
-open my $fh, '-|', qq[$Perl -we "eval qq(\\x24\\x7c = 1) or die; binmode STDOUT; sleep 1, print for split //, qq(a\nb\n\nc\n\n\n)"] or die "open: $!";
+open my $fh, '-|', qq[$Perl -we "eval qq(\\x24\\x7c = 1) or die; binmode STDOUT; sleep 1; print for split //, qq(a\nb\n\nc\n\n\n)"] or die "open: $!";
 ok(1, 'open pipe');
 binmode $fh, q(:crlf);
 ok(1, 'binmode');
-- 
1.7.9.5

@p5pRT
Copy link
Author

p5pRT commented Jan 22, 2014

From @tonycoz

On Mon Jan 20 09​:36​:05 2014, alh wrote​:

Currently, io/crlf.t and io/crlf_through.t takes ~10 seconds each
to run on my machine.

They are using sleeps that I'm not convinced are needed.

By removing all but the first sleep (incase that's needed for
process synchronization) I've reduced the runtime of each to 2
seconds.

I temporarily reverted the associated fix that came with the tests
(93c2c2e) to test that my versions still catch the issues, and they
do.

Patch attached. Thanks,

Reverting the substantive parts of 93c2c2e (I didn't revert the comment change) didn't cause the test you modified to fail even without your change. (Win32 and Linux)

That said, from reading the original discussion of the problem, I don't think your change preserves the behaviour that was required to reproduce the original problem.

The original problem, if I understand it, was the user entering text from the keyboard and perlio's CRLF layer not handling those short reads correctly.

With your change, the child process is likely to arrive in a single read() in the parent process, so not matching the behaviour needed to reproduce the original bug.

Tony

@p5pRT
Copy link
Author

p5pRT commented Jan 22, 2014

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jan 24, 2014

From @wolfsage

On Tue, Jan 21, 2014 at 10​:17 PM, Tony Cook via RT
<perlbug-followup@​perl.org> wrote​:

Reverting the substantive parts of 93c2c2e (I didn't revert the comment change) didn't cause the test you modified to fail even without your change. (Win32 and Linux)

io/through.t passes for me with or without the application of 93c2c2e.

io/crlf_through.t is the one that fails when 93c2c2e is reverted,
though different tests fail, not the one I've modified.

I've noticed that the test I've changed​:

  # shell-neutral and miniperl-enabled autoflush? qq(\x24\x7c) eq '$|'
  open my $fh, '-|', qq[$Perl -we "eval qq(\\x24\\x7c = 1) or die;
binmode STDOUT; sleep 1, print for s$
  ok(1, 'open pipe');
  binmode $fh, q(​:crlf);
  ok(1, 'binmode');
  my (@​c, $c);
  push @​c, ord $c while $c = getc $fh;
  ok(1, 'got chars');
  is(scalar @​c, 9, 'got 9 chars');
  is("@​c", '97 10 98 10 10 99 10 10 10', 'got expected chars');

passes with or without 93c2c2e for both io/through.t and
io/crlf_throught.t, so now I'm not certain of its purpose or value.

Unfortunately I can't get Perl to build at 93c2c2e to see if perhaps
something else hasn't fixed it since then.

-- Matthew Horsfall (alh)

@p5pRT
Copy link
Author

p5pRT commented Feb 26, 2017

From @jkeenan

On Fri, 24 Jan 2014 13​:34​:43 GMT, alh wrote​:

On Tue, Jan 21, 2014 at 10​:17 PM, Tony Cook via RT
<perlbug-followup@​perl.org> wrote​:

Reverting the substantive parts of 93c2c2e (I didn't revert the
comment change) didn't cause the test you modified to fail even
without your change. (Win32 and Linux)

io/through.t passes for me with or without the application of
93c2c2e.

io/crlf_through.t is the one that fails when 93c2c2e is reverted,
though different tests fail, not the one I've modified.

I've noticed that the test I've changed​:

# shell-neutral and miniperl-enabled autoflush? qq(\x24\x7c) eq '$|'
open my $fh, '-|', qq[$Perl -we "eval qq(\\x24\\x7c = 1) or die;
binmode STDOUT; sleep 1, print for s$
ok(1, 'open pipe');
binmode $fh, q(​:crlf);
ok(1, 'binmode');
my (@​c, $c);
push @​c, ord $c while $c = getc $fh;
ok(1, 'got chars');
is(scalar @​c, 9, 'got 9 chars');
is("@​c", '97 10 98 10 10 99 10 10 10', 'got expected chars');

passes with or without 93c2c2e for both io/through.t and
io/crlf_throught.t, so now I'm not certain of its purpose or value.

Unfortunately I can't get Perl to build at 93c2c2e to see if perhaps
something else hasn't fixed it since then.

-- Matthew Horsfall (alh)

Matt, Tony​: Should this ticket remain open?

Thank you very much.
--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Feb 27, 2017

From @wolfsage

On Sun, Feb 26, 2017 at 5​:27 PM, James E Keenan via RT
<perlbug-followup@​perl.org> wrote​:

Matt, Tony​: Should this ticket remain open?

Thank you very much.

I don't think it's worth it. Feel free to close, thanks.

-- Matthew Horsfall (alh)

@p5pRT
Copy link
Author

p5pRT commented Feb 28, 2017

From @jkeenan

On Mon, 27 Feb 2017 14​:27​:38 GMT, alh wrote​:

On Sun, Feb 26, 2017 at 5​:27 PM, James E Keenan via RT
<perlbug-followup@​perl.org> wrote​:

Matt, Tony​: Should this ticket remain open?

Thank you very much.

I don't think it's worth it. Feel free to close, thanks.

TonyC is listed as Owner, so I'll let him make the final call.

-- Matthew Horsfall (alh)

--
James E Keenan (jkeenan@​cpan.org)

@khwilliamson
Copy link
Contributor

No response in 5 years; OP says ok to close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants