Repository navigation
perf(onboard): replace fixed readiness polls with deadline waits #7274
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0ba29dd
perf(onboard): use deadline-based readiness waits
amata-human 78d2645
refactor(onboard): extract gateway readiness polling
amata-human 29f4b32
test(onboard): cover agent gateway readiness wiring
amata-human b9d592e
test(onboard): keep gateway mocks linear
amata-human c65cc86
docs(onboard): correct fail-fast debounce example
amata-human 44926b0
fix(onboard): clarify zero-budget readiness outcomes
amata-human 3d1d911
fix(onboard): preserve readiness stability interval
jyaunches 7ace6ce
merge: update performance PR from main
jyaunches bbdb0e2
merge: update performance PR from main
amata-human b886cc8
merge: sync #7274 with current main
apurvvkumaria 31523b4
merge: sync #7274 with current main
apurvvkumaria 0fd39b8
merge(main): sync PR #7274 with current main
apurvvkumaria File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { describe, expect, it, vi } from "vitest"; | ||
|
|
||
| import { waitForAgentGatewayReady } from "./gateway-readiness"; | ||
|
|
||
| function clock() { | ||
| let nowMs = 10_000; | ||
| const sleepSeconds = vi.fn((seconds: number) => { | ||
| nowMs += seconds * 1000; | ||
| }); | ||
| return { now: () => nowMs, sleepSeconds }; | ||
| } | ||
|
|
||
| describe("waitForAgentGatewayReady", () => { | ||
| it("returns immediately when the agent gateway is already ready", () => { | ||
| const time = clock(); | ||
| const probe = vi.fn(() => true); | ||
|
|
||
| expect(waitForAgentGatewayReady({ timeoutSeconds: 60, probe, ...time })).toBe(true); | ||
| expect(probe).toHaveBeenCalledOnce(); | ||
| expect(time.sleepSeconds).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it("retries quickly and succeeds before the deadline", () => { | ||
| const time = clock(); | ||
| const probe = vi.fn().mockReturnValueOnce(false).mockReturnValue(true); | ||
|
|
||
| expect(waitForAgentGatewayReady({ timeoutSeconds: 60, probe, ...time })).toBe(true); | ||
| expect(probe).toHaveBeenCalledTimes(2); | ||
| expect(time.sleepSeconds).toHaveBeenCalledWith(0.25); | ||
| }); | ||
|
|
||
| it("uses the full short deadline before timing out", () => { | ||
| const time = clock(); | ||
| const probe = vi.fn(() => false); | ||
|
|
||
| expect(waitForAgentGatewayReady({ timeoutSeconds: 0.1, probe, ...time })).toBe(false); | ||
| expect(time.sleepSeconds.mock.calls.reduce((total, [seconds]) => total + seconds, 0)).toBe(0.1); | ||
| }); | ||
|
|
||
| it("does not probe when the configured deadline is zero", () => { | ||
| const time = clock(); | ||
| const probe = vi.fn(() => true); | ||
|
|
||
| expect(waitForAgentGatewayReady({ timeoutSeconds: 0, probe, ...time })).toBe(false); | ||
| expect(probe).not.toHaveBeenCalled(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { waitUntil } from "../core/wait"; | ||
| import { createReadinessWaitOptions } from "../onboard/readiness-wait"; | ||
|
|
||
| export function waitForAgentGatewayReady(options: { | ||
| timeoutSeconds: number; | ||
| probe: () => boolean; | ||
| sleepSeconds: (seconds: number) => void; | ||
| now?: () => number; | ||
| }): boolean { | ||
| const waitOptions = createReadinessWaitOptions({ | ||
| budgetMs: Math.max(0, options.timeoutSeconds * 1000), | ||
| maxIntervalMs: 3_000, | ||
| now: options.now, | ||
| sleep: (ms) => options.sleepSeconds(ms / 1000), | ||
| }); | ||
| return waitOptions !== null && waitUntil(options.probe, waitOptions); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.