-
Notifications
You must be signed in to change notification settings - Fork 63
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
Conversation
@@ -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), |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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 takes136128 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