Skip to content

oxfmt: sequential pre-scan wastes a lot of time on repos with no nested configs #22225

@marvinhagemeister

Description

@marvinhagemeister

I'm benchmarking oxfmt on a big repo with around 50k directories. Running it through samply reveals that the majority of time is spent calling fs::metadata on many places. The project has a single .oxfmtrc.json at the root. Running it with --disable-nested-config sidesteps the issue and is a current workaround.

Mode Time
default 6.1s
--disable-nested-config 2.5s

So far I have traced it down to prescan_config_locations() as the key issue. It runs a sequential walk over every directory before the parallel main walk starts. For each directory it calls 3 separate fs::metadata / path.is_file() calls.

for path in [
dir.join(self.config_file_names.json),
dir.join(self.config_file_names.jsonc),
dir.join(self.config_file_names.js),
] {

Default:

Image Image

With --disable-nested-config:

Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions