-
Notifications
You must be signed in to change notification settings - Fork 531
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
Add cache hit percentage to stats #2211
base: main
Are you sure you want to change the base?
Conversation
Hi @Xuanwo, Is it OK to you? |
src/server.rs
Outdated
@@ -1510,6 +1510,17 @@ impl Default for ServerStats { | |||
} | |||
} | |||
|
|||
macro_rules! set_percentage_stat { |
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.
why a macro and not a function?
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.
Picked up code from #614 and experienced tunnel vision.
Function is probably a better choice here indeed.
Could you please add a test to verify the field is present? Thanks |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2211 +/- ##
===========================================
+ Coverage 30.91% 51.56% +20.65%
===========================================
Files 53 53
Lines 20112 20577 +465
Branches 9755 9725 -30
===========================================
+ Hits 6217 10611 +4394
- Misses 7922 7954 +32
+ Partials 5973 2012 -3961 ☔ View full report in Codecov by Sentry. |
|
||
let output = writer.get_output(); | ||
|
||
assert!(output.contains("Cache hits rate -")); |
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.
Interesting case where PerLanguageCount::all()
uses counts.values().sum()
and not self.adv_counts.values().sum()
in case of printing advanced stats.
In practice should never happen because PerLanguageCount::increment()
is used to set the counts.
@@ -1700,7 +1780,7 @@ impl ServerInfo { | |||
|
|||
/// Print info to stdout in a human-readable format. | |||
pub fn print(&self, advanced: bool) { | |||
let (name_width, stat_width) = self.stats.print(advanced); | |||
let (name_width, stat_width) = self.stats.print(&mut StdoutServerStatsWriter, advanced); |
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.
Intrusive way to test the code. If anyone has an idea on how to test it in a better way it would be helpful to know.
I was thinking about writing similar test like in sccache_cargo.rs
(using Command::new()
and capturing the output), but I was hesitant because the test would not be fast.
I was thinking about refactoring this code to free functions and testing the free functions but then it would potentially not cover the whole use case.
Hi @Saruniks Is it ready to be merged? |
Hello @AJIOB Ready from my side. Unless perhaps someone has comments on the code and tests. |
Hi @sylvestre & @Xuanwo |
i was hoping to have also integration tests like in https://github.com/mozilla/sccache/blob/main/.github/workflows/integration-tests.yml |
and sorry for the latency |
Ok. I'll add the integration test |
many thanks :) |
Closes #2161
Inspiration from #614
Feedback is welcome.
No compile requests:
Zero cache hits:
Some cache hits:
sccache --show-adv-stats
: