FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

optimize nerdctl ps by ningmingxiao · Pull Request #4732 · containerd/nerdctl · GitHub

optimize nerdctl ps - #4732

Open
ningmingxiao wants to merge 1 commit into
containerd:mainfrom
ningmingxiao:optimize_ps
Open

ningmingxiao wants to merge 1 commit into
containerd:mainfrom
ningmingxiao:optimize_ps

Conversation

Copy link
Copy Markdown
Contributor

speed up nerdctl ps we don't need call get container spec again.

Signed-off-by: ningmingxiao <ning.mingxiao@zte.com.cn>
}
}

func GetCommandFromSpec(spec typeurl.Any, trunc, quote bool) (string, error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This code does not need to be a separate function, as it is called only once

ningmingxiao Feb 4, 2026
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

since spec have much data, If I use it into a function, it may cause quickly gc (gc may happen after the function return)
if I use it into a for loop (gc may happen after every loop). @AkihiroSuda

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

You can just create a scope with {}

Also please add the code comments about GC

Comment thread pkg/cmd/container/list.go
return nil, err
}
return prepareContainers(ctx, client, containers, cMap, options)
return prepareContainers(ctx, client, &containers, cMap, options)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

why?

Comment thread pkg/cmd/container/list.go
}
li.Size = containerSize
}
(*containers)[i] = nil

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

?

ningmingxiao Feb 4, 2026
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

here I want to let gc recycle the memory quickly

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

That behavior has to be explained in the code comments in the function declaration

Copy link
Copy Markdown
Member

speed up

Any benchmark results?

Copy link
Copy Markdown
Contributor Author

1000 container speedup 1-2s @AkihiroSuda

ningmingxiao commented Feb 4, 2026
edited
Loading

Copy link
Copy Markdown
Contributor Author

I find nerdctl ps use about 1g memory when container spec size is too big there are many env in spec (because user use enableServiceLinks:true and k8s has many services )
see :containerd/containerd#12846

AkihiroSuda added this to the v2.3.0 milestone Feb 4, 2026

Copy link
Copy Markdown
Contributor Author

we can wait containerd/containerd#12846 or containerd/containerd#12862 to be merged. @AkihiroSuda

AkihiroSuda removed this from the v2.3.0 milestone Apr 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL