Git Product home page Git Product logo

Comments (9)

mheon avatar mheon commented on May 18, 2024 1

Creating containers taking a long time was somewhat expected, we do a lot of network-heavy image checks. The scaling on ps is really concerning, though, that ought to be a fast operation. We should look into this.

from podman.

surajssd avatar surajssd commented on May 18, 2024

starting the containers:

# for i in `seq 1 15`;                        
> do                                                
> kpod run -d fedora sleep 10000                    
> done                                              
e686f462bf517fcc10c2e8efb3eaa1839eb1a1c2b84f8760434b53d649e0b1fb
8e7bd27d051b36b7cd9f70215fbcefbafd8b9277c1b30c451381e448d3c06bc0
0127169c8ab067a0fd369112e5dcf4f699bad98f189271728e0dc1fb1630e4f6
3fa7a4f3ecaabce148548fa1e4020346422252424f7e22b04ee450f15d43bacb
52dde04213cf9478975615d7c84d52a8ee1fef7d03ab4f64e1974c03a079ce5d
0a4835766878fb74cb7d58c958054ff3276ed3fa9be38258cf7d6a13e3ddd84e
3f7000e769a3f150517c93ea276983457c310bb1a798260a6686d119539d6107
0b8a3f0dde3f04d587df5f1f64fe5b26b1f410647ba67ce9e5c95d58e8b83a61
9a0c36841c09824ed62707474741f644c4e8fe953e001e35c664a84e9fa8f880
9f5ce2ed5d5ced1ae5cce570c605c17effee0b95bd56d0cad6f6f2080a260aba
8a51c149109e4e701d72f1e66c4376dbd949140ca7a5fdfe0cc5319f1e6aa486
834789419e360466271ce81075c1eb2078bdf5d75ba25244427dcf8316f05180
afa779e0e92d17c0322482a5b0bcbaf4d65a84a9e3b9cceaf0025e5a4b610bbd
bee9c4ca14a36c73bb3917cf8284372ab246216c8b13a7f0b27a6cec51d76e96
32e0359eddb7996523f3d1a5af299f7c3295d23d70337c9695018b5a02a9a194

listing them:

# time ./bin/kpod ps
CONTAINER ID   IMAGE                             COMMAND       CREATED AT           STATUS                  PORTS   NAMES
32e0359eddb7   docker.io/library/fedora:latest   sleep 10000   19 seconds ago       Up 19 seconds ago               gallant_dubinsky
bee9c4ca14a3   docker.io/library/fedora:latest   sleep 10000   23 seconds ago       Up 23 seconds ago               keen_fermat
afa779e0e92d   docker.io/library/fedora:latest   sleep 10000   26 seconds ago       Up 26 seconds ago               sharp_swanson
834789419e36   docker.io/library/fedora:latest   sleep 10000   30 seconds ago       Up 30 seconds ago               practical_nightingale
8a51c149109e   docker.io/library/fedora:latest   sleep 10000   33 seconds ago       Up 33 seconds ago               quizzical_poitras
9f5ce2ed5d5c   docker.io/library/fedora:latest   sleep 10000   37 seconds ago       Up 37 seconds ago               peaceful_swirles
9a0c36841c09   docker.io/library/fedora:latest   sleep 10000   40 seconds ago       Up 40 seconds ago               elastic_boyd
0b8a3f0dde3f   docker.io/library/fedora:latest   sleep 10000   44 seconds ago       Up 44 seconds ago               stoic_lalande
3f7000e769a3   docker.io/library/fedora:latest   sleep 10000   47 seconds ago       Up 47 seconds ago               quirky_booth
0a4835766878   docker.io/library/fedora:latest   sleep 10000   50 seconds ago       Up 50 seconds ago               focused_jones
52dde04213cf   docker.io/library/fedora:latest   sleep 10000   54 seconds ago       Up 54 seconds ago               jovial_northcutt
3fa7a4f3ecaa   docker.io/library/fedora:latest   sleep 10000   57 seconds ago       Up 57 seconds ago               sharp_jennings
0127169c8ab0   docker.io/library/fedora:latest   sleep 10000   About a minute ago   Up About a minute ago           blissful_swartz
8e7bd27d051b   docker.io/library/fedora:latest   sleep 10000   About a minute ago   Up About a minute ago           suspicious_brahmagupta
e686f462bf51   docker.io/library/fedora:latest   sleep 10000   About a minute ago   Up About a minute ago           keen_mccarthy

real    0m6.037s
user    0m0.475s
sys     0m0.365s

the listing took 6seconds, and also if you look closely each container took 3seconds to come up.

from podman.

baude avatar baude commented on May 18, 2024

Ill take a look at this later this week. I did some profiling when this came up before and the time was spent in cs doing IO iirc.

from podman.

surajssd avatar surajssd commented on May 18, 2024

When I checked last time trying to profile, getting container PID was taking almost ~30ms maybe that is adding up!

from podman.

baude avatar baude commented on May 18, 2024
ROUTINE ======================== main.generatePsOutput in /root/go/src/github.com/projectatomic/libpod/cmd/kpod/ps.go                                                                                              
         0       50ms (flat, cum) 55.56% of Total   
         .          .    535:           if err != nil {                                                  
         .          .    536:                   return errors.Wrapf(err, "unable to create JSON for output")                                                                                                       
         .          .    537:           }           
         .          .    538:           out = formats.JSONStructArray{Output: psToGeneric([]psTemplateParams{}, psOutput)}                                                                                         
         .          .    539:   default:            
         .       50ms    540:           psOutput, err := getTemplateOutput(containers, opts)             
         .          .    541:           if err != nil {                                                  
         .          .    542:                   return errors.Wrapf(err, "unable to create output")      
         .          .    543:           }           
         .          .    544:           out = formats.StdoutTemplateArray{Output: psToGeneric(psOutput, []psJSONParams{}), Template: opts.format, Fields: psOutput[0].headerMap()}                                 
         .          .    545:   }                   
ROUTINE ======================== main.getTemplateOutput in /root/go/src/github.com/projectatomic/libpod/cmd/kpod/ps.go                                                                                             
         0       50ms (flat, cum) 55.56% of Total   
         .          .    375:func getTemplateOutput(containers []*libpod.Container, opts psOptions) ([]psTemplateParams, error) {                                                                                  
         .          .    376:   var psOutput []psTemplateParams                                          
         .          .    377:   var status string   
         .          .    378:   for _, ctr := range containers {                                         
         .          .    379:           ctrID := ctr.ID()                                                
         .       10ms    380:           conConfig := ctr.Config()                                        
         .          .    381:           conState, err := ctr.State()                                     
         .          .    382:           if err != nil {                                                  
         .          .    383:                   return psOutput, errors.Wrapf(err, "unable to obtain container state")                                                                                             
         .          .    384:           }           
         .       10ms    385:           exitCode, err := ctr.ExitCode()                                  
         .          .    386:           if err != nil {                                                  
         .          .    387:                   return psOutput, errors.Wrapf(err, "unable to obtain container exit code")                                                                                         
         .          .    388:           }           
         .       30ms    389:           pid, err := ctr.PID()                                            
         .          .    390:           if err != nil {                                                  
         .          .    391:                   return psOutput, errors.Wrapf(err, "unable to obtain container pid")                                                                                               
         .          .    392:           }           
         .          .    393:           runningFor := units.HumanDuration(time.Since(conConfig.CreatedTime))                                                                                                       
         .          .    394:           createdAt := runningFor + " ago"                                 
ROUTINE ======================== main.main in /root/go/src/github.com/projectatomic/libpod/cmd/kpod/main.go                                                                                                        
         0       80ms (flat, cum) 88.89% of Total   
         .          .    144:           cli.StringSliceFlag{                                             
         .          .    145:                   Name:  "storage-opt",                                    
         .          .    146:                   Usage: "used to pass an option to the storage driver",   
         .          .    147:           },          
         .          .    148:   }                   
         .       80ms    149:   if err := app.Run(os.Args); err != nil {                                 
         .          .    150:           if debug {  
         .          .    151:                   logrus.Errorf(err.Error())                               
         .          .    152:           } else {    
         .          .    153:                   fmt.Fprintln(os.Stderr, err.Error())                     
         .          .    154:           }           
ROUTINE ======================== main.psCmd in /root/go/src/github.com/projectatomic/libpod/cmd/kpod/ps.go                                                                                                         
         0       80ms (flat, cum) 88.89% of Total   
         .          .    196:                   }   
         .          .    197:                   filterFuncs = append(filterFuncs, generatedFunc)         
         .          .    198:           }           
         .          .    199:   }                   
         .          .    200:                       
         .       30ms    201:   containers, err := runtime.GetContainers(filterFuncs...)                 
         .          .    202:   var outputContainers []*libpod.Container                                 
         .          .    203:   if opts.latest && len(containers) > 0 {                                  
         .          .    204:           outputContainers = append(outputContainers, containers[0])       
         .          .    205:   } else if opts.last > 0 && opts.last <= len(containers) {                
         .          .    206:           outputContainers = append(outputContainers, containers[:opts.last]...)                                                                                                     
         .          .    207:   } else {            
         .          .    208:           outputContainers = containers                                    
         .          .    209:   }                   
         .          .    210:                       
         .       50ms    211:   return generatePsOutput(outputContainers, opts)                          
         .          .    212:}                      
         .          .    213:                       
         .          .    214:// checkFlagsPassed checks if mutually exclusive flags are passed together  
         .          .    215:func checkFlagsPassed(c *cli.Context) error {                               
         .          .    216:   // latest, and last are mutually exclusive.                              
ROUTINE ======================== main.psCmd.func1 in /root/go/src/github.com/projectatomic/libpod/cmd/kpod/ps.go                                                                                                   
         0       30ms (flat, cum) 33.33% of Total   
         .          .    176:   // When we are dealing with latest or last=n, we need to                 
         .          .    177:   // get all containers.                                                   
         .          .    178:   if !opts.all && !opts.latest && opts.last < 1 {                          
         .          .    179:           // only get running containers                                   
         .          .    180:           filterFuncs = append(filterFuncs, func(c *libpod.Container) bool {                                                                                                         
         .       30ms    181:                   state, _ := c.State()                                    
         .          .    182:                   return state == libpod.ContainerStateRunning             
         .          .    183:           })          
         .          .    184:   }                   
         .          .    185:                       
         .          .    186:   if opts.filter != "" {                                     

from podman.

baude avatar baude commented on May 18, 2024
(pprof) list PID
Total: 90ms
ROUTINE ======================== github.com/projectatomic/libpod/libpod.(*Container).PID in /root/go/src/github.com/projectatomic/libpod/libpod/container.go
         0       30ms (flat, cum) 33.33% of Total
         .          .    348:// An error is returned if the container is not running
         .          .    349:func (c *Container) PID() (int, error) {
         .          .    350:   c.lock.Lock()
         .          .    351:   defer c.lock.Unlock()
         .          .    352:
         .       30ms    353:   if err := c.syncContainer(); err != nil {
         .          .    354:           return -1, err
         .          .    355:   }
         .          .    356:
         .          .    357:   return c.state.PID, nil
         .          .    358:}

from podman.

baude avatar baude commented on May 18, 2024

We added a PR that groups all the container actions under one lock and observe a speed up. The rest is related to the output. Will keep this open until we decide how to deal with it.

from podman.

rhatdan avatar rhatdan commented on May 18, 2024

Any update on this?

from podman.

baude avatar baude commented on May 18, 2024

Specifically to this issue, I'm going to mark it as closed. @mheon and I have talked about redoing the output functions for podman and focus on performance ... as far as ps goes, it is nearly as fast as it can be.

from podman.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.