Skip to content

Potential performance regression with Python 3.14 bench_mp_pool on Linux #139881

Description

@NoAnyLove

Bug report

Bug description:

Hi team, I was running pyperformance and found that the bench_mp_pool in 3.14 was way more slower than in 3.13.

I uses pyperformance-1.11.0 installed from master branch and conda-forge Python builds, the system is Ubuntu 22.04.

+-------------------+-----------------------------+-----------------------------+
| Benchmark         | Python 3.13.7               | Python 3.14.0               |
+===================+=============================+=============================+
| bench_mp_pool     | 6.08 ms                     | 1.91 sec: 315.05x slower    |
+-------------------+-----------------------------+-----------------------------+

I also tried it on another Ubuntu 22.04 box, it was better but still tens of times slower,

+-------------------+-----------------------------+-----------------------------+
| Benchmark         | Python 3.13.7               | pPython 3.14.0              |
+===================+=============================+=============================+
| bench_mp_pool     | 13.4 ms                     | 367 ms: 27.42x slower       |
+-------------------+-----------------------------+-----------------------------+

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Activity

  1. LamentXU123 commented on Oct 10, 2025

    @LamentXU123
  2. picnixz commented on Oct 10, 2025

    @picnixz
    Member

    Maybe it's because we are changing the default start method? we switched from fork to forkserver on Linux in Python 3.14. Could you try to alter the benchmark and explicitly call multiprocessing.set_start_method("fork") to see what happens? (I don't know where you should put that call though...)

    We don't see that much drop of performance on bench_mp_pool on the main branch:

    @LamentXU123 That's not a comparison between 3.14 and 3.13.

  3. added
    pendingThe issue will be closed if no feedback is provided
    on Oct 10, 2025
  4. NoAnyLove commented on Oct 11, 2025

    @NoAnyLove
    Author

    @picnixz I think you're right, 3.14 matches 3.13 after adding multiprocessing.set_start_method("fork").

    btw, I'm running benchmarks on a small Ubuntu VM with a few cores, 3.14 is only a few times slower than 3.13.

    Without multiprocessing.set_start_method("fork"),

    +-------------------+---------+-----------------------+
    | Benchmark         | py313   | py314                 |
    +===================+=========+=======================+
    | bench_mp_pool     | 15.6 ms | 43.1 ms: 2.77x slower |
    +-------------------+---------+-----------------------+
    

    With multiprocessing.set_start_method("fork"),

    +-------------------+------------+-----------------------+
    | Benchmark         | py313_fork | py314_fork            |
    +===================+============+=======================+
    | bench_mp_pool     | 16.6 ms    | 16.3 ms: 1.02x faster |
    +-------------------+------------+-----------------------+
    
  5. picnixz commented on Oct 12, 2025

    @picnixz
    Member

    @gpshead Was such slowdown actually planned or is it a legitimate issue somewhere?

  6. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Oct 12, 2025
  7. eendebakpt commented on Oct 27, 2025

    @eendebakpt
    Contributor

    The PR introducing the slowdown is #101556. But according to the python speed center python 3.15 will have a speedup again:

    Image
  8. chris-eibl commented on Oct 30, 2025

    @chris-eibl
    Member

    Yeah, that's basically what @LamentXU123 has posted above #139881 (comment), but it got hidden. Looking what happened around that time in September it must have been #135295 (commit 0912b3a) that cured it. @thesamesam already mentioned the related issue #126631.

    #137996 got closed as duplicate of this issue, so most probably this issue here can be closed as duplicate as well?

    Since the associated PR got also backported to 3.14 #138607 (commit 64f0e2d) and thus will be part of 3.14.1.

    And it was also backported to 3.13 #138609 (commit 9a6137a) and is part of 3.13.8 and 3.13.9. It had less effect on speed there, since, as mentioned above, the default start method on 3.13 is still fork. I am quite confident, that 3.13 without that fix would show worse performance for forkserver as well?

  9. thesamesam commented on Nov 22, 2025

    @thesamesam
    Contributor

    #86354 (pending PR #139537) could have a performance impact as well.

  10. gpshead commented on Nov 22, 2025

    @gpshead
    Member

    The default start method change was intentional and long planned. I don't think it is very useful for that benchmark to focus on the default start method. Explicitly benchmarking each one is a more interesting comparison.

  11. gpshead commented on Nov 22, 2025

    @gpshead
    Member

    anyways I agree that we can close this as (a) it was planned and (b) the bugfix for __main__ preloading being in 3.14.1 happens to make it happier.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    pendingThe issue will be closed if no feedback is providedperformancePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directorytopic-multiprocessingtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions