From 6eb96290faf5beade356370e056e8011cc741de9 Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Thu, 29 Feb 2024 11:03:19 +0100 Subject: [PATCH] mach: Speed up `taplo` runs on MacOS (#31452) `taplo` is the TOML formatter that we use. It seems to be using a very slow directory walking mechanism on MacOS. This change works around that issue by explicitly listing globs of TOML files to format and check. Before: ```text real 0m17.632s user 0m2.164s sys 0m6.916s ``` After: ```text real 0m1.519s user 0m1.391s sys 0m0.112s ``` --- python/servo/testing_commands.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py index 36c51fd250b..779face4a45 100644 --- a/python/servo/testing_commands.py +++ b/python/servo/testing_commands.py @@ -48,6 +48,18 @@ UNSTABLE_RUSTFMT_ARGUMENTS = [ "--config", "group_imports=StdExternalCrate", ] +# Listing these globs manually is a work-around for very slow `taplo` invocation +# on MacOS machines. If `taplo` runs fast without the globs on MacOS, this +# can be removed. +TOML_GLOBS = [ + "*.toml", + ".cargo/*.toml", + "components/*/*.toml", + "components/shared/*.toml", + "ports/*/*.toml", + "support/*/*.toml", +] + def format_toml_files_with_taplo(check_only: bool = True) -> int: taplo = shutil.which("taplo") @@ -56,9 +68,9 @@ def format_toml_files_with_taplo(check_only: bool = True) -> int: return 1 if check_only: - return call([taplo, "fmt", "--check"], env={'RUST_LOG': 'error'}) + return call([taplo, "fmt", "--check", *TOML_GLOBS], env={'RUST_LOG': 'error'}) else: - return call([taplo, "fmt"], env={'RUST_LOG': 'error'}) + return call([taplo, "fmt", *TOML_GLOBS], env={'RUST_LOG': 'error'}) @CommandProvider