Batch deferred chart detail loads
This commit is contained in:
@@ -60,7 +60,8 @@ const FOREGROUND_FULL_DETAIL_REFRESH_DEDUP_MS = 90_000;
|
|||||||
const DETAIL_LOAD_BATCH_DELAY_MS = 0;
|
const DETAIL_LOAD_BATCH_DELAY_MS = 0;
|
||||||
const INITIAL_DETAIL_LOAD_SLOTS = 3;
|
const INITIAL_DETAIL_LOAD_SLOTS = 3;
|
||||||
const DEFERRED_DETAIL_LOAD_DELAY_MS = 1_200;
|
const DEFERRED_DETAIL_LOAD_DELAY_MS = 1_200;
|
||||||
const DEFERRED_DETAIL_LOAD_STEP_MS = 450;
|
const DEFERRED_DETAIL_LOAD_GROUP_SIZE = 3;
|
||||||
|
const DEFERRED_DETAIL_LOAD_WAVE_STEP_MS = 900;
|
||||||
|
|
||||||
const TemperatureChartCanvas = dynamic(
|
const TemperatureChartCanvas = dynamic(
|
||||||
() =>
|
() =>
|
||||||
@@ -157,7 +158,10 @@ function getInitialDetailLoadDelayMs({
|
|||||||
if (!compact || isActive || isMaximized) return 0;
|
if (!compact || isActive || isMaximized) return 0;
|
||||||
const normalizedIndex = normalizeSlotIndex(slotIndex);
|
const normalizedIndex = normalizeSlotIndex(slotIndex);
|
||||||
if (normalizedIndex < INITIAL_DETAIL_LOAD_SLOTS) return 0;
|
if (normalizedIndex < INITIAL_DETAIL_LOAD_SLOTS) return 0;
|
||||||
return DEFERRED_DETAIL_LOAD_DELAY_MS + (normalizedIndex - INITIAL_DETAIL_LOAD_SLOTS) * DEFERRED_DETAIL_LOAD_STEP_MS;
|
const deferredWave = Math.floor(
|
||||||
|
(normalizedIndex - INITIAL_DETAIL_LOAD_SLOTS) / DEFERRED_DETAIL_LOAD_GROUP_SIZE,
|
||||||
|
);
|
||||||
|
return DEFERRED_DETAIL_LOAD_DELAY_MS + deferredWave * DEFERRED_DETAIL_LOAD_WAVE_STEP_MS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Main component ─────────────────────────────────────────────────────
|
// ── Main component ─────────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -174,6 +174,18 @@ export async function runTests() {
|
|||||||
__getInitialDetailLoadDelayMsForTest({ compact: true, isActive: false, isMaximized: false, slotIndex: 3 }) > 0,
|
__getInitialDetailLoadDelayMsForTest({ compact: true, isActive: false, isMaximized: false, slotIndex: 3 }) > 0,
|
||||||
"later non-active grid charts should defer full-detail loading after first paint",
|
"later non-active grid charts should defer full-detail loading after first paint",
|
||||||
);
|
);
|
||||||
|
assert(
|
||||||
|
__getInitialDetailLoadDelayMsForTest({ compact: true, isActive: false, isMaximized: false, slotIndex: 3 }) ===
|
||||||
|
__getInitialDetailLoadDelayMsForTest({ compact: true, isActive: false, isMaximized: false, slotIndex: 5 }),
|
||||||
|
"deferred grid charts should load in same-wave groups so detail-batch can coalesce them",
|
||||||
|
);
|
||||||
|
assert(
|
||||||
|
__getInitialDetailLoadDelayMsForTest({ compact: true, isActive: false, isMaximized: false, slotIndex: 6 }) ===
|
||||||
|
__getInitialDetailLoadDelayMsForTest({ compact: true, isActive: false, isMaximized: false, slotIndex: 8 }) &&
|
||||||
|
__getInitialDetailLoadDelayMsForTest({ compact: true, isActive: false, isMaximized: false, slotIndex: 6 }) >
|
||||||
|
__getInitialDetailLoadDelayMsForTest({ compact: true, isActive: false, isMaximized: false, slotIndex: 5 }),
|
||||||
|
"later deferred grid charts should form a second batch wave instead of one request per slot",
|
||||||
|
);
|
||||||
assert(
|
assert(
|
||||||
__getInitialDetailLoadDelayMsForTest({ compact: true, isActive: true, isMaximized: false, slotIndex: 8 }) === 0 &&
|
__getInitialDetailLoadDelayMsForTest({ compact: true, isActive: true, isMaximized: false, slotIndex: 8 }) === 0 &&
|
||||||
__getInitialDetailLoadDelayMsForTest({ compact: true, isActive: false, isMaximized: true, slotIndex: 8 }) === 0,
|
__getInitialDetailLoadDelayMsForTest({ compact: true, isActive: false, isMaximized: true, slotIndex: 8 }) === 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user