Skip to content

🚀 Feature: Make parallel mode smarter #4322

Open

Description

I have a couple ideas for improvements here now that we're past the MVP:

  1. Detect if we're only running a single file, and disable parallel mode automatically. Running a single file in parallel mode will always (AFAIK) be slower than running in serial. Add a command-line option to disable this behavior (a general-purpose, contextual --force might be helpful)
  2. Automatic optimization via duration caching
    • Cache per file durations (cache could live in node_modules/.cache/mocha, which is an unofficial convention).
      • This would be timing the run() call in lib/nodejs/worker.js, from beginning to end.
      • Maybe calculate the mean over n most recent runs?
    • On subsequent runs, execute slowest test files first. This will help avoid the case at the end of the run where there's only a single worker process, munching on a meaty test file, and the other workers are idle. TypeScript uses a strategy like this in their custom tooling around Mocha (look at their implementation for ideas).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    area: parallel modeRegarding parallel modesemver-majorimplementation requires increase of "major" version number; "breaking changes"status: accepting prsMocha can use your help with this one!type: featureenhancement proposal

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions