-
Notifications
You must be signed in to change notification settings - Fork 9
Reload defunct runners #68
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -162,7 +162,13 @@ | ||||||||||||||||||||||||||||||||||
for r, slot := range l.runners { | |||||||||||||||||||||||||||||||||||
unused := l.references[slot] == 0 | |||||||||||||||||||||||||||||||||||
idle := unused && now.Sub(l.timestamps[slot]) > runnerIdleTimeout | |||||||||||||||||||||||||||||||||||
if unused && (!idleOnly || idle) { | |||||||||||||||||||||||||||||||||||
defunct := false | |||||||||||||||||||||||||||||||||||
select { | |||||||||||||||||||||||||||||||||||
case <-l.slots[slot].done: | |||||||||||||||||||||||||||||||||||
defunct = true | |||||||||||||||||||||||||||||||||||
default: | |||||||||||||||||||||||||||||||||||
} | |||||||||||||||||||||||||||||||||||
if unused && (!idleOnly || idle || defunct) { | |||||||||||||||||||||||||||||||||||
l.log.Infof("Evicting %s backend runner with model %s in %s mode", | |||||||||||||||||||||||||||||||||||
r.backend, r.model, r.mode, | |||||||||||||||||||||||||||||||||||
) | |||||||||||||||||||||||||||||||||||
|
@@ -372,9 +378,17 @@ | ||||||||||||||||||||||||||||||||||
// See if we can satisfy the request with an existing runner. | |||||||||||||||||||||||||||||||||||
existing, ok := l.runners[runnerKey{backendName, model, mode}] | |||||||||||||||||||||||||||||||||||
if ok { | |||||||||||||||||||||||||||||||||||
l.references[existing] += 1 | |||||||||||||||||||||||||||||||||||
l.timestamps[existing] = time.Time{} | |||||||||||||||||||||||||||||||||||
return l.slots[existing], nil | |||||||||||||||||||||||||||||||||||
select { | |||||||||||||||||||||||||||||||||||
case <-l.slots[existing].done: | |||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it'd make sense to also run There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, that makes sense. |
|||||||||||||||||||||||||||||||||||
l.log.Warnf("Will reload defunct %s runner for %s. Runner error: %s.", backendName, model, | |||||||||||||||||||||||||||||||||||
Check failureCode scanning / CodeQL Log entries created from user input High
This log entry depends on a
user-provided value Error loading related location Loading
Copilot AutofixAI 2 days ago To fix the issue, the The sanitization should be applied directly before the log statement to ensure that the logged value is safe. This fix will not alter the functionality of the code but will enhance its security.
Suggested changeset
1
pkg/inference/scheduling/loader.go
Copilot is powered by AI and may make mistakes. Always verify output.
Positive FeedbackNegative Feedback
Refresh and try again.
|
|||||||||||||||||||||||||||||||||||
l.slots[existing].err) | |||||||||||||||||||||||||||||||||||
// Evict the defunct runner if it is not in use by anyone else. | |||||||||||||||||||||||||||||||||||
l.evictRunner(backendName, model) | |||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense. Though I wonder if it would not be safer to let the reference counting work normally, issue and idle check here, and expand the idle check logic to look for defunct or stale runners. WDYT? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I like this! Although, in this specific case, this code which comes right after the code you're changing will evict all (1, currently, but still) runners if all the slots are full and the current one that's attempted to be loaded is defunct and not clean up, right?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm pretty sure forcing the refcount to 0 does put us at a risk of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that we can't force the refcount to The bigger issue I see with the new logic is that I think what I would do is put a label (say |
|||||||||||||||||||||||||||||||||||
default: | |||||||||||||||||||||||||||||||||||
l.references[existing] += 1 | |||||||||||||||||||||||||||||||||||
l.timestamps[existing] = time.Time{} | |||||||||||||||||||||||||||||||||||
return l.slots[existing], nil | |||||||||||||||||||||||||||||||||||
} | |||||||||||||||||||||||||||||||||||
} | |||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||
// If there's not sufficient memory or all slots are full, then try | |||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This chunk looks good, I would just update the doc comment for
evict
to reflect that it also evicts defunct runners if possible.