Skip to content

perf(worker-utils): overlap callback connection setup with inference - #2968

Draft
sytianhe wants to merge 1 commit into
NVIDIA:mainfrom
sytianhe:sytianhe/feat/callback-preconnect
Draft

sytianhe wants to merge 1 commit into
NVIDIA:mainfrom
sytianhe:sytianhe/feat/callback-preconnect

Conversation

@sytianhe

Copy link
Copy Markdown

TL;DR

Add default-off callback connection preparation so a stateless HTTP worker can overlap first-hop DNS/TCP/TLS setup with function execution. The existing HTTP transport still performs the normal authenticated callback POST and owns subsequent connection reuse.

Additional Details

The callback route is available before function execution, but cold callback connection setup currently begins when response headers become available. This change can move that setup off the response-delivery path without changing the invocation service or sending an early HTTP request.

NVCF_CALLBACK_PRECONNECT_ENABLED=true enables the feature per utility. A bounded pool coalesces preparation by target origin and full proxy identity. The transport's supported dial hooks claim prepared connections only for response POSTs, after ordinary idle reuse has had priority. Request-data GETs cannot consume them.

The initial limits are 16 unclaimed preparation entries, a 2-second setup budget, a 30-second unused lifetime, and a bounded cooldown limiting preparation starts. A claimed connection transfers to real callback work; these are speculative-entry limits, not an active-request concurrency limit. Cancellation, expiry, unexpected data and peer close release unused sockets. Missing or failed preparation falls back to normal dialing without replaying the POST.

The implementation preserves the current proxy CA trust configuration and HTTP/1 callback behavior. It adds setup/TLS spans, a prepared-connection claim event, structured context and bounded, pre-initialized lifecycle metrics. Expected cancellation is distinct from setup failure. No callback URL, token or payload is added to feature logs or metric labels.

No third-party dependency versions, licenses or NOTICE entries change.

For the Reviewer

This is a draft for maintainer design review. Review socket ownership during cancellation and handoff, proxy/target isolation, idle reuse, and the initial resource limits.

Waiting for an unfinished preparation can add its remaining setup budget before fallback. Long function execution can outlive an unused prepared socket. The default remains disabled pending workload qualification. Local synthetic tests do not establish deployment-wide latency savings or zero resource overhead.

For QA

Local validation passed:

  • bazel build //src/clis/nvcf-cli:nvcf-cli.
  • bazel test //src/compute-plane-services/worker-utils/worker/httpstream:httpstream_test.
  • Native Go callback tests, three short race repetitions, vet and a disposable binary build using ./test-callback-preconnect.sh callback.
  • Isolated Linux worker, service and callback tests, three callback race repetitions, vet and a disposable binary build using ./test-callback-preconnect.sh all.
  • A final Linux callback run with external networking disabled.
  • The scoped root Gazelle check, Markdown lint and git diff --check.

The tests use generated certificates, synthetic tokens, loopback HTTP/TLS servers and embedded NATS. Coverage includes proxy and target CA trust, buffered and streaming responses, route isolation, idle reuse, fallback, cancellation, expiry and concurrency. The injected-delay experiment checks prepared-socket consumption and reports timing without a wall-clock correctness threshold. No live requests or deployment-specific results are included.

The full repository suite and a full self-managed stack were not run.

Full-stack deployment and live traffic qualification remain necessary before enabling this outside a test environment. Stateful session and task execution are outside this HTTP callback feature.

Issues

Fixes #2967

Checklist

  • I am familiar with the Contributing Guidelines.
  • I have signed off my commits for Developer Certificate of Origin (DCO) compliance.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

Prepare bounded, default-off first-hop connections through supported HTTP
transport dial hooks. Preserve authentication, TLS trust, proxy routing,
streaming and ordinary idle reuse. Add bounded lifecycle observability and
synthetic socket and worker integration coverage.

Fixes NVIDIA#2967

Signed-off-by: sytianhe <605748+sytianhe@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Oct 28, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[worker-utils] Overlap callback connection setup with inference

1 participant