perf(renderer): slow process-lite runtime telemetry refresh
This commit is contained in:
parent
b2c416dee6
commit
bc660e7e9b
2 changed files with 19 additions and 5 deletions
|
|
@ -361,6 +361,8 @@ export function initializeNotificationListeners(): () => void {
|
||||||
const TEAM_REFRESH_THROTTLE_MS = 800;
|
const TEAM_REFRESH_THROTTLE_MS = 800;
|
||||||
const TEAM_PRESENCE_REFRESH_THROTTLE_MS = 400;
|
const TEAM_PRESENCE_REFRESH_THROTTLE_MS = 400;
|
||||||
const TEAM_MEMBER_SPAWN_REFRESH_THROTTLE_MS = 500;
|
const TEAM_MEMBER_SPAWN_REFRESH_THROTTLE_MS = 500;
|
||||||
|
const TEAM_AGENT_RUNTIME_REFRESH_THROTTLE_MS = 500;
|
||||||
|
const TEAM_AGENT_RUNTIME_PROCESS_LITE_REFRESH_THROTTLE_MS = 5_000;
|
||||||
const TEAM_LIST_REFRESH_THROTTLE_MS = 2000;
|
const TEAM_LIST_REFRESH_THROTTLE_MS = 2000;
|
||||||
const GLOBAL_TASKS_REFRESH_THROTTLE_MS = 500;
|
const GLOBAL_TASKS_REFRESH_THROTTLE_MS = 500;
|
||||||
const GLOBAL_TASKS_REFRESH_DURING_LAUNCH_THROTTLE_MS = 5000;
|
const GLOBAL_TASKS_REFRESH_DURING_LAUNCH_THROTTLE_MS = 5000;
|
||||||
|
|
@ -512,6 +514,10 @@ export function initializeNotificationListeners(): () => void {
|
||||||
if (teamAgentRuntimeRefreshTimers.has(timerKey)) {
|
if (teamAgentRuntimeRefreshTimers.has(timerKey)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const throttleMs =
|
||||||
|
reason === 'event:process-lite'
|
||||||
|
? TEAM_AGENT_RUNTIME_PROCESS_LITE_REFRESH_THROTTLE_MS
|
||||||
|
: TEAM_AGENT_RUNTIME_REFRESH_THROTTLE_MS;
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
teamAgentRuntimeRefreshTimers.delete(timerKey);
|
teamAgentRuntimeRefreshTimers.delete(timerKey);
|
||||||
if (options.skipIfHiddenAtExecution === true && !isTeamVisibleInAnyPane(teamName)) {
|
if (options.skipIfHiddenAtExecution === true && !isTeamVisibleInAnyPane(teamName)) {
|
||||||
|
|
@ -533,7 +539,7 @@ export function initializeNotificationListeners(): () => void {
|
||||||
operation: 'fetchTeamAgentRuntime',
|
operation: 'fetchTeamAgentRuntime',
|
||||||
});
|
});
|
||||||
void useStore.getState().fetchTeamAgentRuntime(teamName);
|
void useStore.getState().fetchTeamAgentRuntime(teamName);
|
||||||
}, TEAM_MEMBER_SPAWN_REFRESH_THROTTLE_MS);
|
}, throttleMs);
|
||||||
teamAgentRuntimeRefreshTimers.set(timerKey, timer);
|
teamAgentRuntimeRefreshTimers.set(timerKey, timer);
|
||||||
};
|
};
|
||||||
const scheduleProcessLiteRuntimeRefresh = (teamName: string): void => {
|
const scheduleProcessLiteRuntimeRefresh = (teamName: string): void => {
|
||||||
|
|
|
||||||
|
|
@ -298,8 +298,7 @@ describe('team change throttling', () => {
|
||||||
await vi.advanceTimersByTimeAsync(500);
|
await vi.advanceTimersByTimeAsync(500);
|
||||||
expect(fetchMemberSpawnStatusesSpy).toHaveBeenCalledTimes(1);
|
expect(fetchMemberSpawnStatusesSpy).toHaveBeenCalledTimes(1);
|
||||||
expect(fetchMemberSpawnStatusesSpy).toHaveBeenCalledWith('my-team');
|
expect(fetchMemberSpawnStatusesSpy).toHaveBeenCalledWith('my-team');
|
||||||
expect(fetchTeamAgentRuntimeSpy).toHaveBeenCalledTimes(1);
|
expect(fetchTeamAgentRuntimeSpy).not.toHaveBeenCalled();
|
||||||
expect(fetchTeamAgentRuntimeSpy).toHaveBeenCalledWith('my-team');
|
|
||||||
expect(refreshTeamDataSpy).not.toHaveBeenCalled();
|
expect(refreshTeamDataSpy).not.toHaveBeenCalled();
|
||||||
expect(fetchTeamsSpy).not.toHaveBeenCalled();
|
expect(fetchTeamsSpy).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
|
@ -312,6 +311,10 @@ describe('team change throttling', () => {
|
||||||
expect(refreshTeamDataSpy).toHaveBeenCalledTimes(1);
|
expect(refreshTeamDataSpy).toHaveBeenCalledTimes(1);
|
||||||
expect(refreshTeamDataSpy).toHaveBeenCalledWith('my-team', { withDedup: true });
|
expect(refreshTeamDataSpy).toHaveBeenCalledWith('my-team', { withDedup: true });
|
||||||
|
|
||||||
|
await vi.advanceTimersByTimeAsync(2_500);
|
||||||
|
expect(fetchTeamAgentRuntimeSpy).toHaveBeenCalledTimes(1);
|
||||||
|
expect(fetchTeamAgentRuntimeSpy).toHaveBeenCalledWith('my-team');
|
||||||
|
|
||||||
const summary = summarizeTeamRefreshFanout('my-team');
|
const summary = summarizeTeamRefreshFanout('my-team');
|
||||||
expect(summary.rows).toEqual(
|
expect(summary.rows).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
|
|
@ -436,14 +439,19 @@ describe('team change throttling', () => {
|
||||||
expect(refreshTeamDataSpy).not.toHaveBeenCalled();
|
expect(refreshTeamDataSpy).not.toHaveBeenCalled();
|
||||||
await vi.advanceTimersByTimeAsync(799);
|
await vi.advanceTimersByTimeAsync(799);
|
||||||
expect(refreshTeamDataSpy).not.toHaveBeenCalled();
|
expect(refreshTeamDataSpy).not.toHaveBeenCalled();
|
||||||
|
expect(fetchMemberSpawnStatusesSpy).toHaveBeenCalledWith('my-team');
|
||||||
|
expect(fetchTeamAgentRuntimeSpy).not.toHaveBeenCalled();
|
||||||
|
|
||||||
await vi.advanceTimersByTimeAsync(1);
|
await vi.advanceTimersByTimeAsync(1);
|
||||||
expect(fetchMemberSpawnStatusesSpy).toHaveBeenCalledWith('my-team');
|
expect(fetchMemberSpawnStatusesSpy).toHaveBeenCalledTimes(1);
|
||||||
|
expect(fetchTeamAgentRuntimeSpy).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
await vi.advanceTimersByTimeAsync(4_200);
|
||||||
expect(fetchTeamAgentRuntimeSpy).toHaveBeenCalledWith('my-team');
|
expect(fetchTeamAgentRuntimeSpy).toHaveBeenCalledWith('my-team');
|
||||||
expect(useStore.getState().selectedTeamData).toBeNull();
|
expect(useStore.getState().selectedTeamData).toBeNull();
|
||||||
expect(useStore.getState().teamDataCacheByName['my-team']).toBeUndefined();
|
expect(useStore.getState().teamDataCacheByName['my-team']).toBeUndefined();
|
||||||
|
|
||||||
await vi.advanceTimersByTimeAsync(19_200);
|
await vi.advanceTimersByTimeAsync(15_000);
|
||||||
expect(fetchTeamsSpy).not.toHaveBeenCalled();
|
expect(fetchTeamsSpy).not.toHaveBeenCalled();
|
||||||
expect(refreshTeamDataSpy).not.toHaveBeenCalled();
|
expect(refreshTeamDataSpy).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue