Skip to content

gpu-tracker: remove redundant signal handler, simplify locking#110

Merged
sgopinath1 merged 1 commit intoROCm:mainfrom
shiv-tyagi:remove-signal-handler
Apr 7, 2026
Merged

gpu-tracker: remove redundant signal handler, simplify locking#110
sgopinath1 merged 1 commit intoROCm:mainfrom
shiv-tyagi:remove-signal-handler

Conversation

@shiv-tyagi
Copy link
Copy Markdown
Member

  • Remove setupSignalHandler. flock advisory locks are kernel-managed and automatically released when the process exits, making the signal handler redundant. It also leaked a goroutine and channel on every method call. Signal handling is an application-level concern; a library should not call os.Exit or register global signal handlers, as it takes control away from the caller.
  • Replace manual time.Tick poll loop in acquireLock with flock.TryLockContext, fixing a ticker leak and removing reimplemented retry logic.
  • Remove defer recover from all 9 public methods. Panics indicate bugs that should crash loudly with a stack trace, not be silently converted to errors. A library should not swallow panics; whether to recover is an application-level policy that belongs in the caller, not the library.
  • Simplify deferred unlock from a 4-line nil-check closure to defer lock.Unlock, since lock is guaranteed non-nil after a successful acquireLock.
  • Remove redundant error wrapping on lock failures.

The signal handler, panic recovery, and verbose lock boilerplate added around 180 lines of complexity with no correctness benefit. None of these belong in a library as they override decisions that should be made by the application.

- Remove setupSignalHandler. flock advisory locks are kernel-managed and
  automatically released when the process exits, making the signal handler
  redundant. It also leaked a goroutine and channel on every method call.
  Signal handling is an application-level concern; a library should not
  call os.Exit or register global signal handlers, as it takes control
  away from the caller.
- Replace manual time.Tick poll loop in acquireLock with
  flock.TryLockContext, fixing a ticker leak and removing reimplemented
  retry logic.
- Remove defer recover from all 9 public methods. Panics indicate bugs
  that should crash loudly with a stack trace, not be silently converted
  to errors. A library should not swallow panics; whether to recover is
  an application-level policy that belongs in the caller, not the library.
- Simplify deferred unlock from a 4-line nil-check closure to
  defer lock.Unlock, since lock is guaranteed non-nil after a successful
  acquireLock.
- Remove redundant error wrapping on lock failures.

The signal handler, panic recovery, and verbose lock boilerplate added
around 180 lines of complexity with no correctness benefit. None of these
belong in a library as they override decisions that should be made by the
application.
Copy link
Copy Markdown
Collaborator

@sgopinath1 sgopinath1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sgopinath1 sgopinath1 merged commit 0e4f946 into ROCm:main Apr 7, 2026
3 checks 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.

2 participants