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 flaky memory usage test by guaranteeing array size. #10114

Merged

Conversation

vyasr
Copy link
Contributor

@vyasr vyasr commented Jan 24, 2022

The test test_dataframe.py::test_memory_usage_multi is currently flaky. In theory it can fail for any value of the rows parameter, but in practice we only observe failures for the smaller value of 10. The reason for this is that the data for the MultiIndex is being constructed by randomly sampling from an array of size 3, and for a sufficiently small sample (e.g. 10) the probability that selection will not actually include all three values (e.g. a sample of [0, 1, 1, 1, 0, 1, 1, 0, 0, 1]) is not vanishingly small and occurs with observable frequency. The resulting MultiIndex will encode the levels for that column as a column with only two values, and as a result the column will occupy 8 fewer bytes (one 64 bit integer or float) less of space than expected. This PR changes that by always sampling without replacement from an array of the same length as the number of rows. I could also have fixed this problem by fixing a random seed that ensures that all the values are always sampled, but I made this change instead because 1) it more clearly conveys the intent, and 2) fixing a seed is a change that we should discuss and apply globally across all our tests.

@vyasr vyasr added bug Something isn't working 3 - Ready for Review Ready for review by team Python Affects Python cuDF API. non-breaking Non-breaking change labels Jan 24, 2022
@vyasr vyasr requested a review from a team as a code owner January 24, 2022 21:40
@vyasr vyasr self-assigned this Jan 24, 2022
@vyasr vyasr requested review from isVoid and rgsl888prabhu January 24, 2022 21:40
Copy link
Contributor

@bdice bdice 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 the fix. This caused significant confusion for me in #9945.

@galipremsagar galipremsagar added 5 - Ready to Merge Testing and reviews complete, ready to merge and removed 3 - Ready for Review Ready for review by team labels Jan 24, 2022
@codecov
Copy link

codecov bot commented Jan 24, 2022

Codecov Report

Merging #10114 (b99c80d) into branch-22.04 (e24fa8f) will increase coverage by 0.04%.
The diff coverage is 3.18%.

Impacted file tree graph

@@               Coverage Diff                @@
##           branch-22.04   #10114      +/-   ##
================================================
+ Coverage         10.37%   10.42%   +0.04%     
================================================
  Files               119      119              
  Lines             20149    20607     +458     
================================================
+ Hits               2091     2148      +57     
- Misses            18058    18459     +401     
Impacted Files Coverage Δ
python/cudf/cudf/__init__.py 0.00% <ø> (ø)
python/cudf/cudf/_fuzz_testing/io.py 0.00% <0.00%> (ø)
python/cudf/cudf/_fuzz_testing/orc.py 0.00% <ø> (ø)
python/cudf/cudf/_fuzz_testing/parquet.py 0.00% <ø> (ø)
python/cudf/cudf/_fuzz_testing/utils.py 0.00% <0.00%> (ø)
python/cudf/cudf/api/types.py 0.00% <0.00%> (ø)
python/cudf/cudf/core/_base_index.py 0.00% <0.00%> (ø)
python/cudf/cudf/core/column/__init__.py 0.00% <ø> (ø)
python/cudf/cudf/core/column/column.py 0.00% <0.00%> (ø)
python/cudf/cudf/core/column/decimal.py 0.00% <0.00%> (ø)
... and 81 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cfb6cbe...b99c80d. Read the comment docs.

@vyasr
Copy link
Contributor Author

vyasr commented Jan 24, 2022

@gpucibot merge

@rapids-bot rapids-bot bot merged commit 6d11823 into rapidsai:branch-22.04 Jan 24, 2022
@vyasr vyasr deleted the fix/multiindex_memory_usage_test branch March 9, 2022 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 - Ready to Merge Testing and reviews complete, ready to merge bug Something isn't working non-breaking Non-breaking change Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants