Skip to content

Avoid workload gc failure due to 4-part version in ReleaseVersion used to find a max#45263

Merged
marcpopMSFT merged 3 commits intodotnet:release/9.0.2xxfrom
Forgind:avoid-gc-failure
Dec 10, 2024
Merged

Avoid workload gc failure due to 4-part version in ReleaseVersion used to find a max#45263
marcpopMSFT merged 3 commits intodotnet:release/9.0.2xxfrom
Forgind:avoid-gc-failure

Conversation

@Forgind
Copy link
Copy Markdown
Contributor

@Forgind Forgind commented Dec 3, 2024

No description provided.

@Forgind Forgind requested review from a team, AntonLapounov, tmat and vijayrkn as code owners December 3, 2024 02:13
@ghost ghost added Area-Workloads untriaged Request triage from a team member labels Dec 3, 2024
@Forgind Forgind changed the base branch from main to release/9.0.2xx December 3, 2024 02:13
@Forgind Forgind removed request for a team, AntonLapounov, tmat and vijayrkn December 3, 2024 02:13
return comparison;
}

var modifiedFirst = "1.1.1" + (firstDash == first.Length ? string.Empty : first.Substring(firstDash));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You could just call the ctor overload for ReleaseVersion: ReleaseVersion(int major, int minor, int patch, string prerelease = null, string buildMetadata = null), you'll have a proper value to compare and avoid creating two strings and then creating versions to compare.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I cannot use that overload because it doesn't handle 4-part version numbers. The error this is trying to address is due to trying to create a ReleaseVersion from the original string where it happens to be 9.0.100.1.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm suggesting that you do the following. Right now you're creating a string and passing that to ReleaseVersion constructor, so you have something that will parse correctly.

modifiedFirst = new ReleaseVersion(1, 1, 1, (firstDash == first.Length ? string.Empty : first.Substring(firstDash));

return modifiedFirst.CompareTo(modifiedSecond)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah, I misunderstood. Yeah; that should work and will save a couple allocations 🙂 Happy to make that change.

{
internal static int VersionCompare(string first, string second)
{
if (first.Equals(second))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If the versions are strings, what about case sensitivity? Like, 1.0.0.0-preview vs 1.0.0.0-PREVIEW? Or can these version number strings not contain anything other than numerics and dots?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This first check isn't actually necessary; it's just for performance. If they aren't equal, we start turning parts into versions, and then we use previously built checks. (I think anything after the - is fair game.)

{
internal class WorkloadUtilities
{
internal static int VersionCompare(string first, string second)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a reason this is a separate utility instead of being the comparison operator for ReleaseVersion directly? It is a bit confusing because this method seems to directly (and only) work with strings that represent ReleaseVersion, but the method itself doesn't indicate that without reading the code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was actually pretty annoyed about this.

ReleaseVersion can't handle 4-part versions like 9.0.100.1. Version can't handle prerelease bits like 9.0.100-preview.1. That means there isn't actually anything that can handle workload set versions that might have 4-part versions and might have prerelease bits.

The gc failure was actually directly because ReleaseVersion doesn't work.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So, that makes it sound like this is a separate type, such as a WorkloadVersion since it has different constraints compared to both ReleaseVersion and Version. My general confusion was what each string parameter contains, and it sounds like it is a "new" version type, at least in the context of what version types we already have.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In some sense, yes, and maybe it should be. I think that would be a good refactor, actually, but I'd rather have a bunch of other things in that somehow touch on it before trying to make it.

@Forgind
Copy link
Copy Markdown
Contributor Author

Forgind commented Feb 20, 2025

/backport to release/9.0.1xx

@Forgind Forgind deleted the avoid-gc-failure branch February 20, 2025 18:51
@github-actions
Copy link
Copy Markdown
Contributor

Started backporting to release/9.0.1xx: https://github.com/dotnet/sdk/actions/runs/13442547774

@Forgind
Copy link
Copy Markdown
Contributor Author

Forgind commented Mar 3, 2025

/backport to release/9.0.1xx

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 3, 2025

Started backporting to release/9.0.1xx: https://github.com/dotnet/sdk/actions/runs/13640141941

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Workloads untriaged Request triage from a team member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants