mirror of
https://github.com/containers/podman.git
synced 2025-06-03 12:17:13 +08:00
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>
This commit is contained in:
@ -923,12 +923,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
|
||||
@ -1003,7 +1002,7 @@ func (c *Container) cniHosts() string {
|
||||
for _, status := range c.getNetworkStatus() {
|
||||
for _, netInt := range status.Interfaces {
|
||||
for _, netAddress := range netInt.Networks {
|
||||
hosts += fmt.Sprintf("%s\t%s %s\n", netAddress.Subnet.IP.String(), c.Hostname(), c.Config().Name)
|
||||
hosts += fmt.Sprintf("%s\t%s %s\n", netAddress.Subnet.IP.String(), c.Hostname(), c.config.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2106,7 +2105,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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user