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

pkg.install uses 100% CPU whenever there are no changes to the registry #30230

Closed
mpreziuso opened this issue Jan 8, 2016 · 3 comments
Closed
Labels
Bug broken, incorrect, or confusing behavior Execution-Module P2 Priority 2 Platform Relates to OS, containers, platform-based utilities like FS, system based apps severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around Windows
Milestone

Comments

@mpreziuso
Copy link
Contributor

pkg.install uses 100% CPU whenever there are no changes to the registry.
This is due to a for cycle that is in place in order to make sure there are no effective changes that still have to be applied to it.
This cycle made my Windows VM CPU spike, this is not very efficient and:

  • may cause performance issues to other applications or the OS
  • may cause unnecessary CPU credits consumption on AWS burstable instances
  • causes Salt to timeout and return no date unless a -t flag is set in the command
    The relevant code is here:
    # Get a new list of installed software
    new = list_pkgs()
    tries = 0
    difference = salt.utils.compare_dicts(old, new)
    while not all(name in difference for name in changed) and tries <= 1000:
        new = list_pkgs()
        difference = salt.utils.compare_dicts(old, new)
        tries += 1
        if tries == 1000:
            ret['_comment'] = 'Registry not updated.'

I suggest to use a sleep function, and iterate for 30 seconds (this is what 1000 iterations take on my VM) (which should be sufficient, doesn't cause any timeout issues, and doesn't cause any CPU spike):

import time
    # Get a new list of installed software
    new = list_pkgs()
    tries = 0
    difference = salt.utils.compare_dicts(old, new)
    while not all(name in difference for name in changed) and tries < 10:
        time.sleep( 3 )
        new = list_pkgs()
        difference = salt.utils.compare_dicts(old, new)
        tries += 1
        log.debug("Try {0}".format(tries))
        if tries == 10:
            ret['_comment'] = 'Registry not updated.'

Any thoughts on this?

@jfindlay jfindlay added Execution-Module Bug broken, incorrect, or confusing behavior severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around Windows P2 Priority 2 Platform Relates to OS, containers, platform-based utilities like FS, system based apps labels Jan 8, 2016
@jfindlay jfindlay added this to the Approved milestone Jan 8, 2016
@jfindlay
Copy link
Contributor

jfindlay commented Jan 8, 2016

@mpreziuso, your solution seems good to me. Will you open a pull request against the 2015.8 branch? Thanks.

@mpreziuso
Copy link
Contributor Author

@jfindlay Thanks, sure thing!

@mpreziuso
Copy link
Contributor Author

Hi @jfindlay, as this has been merged, I'm gonna close this.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior Execution-Module P2 Priority 2 Platform Relates to OS, containers, platform-based utilities like FS, system based apps severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around Windows
Projects
None yet
Development

No branches or pull requests

2 participants