From 5d6ea90e756cd48c90d9549d25c0150c9bb5c50c Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Tue, 28 Sep 2021 17:01:22 +0200 Subject: libpod: do not call (*container).Config() Access the container's config field directly inside of libpod instead of calling `Config()` which in turn creates expensive JSON deep copies. Accessing the field directly drops memory consumption of a simple `podman run --rm busybox true` from 1245kB to 410kB. [NO TESTS NEEDED] Signed-off-by: Valentin Rothberg --- libpod/pod.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'libpod/pod.go') diff --git a/libpod/pod.go b/libpod/pod.go index e4516b354..c0b0a974b 100644 --- a/libpod/pod.go +++ b/libpod/pod.go @@ -164,8 +164,7 @@ func (p *Pod) PidMode() string { if err != nil { return "" } - conf := infra.Config() - ctrSpec := conf.Spec + ctrSpec := infra.config.Spec if ctrSpec != nil && ctrSpec.Linux != nil { for _, ns := range ctrSpec.Linux.Namespaces { if ns.Type == specs.PIDNamespace { @@ -186,8 +185,7 @@ func (p *Pod) UserNSMode() string { if err != nil { return "" } - conf := infra.Config() - ctrSpec := conf.Spec + ctrSpec := infra.config.Spec if ctrSpec != nil && ctrSpec.Linux != nil { for _, ns := range ctrSpec.Linux.Namespaces { if ns.Type == specs.UserNamespace { -- cgit v1.2.3-54-g00ecf