Skip to content
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

install: Detect cross-FS cache directory and find best one #12126

Draft
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

zackradisic
Copy link
Contributor

What does this PR do?

WIP need tests

Right now in the package manager, on initialization, we select an install cache directory and a temp directory that are on the same filesystem. This is because copy/moving files between filesystems is slow.

However, we don't ensure that the cache directory and the user's project directory (directory where package.json is) are on the same file system. If this is the case, then bun install becomes very slow.

This PR detects if the cache directory is on another filesystem from the project directory. If that is the case, then we either:

  1. warn the user (if they explicitly set the cache directory with an env variable)
  2. attempt to find the "best" cache directory on the same FS as the project dir

zackradisic and others added 25 commits June 20, 2024 22:20
Co-authored-by: Jarred Sumner <[email protected]>
Co-authored-by: Dylan Conway <[email protected]>
Co-authored-by: zackradisic <[email protected]>
Co-authored-by: Jarred Sumner <[email protected]>
tmpname: [:0]const u8,
) bool {
// Make sure cachedir and cwd are in the same filesystem
std.posix.renameatZ(dir_with_file_to_rename.fd, tmpname, dir_to_rename_file_to.fd, tmpname) catch return false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

None of these should be using std.posix

Copy link
Collaborator

Choose a reason for hiding this comment

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

and this doesn't test they're in the same filesystem. This tests it doesn't throw an error.

Copy link
Collaborator

Choose a reason for hiding this comment

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

and it shouldn't be in bun.sys unless it's reusable elsewhere

/// Invariants:
///
/// - node_modules_folder_path is absolute path with no relative syntax
pub fn findBestDirectoryInSameFileSystem(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can go in the package manager code

we don't need to do this elsewhere afaict

Copy link
Contributor

@zackradisic, your commit has failing tests :(

💪 1 failing tests Darwin AARCH64

  • test/cli/install/bun-run.test.ts 2 failing

💻 1 failing tests Darwin x64 baseline

  • test/cli/install/bun-run.test.ts 2 failing

💻 1 failing tests Darwin x64

  • test/cli/install/bun-run.test.ts 2 failing

🐧💪 1 failing tests Linux AARCH64

  • test/cli/install/bun-run.test.ts 2 failing

🐧🖥 1 failing tests Linux x64 baseline

  • test/cli/install/bun-run.test.ts 2 failing

🐧🖥 1 failing tests Linux x64

  • test/cli/install/bun-run.test.ts 2 failing

🪟💻 3 failing tests Windows x64 baseline

  • test/cli/install/bun-add.test.ts 1 failing
  • test/cli/install/bun-run.test.ts 2 failing
  • test/cli/install/registry/bun-install-registry.test.ts 1 failing

🪟💻 3 failing tests Windows x64

  • test/cli/install/bun-add.test.ts 1 failing
  • test/cli/install/bun-run.test.ts 2 failing
  • test/cli/install/registry/bun-install-windowsshim.test.ts code 1

View logs

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.

None yet