Skip to content

Conversation

@marcins
Copy link
Contributor

@marcins marcins commented Jul 30, 2025

Motivation

macOS integration tests seem to be getting slower again. Profiling revealed two large hot spots both originating from the Cache tests:

Changes

This PR changes the watcher backend to fs-events on macOS. This reduces the CI time by approx 4-5 min (from ~30min to ~26min) based on two test runs.

I did also try and optimise the assertNoFilePathInCache but the few things I tried weren't any faster (using a chunked faster string search algo, scanning in a promise queue, using a Rust based function for searching for the string in the file).

assertNoFilePathInCache was optimised to use a promise queue to check files - testing with Hyperfine locally showed the best value for concurrency was 50, this reduces macOS test time by another ~5 min and Linux by ~2 min.

Checklist

  • Existing or new tests cover this change
  • There is a changeset for this change, or one is not required
  • Added documentation for any new features to the docs/ folder

[no-changeset]: private packages only

@changeset-bot
Copy link

changeset-bot bot commented Jul 30, 2025

⚠️ No Changeset found

Latest commit: 5ac273b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@marcins marcins force-pushed the mszczepanski/improve-mac-integration-test-perf branch 2 times, most recently from 2f32582 to edb0e79 Compare July 30, 2025 05:49
@marcins marcins marked this pull request as ready for review July 30, 2025 23:00
@marcins marcins requested a review from a team as a code owner July 30, 2025 23:00
@marcins
Copy link
Contributor Author

marcins commented Jul 30, 2025

Just doing some more benchmarking, looks like fs-events might be faster than brute-force on Mac, will push up the change and see what the time is in CI again..

marcins added 2 commits July 31, 2025 13:22
* Use brute-force watcher on darwin only
…edup

Don't use fast-glob, it doesn't work with Atlaspack fs :P

Improve some comments
@marcins marcins force-pushed the mszczepanski/improve-mac-integration-test-perf branch from c575009 to 5ac273b Compare July 31, 2025 03:22
"posthtml": "^0.16.5",
"posthtml-parser": "^0.10.1",
"resolve": "^1.12.0",
"rimraf": "^5.0.5",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't get why I have to add these as half the time running yarn add in a workspace will throw an error about rimraf being required but not being present in the workspace.

"license": "(MIT OR Apache-2.0)",
"private": true,
"main": "src/index.js",
"main": "./lib/index.js",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes running the Mocha profiler (via ATLASPACK_PROFILE_MOCHA=true) with TypeScript.

{
inputFS: overlayFS,
shouldDisableCache: false,
watchBackend: os.platform() === 'darwin' ? 'fs-events' : undefined,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't fs-events the default on mac anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If watchman is present it uses watchman, which I believe is the case in our CI.

// For debugging purposes, log all instances of the projectRoot in the cache.
// Otherwise, fail the test if one is found.
if (process.env.ATLASPACK_DEBUG_CACHE_FILEPATH != null)
return assertNoFilePathInCacheDebug(fs, dir, projectRoot);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No brace hey? How fancy of you

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possibly Cursor's fault and I didn't notice.. if you don't like it, lint for it 🧌

Copy link
Contributor

@mattcompiles mattcompiles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one mate

@marcins marcins merged commit 2f29297 into main Jul 31, 2025
20 checks passed
@marcins marcins deleted the mszczepanski/improve-mac-integration-test-perf branch July 31, 2025 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants