avajs/ava

Reuse test worker processes for better performance.

jamestalmage opened this issue · 1 comments

Currently AVA guarantees a fresh process for every test file. This has real benefits, but comes with a hefty performance penalty. The maintainers have discussed, and we have decided to provide a way to opt-in to reusing a process for multiple test files.

General outline

  • Determine how many child processes to use based on os.cpus()

  • Provide a per-file means of opting into the behavior. One idea for such an opt-in mechanism is to simply change the import, and use static analysis to determine behavior.

    // reuses the shared processes with other tests
    import test from "ava/shared"; 
  • Randomize which tests are sent to which process, and in which order (this provides some protection against writing bad tests that interfere with other tests). It might be wise to consider creating a log of that randomized order and saving it to disk so it can be reproduced.

  • Use Node's vm module to provide some protection against cross-test pollution.

Priority

We think this is important, but we are going to defer it for the time being and work on #785 first. Parts of that are required to make this happen anyway. Once that is landed, we will re-evaluate this and begin work on it.

I am locking this issue for the time being. As stated, this is a priority, and we are working towards it. We just don't want the team distracted by bikeshedding on this issue.

We should have an option to run tests in a sandbox in the main process. We should explore that before running the sandbox inside workers. I've been pruning our issue backlog, there might be an issue for sandbox support already, but if not I'll make sure to open it. Closing this as overly complex for now.


2018-01-9: See #1332 which covers running test files in the same process.