-
Notifications
You must be signed in to change notification settings - Fork 997
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
Added an atime test for performance improvement in forderv when reusing existing key and index attributes #6555
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6555 +/- ##
=======================================
Coverage 98.62% 98.62%
=======================================
Files 79 79
Lines 14450 14450
=======================================
Hits 14251 14251
Misses 199 199 ☔ View full report in Codecov by Sentry. |
Generated via commit 13c4b1f Download link for the artifact containing the test results: ↓ atime-results.zip
|
your original test had 3 calls to forderv.
I was wondering if we need both retGrp=TRUE and FALSE in expr? But for retGrp=T in setup then retGrp=F in expr, we see linear Fast, as in the plot below: looking at datatable.verbose=T in this case, for example like the code below, I see "using existing index" which to me suggests that this should be constant (not linear as observed), so is this a performance bug?? > set.seed(1);library(data.table);options(datatable.verbose=T);dt <- data.table(index = sample(N), values = sample(N));data.table:::forderv(dt, "index", retGrp = TRUE);cat("------\n");data.table:::forderv(dt, "index", retGrp = FALSE)
forder.c received 10 rows and 2 columns
forderReuseSorting: opt=-1, took 0.000s
[1] 4 5 7 2 6 9 3 10 1 8
attr(,"starts")
[1] 1 2 3 4 5 6 7 8 9 10
attr(,"maxgrpn")
[1] 1
attr(,"anyna")
[1] 0
attr(,"anyinfnan")
[1] 0
attr(,"anynotascii")
[1] 0
attr(,"anynotutf8")
[1] 0
------
forder.c received 10 rows and 2 columns
forderReuseSorting: opt=-1, took 0.000s
[1] 4 5 7 2 6 9 3 10 1 8 I think we need explain in the comments what is expected to happen (when is expr expected to be linear vs constant). |
so here is a CI result that shows 3 constant Fast vs 1 linear Fast https://asset.cml.dev/f6abccc722845026bf081f0c9aa93b071bef4a4a?cml=png&cache-bypass=5e8ae8d9-fc0e-4b9b-9831-12442334b5d5 |
Not sure what exactly question is about. |
Hi @jangorecki we are trying to adapt your examples here #4386 (comment) to be a performance test, but we are not sure about what is the right way to test the new functionality vs the old.
I guess I don't understand the difference between retGrp=TRUE and FALSE, is that documented somewhere? |
Rerunning same should be constant. As for the other two cases I cannot look so much in details into it at the moment, but possibly when computing retGrp=F when having retGrp=T we may still need to run forder on the index itself to get the original order from groups (should be fast but not constant). In one of PR was fdistinct() which is very small function that was using those so the exact logic can be looked up there easily. |
I added a comment.
We don't, and in fact we don't even need to run forderv in setup, because the first memory measurement run sets the index, for use in subsequent time measurements.
Thanks, that helps! I edited the PR so that it only has these two test cases. (instead of all four described above for which we do not have a clear expectation). I think this PR should be ready to merge now. @Anirban166 can you please review? The atime results are missing Slow/Fast for some test cases, tdhock/atime#64 which is fixed in github atime (to send to CRAN later this week). |
Something that I see here, in my fork, and also when I run the tests locally on my machine (sharing the generated plot below, it uses the fixed/latest Their individual plots:
Is that expected or within reason? (asking since for the other tests I don't notice such; also are these results consistent with what you've been observing locally?)
As per the CI results we're getting, 'some test cases' more specifically would be all the other tests aside from the
Sweet! |
thanks for sharing. This result implies that no memory is used/measurable during the test for those versions. I don't understand why though. |
dt <- data.table(group = rep(1:2, l=N)) | ||
}), | ||
expr = substitute({ | ||
old.opt <- options(datatable.forder.auto.index = TRUE) # required for test, un-documented, comments in forder.c say it is for debugging only. |
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 think Jan mentioned that it is only for 'debugging' since it was not exported (coming from his comment here), but we can probably ask him for more information if we want to document it or have more details (otherwise yes, not having this option set to TRUE
will not show performance improvement)
Closes #6320