Commit 56c23d7
authored
Add
## Problem
In cascaded timer-based resamplers (for example `1s -> 10s`), a race can
happen at window boundaries:
the downstream resampler can tick and compute its window before the
upstream resampler has emitted the last sample for the previous window.
Example with `max_data_age_in_periods=1`:
- The upstream resampler computes `[9,10)` and emits its result (label
`9`) slightly **after** `t=10`.
- The downstream resampler computes `[0,10)` at `t=10` and does not see
that label-`9` sample yet.
- At the next tick (`t=20`), that delayed sample is too old and is no
longer considered.
Result: the affected downstream window stays permanently incomplete.
## Change
- Added `tick_delay` to `ResamplerConfig` and `ResamplerConfig2`.
- `tick_delay` is keyword-only to avoid positional-argument API
breakage.
- The resampler can now optionally wait `tick_delay` after a tick, while
still computing with the original window boundary.
- This delays processing without shifting the actual window definitions.
- Added validation: `tick_delay` must be `>= 0` and `<
resampling_period`.
- Added documentation for the cascaded-resampling use case.
- Marked `tick_delay` as experimental (it may be changed or deprecated
in the future).
## Tests
- Added validation tests for invalid `tick_delay` values (`< 0`, `>=
resampling_period`).
- Added fixture-based timing tests that separate sample arrival time
from timestamp-based window filtering.
- Added a with/without-delay late-arrival comparison (same timestamps
and arrival timing, only `tick_delay` differs) to make the delay effect
explicit.tick_delay to mitigate boundary races in cascaded resampling (#1394)4 files changed
Lines changed: 383 additions & 2 deletions
File tree
- src/frequenz/sdk/timeseries/_resampling
- tests/timeseries
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
204 | 223 | | |
205 | 224 | | |
206 | 225 | | |
| |||
245 | 264 | | |
246 | 265 | | |
247 | 266 | | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
248 | 274 | | |
249 | 275 | | |
250 | 276 | | |
| |||
415 | 441 | | |
416 | 442 | | |
417 | 443 | | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
203 | 208 | | |
204 | 209 | | |
205 | 210 | | |
| |||
0 commit comments