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

Deprecate conda_build.utils.samefile in favor of path to package mapping #5130

Merged
merged 10 commits into from
Jan 4, 2024

Conversation

kenodegard
Copy link
Contributor

@kenodegard kenodegard commented Jan 2, 2024

Description

The which_package refactor #5041 switched from using os.path.normcase to compare paths to calling Path.samefile which calls os.stat. This became especially expensive for certain builds so we need to revert revisit this change.

The proposal here is to implement a cached mapping of files to packages making which_package into O(n) for the first lookup and O(1) for all subsequent lookups.

We add a benchmark/battery test to better compare implementations. Here are the results of running the benchmark test with a few different versions/ideas:

Version/Idea Time
3.27.0 ~9s
3.28.2 ~16m48s
normpath ~1m6s
normcase ~35s
mapping ~2s

Resolves #5126

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

@kenodegard kenodegard self-assigned this Jan 2, 2024
@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Jan 2, 2024
@kenodegard kenodegard mentioned this pull request Jan 2, 2024
67 tasks
jezdez
jezdez previously approved these changes Jan 2, 2024
@kenodegard kenodegard force-pushed the samefile-regression branch from 8821ff9 to 6b0f82e Compare January 3, 2024 15:18
@kenodegard kenodegard changed the title Deprecate conda_build.utils.samefile in favor of os.path.normpath Deprecate conda_build.utils.samefile in favor of path to package mapping Jan 3, 2024
assert set(precs_hardlinkB) == {precB}


@pytest.mark.benchmark
Copy link
Member

Choose a reason for hiding this comment

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

Noice!! This'll go well with codspeed.

@kenodegard kenodegard merged commit 6edc3dc into conda:3.28.x Jan 4, 2024
24 checks passed
@kenodegard kenodegard deleted the samefile-regression branch January 4, 2024 18:29
@kenodegard kenodegard linked an issue Jan 4, 2024 that may be closed by this pull request
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed [bot] added once the contributor has signed the CLA
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Package checks extremely slow with large build environments
3 participants