-
Notifications
You must be signed in to change notification settings - Fork 474
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
clocks: tagged deadlines #5649
clocks: tagged deadlines #5649
Conversation
I think it would be reasonable to require there's exactly one timeout of a given type, which would allow you to avoid the double-nested-map in the implementations of |
Consider making TimeoutType a generic type argument in |
Codecov Report
@@ Coverage Diff @@
## master #5649 +/- ##
==========================================
- Coverage 55.13% 53.75% -1.38%
==========================================
Files 465 465
Lines 65022 65027 +5
==========================================
- Hits 35852 34958 -894
- Misses 26780 27644 +864
- Partials 2390 2425 +35
... and 48 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
That would change the current behavior though. Since now you're allowed to specify multiple deadlines (of any kind). And, the clock remembers past deadlines, so they expire immediately the next time someone looks for them, but without remembering that past deadline, that behavior would also change. |
This part of the behavior can easily stay the same: calling One other benefit is that it codifies the expected usage pattern: that there's just one timeout of a given type. All current code follows this (as far as I can tell), and this makes testing easier (you can trigger a timeout by naming it with the type, rather than by specifying timeout durations). Supporting the more-complicated usage pattern of multiple timeouts per type makes it harder to write correct test harnesses, without any concrete benefit (since no callers need this behavior). |
Current implementation aligns with problem Yossi is trying to solve with new cases exercising, works for me. |
@zeldovich for your generic implementation would you need to call Clock.Zero separately for each of the types in rezeroAction? |
Oh I think I understand better, they all still share a Zero() and still have a map[TimeoutType] but you're just moving the enum def out of the timers package using generics.. |
Yeah, that's all that's going on. It seemed a little weird to hard-code three types of timeouts in |
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.
IMO using TimeoutType
that basically an enum with 3 values as generic is a bit strange to me but I can live with it.
Co-authored-by: Pavel Zbitskiy <[email protected]>
Co-authored-by: Nickolai Zeldovich <[email protected]> Co-authored-by: chris erway <[email protected]> Co-authored-by: cce <[email protected]> Co-authored-by: Pavel Zbitskiy <[email protected]>
Summary
"I needed the clocks change to fix an issue with dynamic lambda (currently, if there are two deadlines for the same time, only one of them fires). This is a potential issue for dynamic lambda (if accidentally, the filter deadline matches a different deadline) and also made it very hard to test (since the current test suite allowed triggering a deadline by their time, which I don’t know apriori, rather than by their type)."
Test Plan
Existing tests + a few simulate cases confirming identical timeouts do not conflict.