Skip to content

fix(hostagent): minimize lock contention in NetworkManager#55

Draft
tsorya wants to merge 1 commit into
NVIDIA:public-mainfrom
tsorya:igal/minimize-nm-lock-contention
Draft

fix(hostagent): minimize lock contention in NetworkManager#55
tsorya wants to merge 1 commit into
NVIDIA:public-mainfrom
tsorya:igal/minimize-nm-lock-contention

Conversation

@tsorya
Copy link
Copy Markdown

@tsorya tsorya commented May 30, 2026

run() and AddNetworkRequest() previously held the write lock across slow operations (API calls, PCI ops, netlink, network config), causing AddNetworkRequest HTTP handler to block for the entire run() cycle.

Refactor to hold locks only for in-memory map operations:

  • run(): snapshot reqs under RLock, process lock-free
  • AddNetworkRequest(): RLock for map checks, no lock for API calls, brief Lock for map write
  • processNetworkRequest(): use removeRequest() helper for thread-safe map deletion

run() and AddNetworkRequest() previously held the write lock across
slow operations (API calls, PCI ops, netlink, network config), causing
AddNetworkRequest HTTP handler to block for the entire run() cycle.

Refactor to hold locks only for in-memory map operations:
- run(): snapshot reqs under RLock, process lock-free
- AddNetworkRequest(): RLock for map checks, no lock for API calls,
  brief Lock for map write
- processNetworkRequest(): use removeRequest() helper for thread-safe
  map deletion

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant