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

refactor: version implementation #227

Merged
merged 7 commits into from
Jun 23, 2023
Merged

Conversation

baszalmstra
Copy link
Collaborator

@baszalmstra baszalmstra commented Jun 21, 2023

This PR does a complete refactor of the version implementation. The primary goal was to reduce the memory footprint because versions are used in RepoData quite a lot. The secondary goal was to simplify the implementation, I think I achieved this by returning an iterator of the version segments vs accessing multiple arrays to get to the data. The implementation of the flag makes it a bit more complex though. If based on a review this is the case I have some ideas.

Just like the previous implementation, this implementation tries to keep most memory on the stack unless the version requires more memory. Most versions are in the form of 1.2.3 so we can take advantage of that. The new implementation takes 136 128 bytes of stack memory per Version. The old one was 440. Changes in heap allocations remain the same. More research is needed to figure out how to further reduce this.

I will follow up this PR with another one that refactors the parsing to make it more robust.

Ideally, I also wanted to add some benchmarking but didn't get the time to. Perhaps that's for later!

Oh yeah, this implementation also fixes #255. With the new implementation, it was much simpler to implement dropping a segment for comparison without allocation.

Fix #225

@baszalmstra baszalmstra requested a review from wolfv June 21, 2023 20:46
@baszalmstra baszalmstra self-assigned this Jun 21, 2023
@@ -7,7 +7,7 @@ use std::path::{Path, PathBuf};
#[derive(Debug, Clone)]
pub struct PythonInfo {
/// The major and minor version
pub short_version: (usize, usize),
pub short_version: (u64, u64),
Copy link
Contributor

Choose a reason for hiding this comment

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

I want to live to see Python 18446744073709551615 :D

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Haha yeah, it's what's stored in a Version because you can have: 202306221907 (year month day hour minute) which is bigger than the largest u32.

}

/// Returns the index of the first segment that belongs to the local version or `None` if there
/// is not local version
Copy link
Contributor

Choose a reason for hiding this comment

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

is no local version

Version::from_str("1.2l").unwrap()
)
}
// #[test]
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we ready to re-enable this test? Or do we not need that function anymore?

Copy link
Contributor

Choose a reason for hiding this comment

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

Btw. in rattler-build we have some functions like pin_compatible(otherpkg, min_pin="x.x", max_pin="x.x") which would resolve to >=1.4,<1.5, so being able to "bump" versions is nice.

@wolfv wolfv mentioned this pull request Jun 22, 2023
@wolfv wolfv merged commit a70cfcd into conda:main Jun 23, 2023
@baszalmstra baszalmstra mentioned this pull request Jun 30, 2023
2 tasks
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.4,<4 is evaluated wrongly
2 participants