Skip to content

Perf work #5740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 21, 2023
Merged

Perf work #5740

merged 4 commits into from
Sep 21, 2023

Conversation

arcanis
Copy link
Member

@arcanis arcanis commented Sep 15, 2023

What's the problem this PR addresses?

This diff implements a couple of small performance improvements.

How did you fix it?

  • Removed nodeUtils.builtinModules (use module.builtinModules)
  • Optimized some ppath functions on non-win32 platforms
  • Removed toFilename (just cast to Filename if needed)
  • The yarnPath same-file check now uses inodes on non-win32 platforms
  • Hoisted a couple of regexps to avoid re-instantiations
Command Mean [ms] Min [ms] Max [ms] Relative
before 236.5 ± 2.7 233.2 241.0 1.06 ± 0.02
after 222.7 ± 3.2 219.6 230.7 1.00

Checklist

  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

Comment on lines +976 to +987
async function isSameBinaryInode(a: PortablePath, b: PortablePath) {
const [aStat, bStat] = await Promise.all([
xfs.statPromise(a),
xfs.statPromise(b),
]);

return aStat.dev === bStat.dev && aStat.ino === bStat.ino;
}

const isSameBinary = process.platform === `win32`
? isSameBinaryContent
: isSameBinaryInode;
Copy link
Member

@merceyz merceyz Sep 15, 2023

Choose a reason for hiding this comment

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

This wont catch cases where the file content is the same but the inode isn't, for example with Corepack and yarnPath the inode (most likely) wont be the same but the content probably is.

Copy link
Member Author

Choose a reason for hiding this comment

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

Having exactly the same version in Corepack and yarnPath (considering that V4 use Corepack without yarnPath when possible) seems in theory unlikely enough that it's tolerable

Perhaps a problem though is that existing projects will have a hard time noticing that they should remove yarnPath from their configuration and fully migrate to Corepack... 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll make a separate PR to add a warning when yarnPath is detected when it could be Corepack

@arcanis arcanis merged commit 9287251 into master Sep 21, 2023
@arcanis arcanis deleted the mael/perf-cleanups branch September 21, 2023 09:11
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.

2 participants