Skip to content

2-5x slowdown, long-standing Event performance regression #104391

@xloem

Description

@xloem

Bug report

The below example completes in 6s for me with python2.7, but takes 21s for me in python3 . As of yet, I have not found any workaround to speed it up in python3.

import os, threading
lock = threading.Lock()
event = threading.Event()
def worker():
    for ct in range(4000):
        while not event.is_set():
            event.wait(1)
        with lock:
            event.clear()
def test():
    thread = threading.Thread(target=worker)
    thread.start()
    while thread.is_alive():
        with lock:
            event.set()
test()

Your environment

  • CPython versions tested on:
    • 2.7.5
    • 3.10.11
  • Operating system and architecture:
    • Red Hat Enterprise Linux 7 x86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions