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

Fix VeryLargeAmountOfEnumsToSerialize test #37710

Merged
merged 2 commits into from
Jun 10, 2020
Merged

Conversation

layomia
Copy link
Contributor

@layomia layomia commented Jun 10, 2020

Fixes #37471. Follow up for #36726.

@layomia layomia added this to the 5.0 milestone Jun 10, 2020
@layomia layomia requested a review from stephentoub June 10, 2020 16:49
@layomia layomia self-assigned this Jun 10, 2020
Parallel.For(0, 8, i => JsonSerializer.Serialize((MyEnum)(46 + i), options));

// Write the remaining enum values. We should not store any more values in
// the cache. If we do, we may throw OutOfMemoryException on some machines.
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps clarify a bit that the OutOfMemoryException would be thrown if we didn't have a cap on the dictionary.

            // Write the remaining enum values. The cache is capped to avoid OutOfMemoryException due
            // to having too many cached items.

Copy link
Contributor Author

@layomia layomia Jun 10, 2020

Choose a reason for hiding this comment

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

Will update the comment in #37720 (to avoid CI reset).


// Write the remaining enum values. We should not store any more values in
// the cache. If we do, we may throw OutOfMemoryException on some machines.
for (int i = 54; i <= MaxValue; i++)
Copy link
Member

Choose a reason for hiding this comment

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

How long does this test take?

Copy link
Contributor Author

@layomia layomia Jun 10, 2020

Choose a reason for hiding this comment

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

It takes ~6.75s on my machine (which would be ~20% of total test time if it were not outer-loop).

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

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

Thanks for fixing it.

@layomia layomia merged commit 7a57b92 into dotnet:master Jun 10, 2020
@layomia layomia deleted the outerloop_oom branch June 10, 2020 21:50
@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test failure: System.Text.Json.Serialization.Tests.EnumConverterTests.VeryLargeAmountOfEnumsToSerialize
3 participants