-
Notifications
You must be signed in to change notification settings - Fork 119
perf: Avoid iterating over already processed files with gcov #611
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
base: main
Are you sure you want to change the base?
Conversation
tests/testthat/test-Compiled.R
Outdated
# This header contains a C++ template, which requires you to run gcov for | ||
# each object file separately and merge the results together. |
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 the problem with this change is this comment, if headers are included in multiple files they get tracked only once if you try to process all the object files at once, so you need to run gcov for each object file separately if you want accurate counting. This means you can have tests which exercise a header via one object file, and it might show up as uncovered depending on the order of the object files.
This is also why the coverage counts have now changed in the test.
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 believe gcov
is still run separately for each file, it's only that parse_gcov()
(in R) is run once for each file, and not n times for the first file and once for the last file (giving a total of O(n^2) runs). I admit, the patch is a little difficult to read. What am I missing?
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.
For each compilation unit you need to run gcov, then parse the results, then remove the output files. You can't just run gcov multiple times, then parse all the output files after the fact because the output files get overwritten by each individual run of gcov and you lose coverage information.
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.
It is possible there is another better way to do this, but this was the only way I found back when I wrote this code originally.
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.
Thanks: I thought I saw increasing runtime with each file: https://github.com/igraph/rigraph/actions/runs/15911464511/job/44880531901 . Let me do some experiments and get back to you.
It seems that with
|
Now:
|
|
R/compiled.R
Outdated
@@ -72,27 +72,56 @@ run_gcov <- function(path, quiet = TRUE, clean = TRUE, | |||
return() | |||
} | |||
|
|||
gcov_inputs <- list.files(path, pattern = rex::rex(".gcno", end), recursive = TRUE, full.names = TRUE) | |||
res <- withr::local_dir(src_path) |
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.
This seems unused?
This is the reason that covr is running so slow in igraph. Reduced the check time from over one hour (timeout) to a whopping 8 minutes. Other projects with many C/C++ files will also benefit.
https://github.com/igraph/rigraph/actions/runs/15930556545/job/44938446998