Skip to content
  • Jorge Manrubia's avatar
    ecc5afed
    Parallelize tests only when overhead is justified · ecc5afed
    Jorge Manrubia authored
    Parallelizing tests has a cost in terms of database setup and fixture
    loading. This change makes Rails disable parallelization when the number
    of tests is below a configurable threshold.
    
    When running tests in parallel each process gets its own database
    instance. On each execution, each process will update each database
    schema (if needed) and load all the fixtures. This can be very expensive
    for non trivial datasets.
    
    As an example, for HEY, when running a single file with 18 tests,
    running tests in parallel in my box adds an overhead of 13 seconds
    versus not parallelizing them. Of course parallelizing is totally worthy
    when there are many tests to run, but not when running just a few tests.
    
    The threshold is configurable via
    config.active_support.test_parallelization_minimum_number_of_tests,
    which is 30 50 by default.
    
    This also adds some tracing to know how tests are being executed:
    
    When in parallel:
    
    ```
    Running 2829 tests in parallel in 8 processes
    ```
    
    When not in parallel:
    
    ```
    Running 15 tests in a single process (parallelization threshold is 30)
    ```
    ecc5afed
    Parallelize tests only when overhead is justified
    Jorge Manrubia authored
    Parallelizing tests has a cost in terms of database setup and fixture
    loading. This change makes Rails disable parallelization when the number
    of tests is below a configurable threshold.
    
    When running tests in parallel each process gets its own database
    instance. On each execution, each process will update each database
    schema (if needed) and load all the fixtures. This can be very expensive
    for non trivial datasets.
    
    As an example, for HEY, when running a single file with 18 tests,
    running tests in parallel in my box adds an overhead of 13 seconds
    versus not parallelizing them. Of course parallelizing is totally worthy
    when there are many tests to run, but not when running just a few tests.
    
    The threshold is configurable via
    config.active_support.test_parallelization_minimum_number_of_tests,
    which is 30 50 by default.
    
    This also adds some tracing to know how tests are being executed:
    
    When in parallel:
    
    ```
    Running 2829 tests in parallel in 8 processes
    ```
    
    When not in parallel:
    
    ```
    Running 15 tests in a single process (parallelization threshold is 30)
    ```
Loading