-
Notifications
You must be signed in to change notification settings - Fork 632
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
fix nerdctl ps slow on heavy IO system by using goroutine #3673
Conversation
402054c
to
76c2590
Compare
3eac91f
to
b5d0902
Compare
b5d0902
to
9cff522
Compare
9cff522
to
cfc18b9
Compare
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, thanks
b629627
to
87bb294
Compare
// formatter.ContainerStatus(ctx, c) is time consuming so we do it in goroutines and return the container's id with status as a map. | ||
// prepareContainers func will use this map to avoid call formatter.ContainerStatus again. | ||
for _, c := range containers { | ||
wg.Add(1) |
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.
wg.Add(1) | |
c := c | |
wg.Add(1) |
the above line code simplifies the code and avoid using a mutex, right ?
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.
@ningmingxiao WDYT ?
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.
avoid using a mutex
I don't think it will avoid the mutex. Current write to a map still need the mutex.
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.
indeed map are note safe for concurrent writes. thanks @djdongjin for your pointer ;)
87bb294
to
659417b
Compare
Signed-off-by: ningmingxiao <[email protected]>
659417b
to
788fc0c
Compare
@ningmingxiao PTAL on this thread #3673 (comment) |
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.
Thanks
formatter.ContainerStatus will use some time. If plenty of calls are coming, this will use much time.
before
after this commit
@AkihiroSuda