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

Reduce the time test_subprocess takes to complete. #82637

Open
gpshead opened this issue Oct 12, 2019 · 8 comments
Open

Reduce the time test_subprocess takes to complete. #82637

gpshead opened this issue Oct 12, 2019 · 8 comments
Assignees
Labels
3.9 performance tests

Comments

@gpshead
Copy link
Member

@gpshead gpshead commented Oct 12, 2019

BPO 38456
Nosy @gpshead, @vstinner, @pablogsal
PRs
  • #16736
  • #16737
  • #16739
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/gpshead'
    closed_at = None
    created_at = <Date 2019-10-12.21:27:44.358>
    labels = ['tests', '3.9', 'performance']
    title = 'Reduce the time test_subprocess takes to complete.'
    updated_at = <Date 2020-10-20.17:33:23.874>
    user = 'https://github.com/gpshead'

    bugs.python.org fields:

    activity = <Date 2020-10-20.17:33:23.874>
    actor = 'gregory.p.smith'
    assignee = 'gregory.p.smith'
    closed = False
    closed_date = None
    closer = None
    components = ['Tests']
    creation = <Date 2019-10-12.21:27:44.358>
    creator = 'gregory.p.smith'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 38456
    keywords = ['patch']
    message_count = 8.0
    messages = ['354554', '354557', '354563', '354648', '354649', '354651', '379077', '379147']
    nosy_count = 3.0
    nosy_names = ['gregory.p.smith', 'vstinner', 'pablogsal']
    pr_nums = ['16736', '16737', '16739']
    priority = 'low'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'performance'
    url = 'https://bugs.python.org/issue38456'
    versions = ['Python 3.9']

    @gpshead
    Copy link
    Member Author

    @gpshead gpshead commented Oct 12, 2019

    test_subprocess is one of our long running tests, this slows down CI and buildbots. There is room for improvement in its total execution time.

    Use this issue as a rollup issue for any such work. we need to keep it reliable, just focus on reducing either user/sys cpu time or wall time.

    @gpshead gpshead added the 3.9 label Oct 12, 2019
    @gpshead gpshead self-assigned this Oct 12, 2019
    @gpshead gpshead added tests performance labels Oct 12, 2019
    @gpshead
    Copy link
    Member Author

    @gpshead gpshead commented Oct 12, 2019

    New changeset 67b93f8 by Gregory P. Smith in branch 'master':
    bpo-38456: Use /bin/true in test_subprocess (GH-16736)
    67b93f8

    @pablogsal
    Copy link
    Member

    @pablogsal pablogsal commented Oct 13, 2019

    New changeset 46113e0 by Pablo Galindo in branch 'master':
    bpo-38456: Handle the case when there is no 'true' command (GH-16739)
    46113e0

    @gpshead
    Copy link
    Member Author

    @gpshead gpshead commented Oct 14, 2019

    New changeset 4f0587f by Gregory P. Smith in branch '3.8':
    [3.8] bpo-38456: Use /bin/true in test_subprocess (GH-16737)
    4f0587f

    @vstinner
    Copy link
    Member

    @vstinner vstinner commented Oct 14, 2019

    Nice. Any idea of the speedup on Travis CI and/or on a specific buildbot worker?

    @gpshead
    Copy link
    Member Author

    @gpshead gpshead commented Oct 14, 2019

    I assume the CI systems are shared and potentially noisy. It should be easier to look at some logs from slower buildbots. but sadly test_subprocess has fallen off the list of "10 slowest tests" that timing info is supplied for. concurrent.futures, multiprocessing, asyncio, tokenize, etc. all take longer.

    I still don't expect it to be more than a few seconds.

    @gpshead
    Copy link
    Member Author

    @gpshead gpshead commented Oct 20, 2020

    the slowest tests on Linux today (with number of seconds prepended on my system that runs the suite serially in 34 seconds on a debug build):

    3.01 test_check_output_stdout_arg (test.test_subprocess.ProcessTestCaseNoPoll) ... ok
    3.01 test_check_output_stdout_arg (test.test_subprocess.ProcessTestCase) ... ok
    3.0 test_check_output_stdin_with_input_arg (test.test_subprocess.RunFuncTestCase) ... ok
    2.28 test_issue8780 (test.test_subprocess.ProcessTestCase) ... ok
    2.27 test_issue8780 (test.test_subprocess.ProcessTestCaseNoPoll) ... ok
    2.04 test_communicate_BrokenPipeError_stdin_write (test.test_subprocess.POSIXProcessTestCase) ... ok
    1.45 test_leak_fast_process_del_killed (test.test_subprocess.POSIXProcessTestCase) ... ok
    1.04 test_communicate_stdout (test.test_subprocess.ProcessTestCase) ... ok
    1.03 test_communicate_stdout (test.test_subprocess.ProcessTestCaseNoPoll) ... ok
    1.03 test_kill (test.test_subprocess.POSIXProcessTestCase) ... ok
    1.03 test_send_signal (test.test_subprocess.POSIXProcessTestCase) ... ok
    1.03 test_terminate (test.test_subprocess.POSIXProcessTestCase) ... ok
    0.636 test_communicate_timeout (test.test_subprocess.ProcessTestCase) ... ok
    0.636 test_communicate_timeout (test.test_subprocess.ProcessTestCaseNoPoll) ... ok
    0.58 test_swap_fds (test.test_subprocess.POSIXProcessTestCase) ... ok

    @gpshead
    Copy link
    Member Author

    @gpshead gpshead commented Oct 20, 2020

    fyi - handy command to get that

    python -m test.regrtest -v test_subprocess | ts '.%s'

    then process that using whatever you want to compute deltas and sort. i fed the output of that into:

    #!/usr/bin/python3
    """Parse `python -m test.regrtest -v | ts '.%s'` output, report slowest."""
    
    import sys
    from typing import Sequence, Tuple
    
    
    infile = sys.stdin
    
    deltas: Sequence[Tuple[float, str]] = []
    
    prev_secs: float = 0.
    prev_test: str = ''
    for line in infile:
      stripped_line = line.strip()
      if ' ' not in stripped_line:
        continue
      num, test = stripped_line.split(None, 1)
      secs = float(num)
      delta = secs - prev_secs if prev_secs else 0.
      if '... ok' or '... skipped' in test:  # Not extraneous output.
        # Assign the accumulated time to the previous test.
        deltas.append((delta, prev_test))
        prev_secs = secs
        prev_test = test
    
    for secs, test in reversed(sorted(deltas, key=lambda x:x[0])[-23:]):
      print(f'{secs:.3} {test}')
    

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 performance tests
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants