Skip to content
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

reduce some memory of log driver #1877

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ningmingxiao
Copy link
Contributor

No description provided.

@ningmingxiao
Copy link
Contributor Author

ningmingxiao commented Jan 18, 2023

nerdctl run -d busybox top

USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root        7784  0.0  0.0 711952  6860 ?        Sl   23:02   0:00 /usr/local/bin/containerd-shim-runc-v2 -namespace default -id 18ed48c9255db730259c062c33f4e6c1ee2dbed436aba0afd817232a98990f88 -address 
root        7793  0.3  0.1 727996 22192 ?        Sl   23:02   0:00  \_ /usr/local/bin/nerdctl _NERDCTL_INTERNAL_LOGGING /var/lib/nerdctl/1935db59
root        7813  8.0  0.0   4776   352 ?        Ss   23:02   0:00  \_ top

use this commit

USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root        7217  0.0  0.0 710800  7868 ?        Sl   23:00   0:00 /usr/local/bin/containerd-shim-runc-v2 -namespace default -id ee28eac42896eb67088ce2297fe1fbeb14a7b21efda0d4f5b9f89329d99ba6b2 -address 
root        7226  0.0  0.0 709096  3884 ?        Sl   23:00   0:00  \_ /usr/local/bin/nlog-driver _NERDCTL_INTERNAL_LOGGING /var/lib/nerdctl/1935db59
root        7244  8.6  0.0   4776  1452 ?        Ss   23:00   0:00  \_ top

the rss of nerdctl will reduce from 22192 to 3884 per container

@ningmingxiao ningmingxiao changed the title reduce some memory for log driver reduce some memory of log driver Jan 18, 2023
@AkihiroSuda
Copy link
Member

/usr/local/bin/nlog-driver _NERDCTL_INTERNAL_LOGGING /var/lib/nerdctl/1935db59

I think this should be like /usr/local/bin/nerdctl-logging-json-file log-path <LOGPATH> max-size <MAXSIZE> max-file <MAXFILE> tag <TAG> so that the logger binary can be used by other containerd applications.
Same applies to other built-in logging drivers.

The binary path should be determined by os.Executable() + "-logging-" + logDriverName.

@ningmingxiao
Copy link
Contributor Author

/usr/local/bin/nlog-driver _NERDCTL_INTERNAL_LOGGING /var/lib/nerdctl/1935db59

I think this should be like /usr/local/bin/nerdctl-logging-json-file log-path <LOGPATH> max-size <MAXSIZE> max-file <MAXFILE> tag <TAG> so that the logger binary can be used by other containerd applications. Same applies to other built-in logging drivers.

The binary path should be determined by os.Executable() + "-logging-" + logDriverName.

nerdctl-logging-json-file this name when use auto complete will show two names nerdctl-logging-json-file and nerdctl,wich is not friendly.

1 similar comment
@ningmingxiao
Copy link
Contributor Author

/usr/local/bin/nlog-driver _NERDCTL_INTERNAL_LOGGING /var/lib/nerdctl/1935db59

I think this should be like /usr/local/bin/nerdctl-logging-json-file log-path <LOGPATH> max-size <MAXSIZE> max-file <MAXFILE> tag <TAG> so that the logger binary can be used by other containerd applications. Same applies to other built-in logging drivers.

The binary path should be determined by os.Executable() + "-logging-" + logDriverName.

nerdctl-logging-json-file this name when use auto complete will show two names nerdctl-logging-json-file and nerdctl,wich is not friendly.

@AkihiroSuda
Copy link
Member

AkihiroSuda commented Jan 19, 2023

We can consider installing it to /usr/local/libexec then, or name it containerd-logging-json-file

@ningmingxiao
Copy link
Contributor Author

We can consider installing it to /usr/local/libexec then, or name it containerd-logging-json-file

ok

args := map[string]string{
logging.MagicArgv1: dataStore,
}

return cio.LogURIGenerator("binary", selfExe, args)
nlogDriver, err := exec.LookPath("nlog-driver")
if err != nil {
Copy link
Contributor

@yzxiu yzxiu Jan 19, 2023

Choose a reason for hiding this comment

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

i think the log driver in nerdctl can be retained
and it is compatible with containers created by older versions.

	if err != nil {
	    logrus.WithError(err).Warnf("nlog-driver not found")
	    nlogDriver, err = os.Executable()
	    if err != nil {
		return nil, err
	    }
	}

@ningmingxiao
Copy link
Contributor Author

ningmingxiao commented Jan 21, 2023

We can consider installing it to /usr/local/libexec then, or name it containerd-logging-json-file

log-driver=json-file journald fluentd syslog ,I'm not sure whether to split or merge them together?
if split them maybe save some memory,but will generate multiple binaries.
@AkihiroSuda

Signed-off-by: ningmingxiao <ning.mingxiao@zte.com.cn>
@AkihiroSuda
Copy link
Member

AkihiroSuda commented Jan 22, 2023

Generating multiple binaries seems fine.
If the binary size becomes problematic we can symlink them to a common binary and check argv[0] to switch the driver later.

@fahedouch WDYT?

@manugupt1
Copy link
Contributor

I am not sure if this idea is crazy, but wanted to check if it warrants merit. Is it possible to use 3rd party shim logger facility and install these binaries to nerdctl to use them. The run command can have an alias to these loggers. If the memory optimized binary is found use that; else use nerdctl as a logging binary

@fahedouch fahedouch self-requested a review February 8, 2023 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants