mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
fix(flights): a delivery after a pause in polling does not raise the display delay
A hidden tab pauses polls; its first delivery after that measured the pause as feed lateness and pushed the delay up for minutes.
This commit is contained in:
1 parent
72cfea35c4
commit
b9ccdff0a3
2 files changed
+31
-2
No files matched your search
@@ -14,7 +14,9 @@
|
|||||||
* poll together). The delay aimed at is the 90th percentile of the newest 256
|
* poll together). The delay aimed at is the 90th percentile of the newest 256
|
||||||
* lags plus 5 s, within the layer's floor and a five-minute cap. Before a
|
* lags plus 5 s, within the layer's floor and a five-minute cap. Before a
|
||||||
* feed has given 16 lags, its first reports stand in: their age plus one poll
|
* feed has given 16 lags, its first reports stand in: their age plus one poll
|
||||||
* interval.
|
* interval. A delivery that comes more than three poll intervals after the
|
||||||
|
* one before it (a hidden tab's polls paused, or the feed failed) gives no
|
||||||
|
* lags: the wait was not the feed's lateness.
|
||||||
*
|
*
|
||||||
* The delay drawn with moves toward that aim at a bounded rate, rising by at
|
* The delay drawn with moves toward that aim at a bounded rate, rising by at
|
||||||
* most 0.2 s and falling by at most 0.05 s per second, so every contact
|
* most 0.2 s and falling by at most 0.05 s per second, so every contact
|
||||||
@@ -39,6 +41,8 @@ export const DISPLAY_DELAY_RISE = 0.2;
|
|||||||
export const DISPLAY_DELAY_FALL = 0.05;
|
export const DISPLAY_DELAY_FALL = 0.05;
|
||||||
/** @constant {number} An aim this close (ms) to the delay leaves it be. */
|
/** @constant {number} An aim this close (ms) to the delay leaves it be. */
|
||||||
export const DISPLAY_DELAY_DEADBAND_MS = 2_000;
|
export const DISPLAY_DELAY_DEADBAND_MS = 2_000;
|
||||||
|
/** @constant {number} Poll intervals between deliveries past which a delivery gives no lags. */
|
||||||
|
export const DISPLAY_DELAY_GAP_POLLS = 3;
|
||||||
|
|
||||||
function createWindow(capacity) {
|
function createWindow(capacity) {
|
||||||
return { values: new Float64Array(capacity), count: 0, cursor: 0 };
|
return { values: new Float64Array(capacity), count: 0, cursor: 0 };
|
||||||
@@ -74,6 +78,10 @@ export function createDisplayDelay({
|
|||||||
let fromMs = floorMs;
|
let fromMs = floorMs;
|
||||||
let fromAtMs = NaN;
|
let fromAtMs = NaN;
|
||||||
let currentMs = floorMs;
|
let currentMs = floorMs;
|
||||||
|
// The delivery being noted, the one before it, and whether a pause
|
||||||
|
// separated them.
|
||||||
|
let deliveryMs = NaN;
|
||||||
|
let afterGap = false;
|
||||||
|
|
||||||
const clamp = (ms) => Math.max(floorMs, Math.min(capMs, ms));
|
const clamp = (ms) => Math.max(floorMs, Math.min(capMs, ms));
|
||||||
|
|
||||||
@@ -107,8 +115,12 @@ export function createDisplayDelay({
|
|||||||
* contact's previous report time (none for a contact seen first).
|
* contact's previous report time (none for a contact seen first).
|
||||||
*/
|
*/
|
||||||
noteReport(receiptMs, reportMs, previousReportMs) {
|
noteReport(receiptMs, reportMs, previousReportMs) {
|
||||||
|
if (receiptMs !== deliveryMs) {
|
||||||
|
afterGap = receiptMs - deliveryMs > DISPLAY_DELAY_GAP_POLLS * pollMs;
|
||||||
|
deliveryMs = receiptMs;
|
||||||
|
}
|
||||||
if (Number.isFinite(previousReportMs)) {
|
if (Number.isFinite(previousReportMs)) {
|
||||||
if (reportMs > previousReportMs)
|
if (reportMs > previousReportMs && !afterGap)
|
||||||
add(lags, receiptMs - previousReportMs);
|
add(lags, receiptMs - previousReportMs);
|
||||||
} else if (Number.isFinite(reportMs))
|
} else if (Number.isFinite(reportMs))
|
||||||
add(firstAges, receiptMs - reportMs);
|
add(firstAges, receiptMs - reportMs);
|
||||||
@@ -159,6 +171,8 @@ export function createDisplayDelay({
|
|||||||
firstAges.count = firstAges.cursor = 0;
|
firstAges.count = firstAges.cursor = 0;
|
||||||
aimMs = fromMs = currentMs = floorMs;
|
aimMs = fromMs = currentMs = floorMs;
|
||||||
fromAtMs = NaN;
|
fromAtMs = NaN;
|
||||||
|
deliveryMs = NaN;
|
||||||
|
afterGap = false;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -168,3 +168,18 @@ test('reset forgets the feed', () => {
|
|||||||
assert.equal(delay.lagCount, 0);
|
assert.equal(delay.lagCount, 0);
|
||||||
assert.equal(delay.settle(now, { jump: true }), FLOOR);
|
assert.equal(delay.settle(now, { jump: true }), FLOOR);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('a delivery after a pause in polling gives no lags, and the next one does', () => {
|
||||||
|
const delay = createDisplayDelay({ floorMs: FLOOR, pollMs: POLL });
|
||||||
|
let now = feed(delay, { ageMs: 10 * SEC, contacts: 20, polls: 2 });
|
||||||
|
const learned = delay.lagCount;
|
||||||
|
// A hidden tab: ten minutes with no polls, then a delivery whose reports
|
||||||
|
// moved on from ones ten minutes old.
|
||||||
|
now += 10 * 60 * SEC;
|
||||||
|
for (let c = 0; c < 20; c++)
|
||||||
|
delay.noteReport(now, now - 10 * SEC, now - 10 * 60 * SEC);
|
||||||
|
assert.equal(delay.lagCount, learned, 'the pause is not the feed’s lateness');
|
||||||
|
assert.ok(delay.settle(now, { jump: true }) < 60 * SEC);
|
||||||
|
feed(delay, { ageMs: 10 * SEC, contacts: 20, polls: 1, startMs: now });
|
||||||
|
assert.equal(delay.lagCount, learned + 20, 'polling again, lags count again');
|
||||||
|
});
|
||||||
Reference in new issue
Block a user