Skip to content

refactor: reduce loading overhead tracker lock contention#86

Open
sunby wants to merge 2 commits into
zilliztech:masterfrom
sunby:optimize-loading-overhead-tracker-locks
Open

refactor: reduce loading overhead tracker lock contention#86
sunby wants to merge 2 commits into
zilliztech:masterfrom
sunby:optimize-loading-overhead-tracker-locks

Conversation

@sunby

@sunby sunby commented May 6, 2026

Copy link
Copy Markdown

Summary

This PR reduces lock contention in LoadingOverheadTracker by splitting the previous single global mutex into:

  • a std::shared_mutex for group/handle map access
  • a per-group GroupState mutex for reservation state updates

The hot-path operations (Reserve, Release, HasFiniteUpperBound, and GetUpperBound) now take a shared map lock, copy the target group state pointer, and only serialize updates within that group. This allows independent groups to reserve/release loading overhead without blocking each other on one global tracker mutex.

Registration and cleanup behavior is preserved:

  • existing groups still reuse the same handle and increment ref counts
  • finite upper bounds still take the max per dimension when re-registered
  • unlimited upper bounds can still be replaced by the registered bound
  • Unregister still removes the group at ref count 0 and logs residual reservations before cleanup

Testing

  • pre-commit passed
  • UT on ubuntu-22.04 passed
  • UT on macos-15 passed

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