Skip to content

watchdog reloader uses excessive CPU #3054

@raylu

Description

@raylu

the watchdog reloader calls run_step every second by default

self.run_step()

on our project with 13,000 files, this causes os.path.isfile to take 15% of a CPU core

I ran py-spy record --pid ... --output profile.speedscope.json --format speedscope for about 8 seconds on an idle app. you can place profile.speedscope.json into https://www.speedscope.app/ and see 8 calls to run() which take about 150ms each:
Image

increasing ReloaderLoop.interval helps a lot, but means reloads have to wait for the next iteration


Environment:

  • Python version: 3.12.7
  • Werkzeug version: 3.0.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions