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: improving flooding #270
Conversation
aw-transform/src/flood.rs
Outdated
// Extend e1 to the middle between e1 and e2 | ||
e1.duration = e1.duration + (gap / 2); |
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 was a major issue, as if the gap is negative that could lead to e1.duration
getting shorter.
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 guess that's true, but if you have negative gaps the data is already unreliable as it is. So there's not much of an improvement, since the raw data is already "bad".
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's intended to fix this: ActivityWatch/activitywatch#602
Which I consider a significant improvement, as now it should handle it as well as aw-server-python.
Codecov Report
@@ Coverage Diff @@
## master #270 +/- ##
==========================================
+ Coverage 50.56% 50.60% +0.03%
==========================================
Files 45 45
Lines 6259 6280 +21
==========================================
+ Hits 3165 3178 +13
- Misses 3094 3102 +8
Continue to review full report at Codecov.
|
c4d2cc7
to
93f99a8
Compare
Hoping coverage will improve with that last commit... |
Can't figure out why coverage is how it is (more should be covered than is reported? or am I just dumb?), and unable to generate reports locally... @johan-bjareholt could you take a look? |
debug_assert!(gap >= chrono::Duration::seconds(0)); | ||
|
||
// If data is the same, we should merge them. | ||
if e1.data == e2.data { | ||
// Choose the longest event and set the endtime to it |
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.
// Choose the longest event and set the endtime to it | |
// Set the endtime of e1 to whichever endtime is last of [e1, e2], drop e2. |
Or am I reading the diff wrong?
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.
That's correct, but it's an very unlikely scenario that e2 starts before e1. You would have to have a very crappy watcher to accomplish that.
So good to fix, but probably won't make much (any?) difference.
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.
very unlikely scenario
Unfortunately not too unlikely. Not sure if they appear due to some faulty queuing, heartbeat logic, or race condition, but they pop up every now and then...
@ErikBjare I don't know why, but the coverage has never been very reliable. You could pretty easily run it with gdb and step through if you really want to be sure for a specific test. |
@johan-bjareholt My best theory is that Rust somehow optimizes away a codepath (it notably shows lines that are later duplicated in a different if-clause as "oncovered") and that leads to it now showing in the coverage? Anyway, would be really nice to have coverage working on the long run. Spent a couple hours trying to get it working better yesterday, but not much luck. Also, you should check out ActivityWatch/activitywatch#724, might provide better background for some of the things I'm trying to make more robust. |
According to https://shift.click/blog/github-actions-rust/#coverage-with-cargo-tarpaulin, cargo-tarpaulin should be a lot more reliable. Not LLVM-based, nor supports branch coverage, but might still be better than the status quo... (where entire tests seem to not show up in the coverage) Tried it out, here the output:
82.7% is a lot better than the ~50% reported by kcov... |
Anyway, merging this. Might open another PR to switch to tarpaulin. |
Changes the behavior of aw-server-rust flooding to work the same as flooding in aw-core.
Part of the issue is described here: ActivityWatch/activitywatch#602 (comment)
Forward flooding instead of meet-in-middle (aw-core uses flood-from-longest though)TODO
flood.rs
)