-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Conversation
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.
The correct way to fix is is to
- keep the fall-through in the first
select
- ditch the fall-through in the 2nd
select
- expand the 2nd
select
with branches forstop
andw.Priority
FWIW, the spin loop was introduced in #835. |
@@ -91,10 +91,18 @@ func (w *Warmer) Loop(logger log.Logger, stop <-chan struct{}, wg *sync.WaitGrou | |||
w.warm(ctx, logger, im.Name, im.Credentials) | |||
} else { | |||
select { | |||
case <-stop: | |||
logger.Log("stopping", "true") |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
registry/cache/warming.go
Outdated
w.warm(ctx, logger, name, creds) | ||
} else { | ||
logger.Log("priority", name.String(), "err", "no creds available") | ||
} |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Why was the original code not consuming an entire core all the time? Is that because every |
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.
Looks good in sum @stefanprodan, thank you. Thanks @rade for helping knock it into shape. Please rebase into a single commit -- or two, if you want to do the factoring of |
@squaremo let me know if it's ok for me to merge this PR. |
Thank you. I am a bit baffled by the commit message though -- did you really add those things? (I don't think you did.) Something like this would describe what's being fixed:
(the commit summary can be a bit shorter too -- just "Avoid spin in cache refresh loop" would be fine IMO). |
To implement the loop as described in the comment above it, when the backlog is empty we need to block until the refresh tick fires (or a priority image comes in). By having a default case, it's possible to spin.
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.
LGTM, thank you for your patience Stefan.
Fix #926
Tested with
stefanprodan/flux:cpufix-090b064-wip3
on GKE: