summaryrefslogtreecommitdiff
path: root/libpod/container_internal.go
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2021-09-28 17:01:22 +0200
committerMatthew Heon <matthew.heon@pm.me>2021-09-29 16:39:29 -0400
commitba74d6e6ecc2cc8e1480a466e29a078a93e24afa (patch)
treec5051bfcdcdc6363d1b4dabfa71eb7132500bd64 /libpod/container_internal.go
parenta1199dbaf1e42de665a8fc40ba0dd17d21f05ab7 (diff)
downloadpodman-ba74d6e6ecc2cc8e1480a466e29a078a93e24afa.tar.gz
podman-ba74d6e6ecc2cc8e1480a466e29a078a93e24afa.tar.bz2
podman-ba74d6e6ecc2cc8e1480a466e29a078a93e24afa.zip
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 <rothberg@redhat.com> <MH: Fixed cherry-pick conflicts>
Diffstat (limited to 'libpod/container_internal.go')
-rw-r--r--libpod/container_internal.go7
1 files changed, 3 insertions, 4 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 18b80475b..2ca49758d 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -982,12 +982,11 @@ func (c *Container) checkDependenciesRunning() ([]string, error) {
}
// Check the status
- conf := depCtr.Config()
state, err := depCtr.State()
if err != nil {
return nil, errors.Wrapf(err, "error retrieving state of dependency %s of container %s", dep, c.ID())
}
- if state != define.ContainerStateRunning && !conf.IsInfra {
+ if state != define.ContainerStateRunning && !depCtr.config.IsInfra {
notRunning = append(notRunning, dep)
}
depCtrs[dep] = depCtr
@@ -1063,7 +1062,7 @@ func (c *Container) cniHosts() string {
var hosts string
if len(c.state.NetworkStatus) > 0 && len(c.state.NetworkStatus[0].IPs) > 0 {
ipAddress := strings.Split(c.state.NetworkStatus[0].IPs[0].Address.String(), "/")[0]
- hosts += fmt.Sprintf("%s\t%s %s\n", ipAddress, c.Hostname(), c.Config().Name)
+ hosts += fmt.Sprintf("%s\t%s %s\n", ipAddress, c.Hostname(), c.config.Name)
}
return hosts
}
@@ -2127,7 +2126,7 @@ func (c *Container) canWithPrevious() error {
// JSON files for later export
func (c *Container) prepareCheckpointExport() error {
// save live config
- if _, err := metadata.WriteJSONFile(c.Config(), c.bundlePath(), metadata.ConfigDumpFile); err != nil {
+ if _, err := metadata.WriteJSONFile(c.config, c.bundlePath(), metadata.ConfigDumpFile); err != nil {
return err
}