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

[REVIEW] Split out cudf::distinct_count from drop_duplicates.cu #6822

Merged
merged 6 commits into from
Nov 25, 2020

Conversation

davidwendt
Copy link
Contributor

@davidwendt davidwendt commented Nov 20, 2020

One of our longest compile times is for drop_duplicates.cu measured currently at about 15 minutes. This file contains two cudf APIs: cudf::drop_duplicates and cudf::distinct_count. They share no code so it is reasonable to move the distinct_count to its own source file. Both files individually have a compile time around 7 minutes.

Also, analyzing the drop_duplicates source code I found that the table row-comparator is used in two thrust::copy_if() calls which inlines this large comparator function many times. And, the first copy_if has a lambda with two calls to the comparator meaning it is inlined twiced for each time it is inlined by copy_if. This is the main cause of the increased compile time and code size. I found a way to combine the logic for both the copy_if lambdas and further reduce the lambda to include only one copy of the comparator. The copy_if itself will still inline this many times but should reduce it by a factor of 3.

The drop_duplicates does not have a gbenchmark so I added one in this PR to measure before and after this change. No measurable effect was found so I'm including the change in this PR.

The distinct_count API passes the row-comparator to the thrust::count_if but only once so the same improvement does not apply there.

Note that no new function has been added (or removed). This is simply an improvement to compile time and size for this source file. The compile time for drop_duplicates.cu is now less than 5 minutes.

@davidwendt davidwendt requested review from a team as code owners November 20, 2020 19:08
@davidwendt davidwendt self-assigned this Nov 20, 2020
@davidwendt davidwendt added 3 - Ready for Review Ready for review by team libcudf Affects libcudf (C++/CUDA) code. labels Nov 20, 2020
@@ -0,0 +1,196 @@
/*
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not new code but was just moved from the drop_duplicates.cu source file here to its own source file.

@@ -151,44 +173,6 @@ column_view get_unique_ordered_indices(cudf::table_view const& keys,
}
}

cudf::size_type distinct_count(table_view const& keys,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code was moved to the new distinct_count.cu source file.

@kkraus14
Copy link
Collaborator

@davidwendt did you do any experimentation with removing pragmas from thrust to see what happens if things aren't inlined in this situation and the performance implications?

@davidwendt
Copy link
Contributor Author

@davidwendt did you do any experimentation with removing pragmas from thrust to see what happens if things aren't inlined in this situation and the performance implications?

Unroll may have implications for thrust::copy_if (https://godbolt.org/z/asffbo) which is used by code in this PR but I've not tried disabling it here.

@codecov
Copy link

codecov bot commented Nov 20, 2020

Codecov Report

Merging #6822 (4636246) into branch-0.17 (632ac54) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##           branch-0.17    #6822   +/-   ##
============================================
  Coverage        81.94%   81.94%           
============================================
  Files               96       96           
  Lines            16164    16164           
============================================
  Hits             13246    13246           
  Misses            2918     2918           

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 632ac54...4636246. Read the comment docs.

@davidwendt
Copy link
Contributor Author

rerun tests

Copy link
Collaborator

@kkraus14 kkraus14 left a comment

Choose a reason for hiding this comment

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

cmake lgtm

@kkraus14 kkraus14 added 5 - Ready to Merge Testing and reviews complete, ready to merge and removed 3 - Ready for Review Ready for review by team labels Nov 24, 2020
@davidwendt davidwendt merged commit e1e3047 into rapidsai:branch-0.17 Nov 25, 2020
@davidwendt davidwendt deleted the split-up-drop-duplicate branch November 25, 2020 04:33
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 libcudf Affects libcudf (C++/CUDA) code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants