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

salt 2018.3.2 py3 on Ubuntu 18.04 takes a long time to run test.true #48773

Closed
kartiksubbarao opened this issue Jul 25, 2018 · 13 comments · Fixed by #57062
Closed

salt 2018.3.2 py3 on Ubuntu 18.04 takes a long time to run test.true #48773

kartiksubbarao opened this issue Jul 25, 2018 · 13 comments · Fixed by #57062
Labels
Bug broken, incorrect, or confusing behavior P3 Priority 3 severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around ZRelease-Sodium retired label
Milestone

Comments

@kartiksubbarao
Copy link
Contributor

I'm running salt 2018.3.2+ds-1 with python 3 on Ubuntu 18.04, and am finding that it takes over 5 seconds to run salt-call --local test.true. If I use --skip-grains, it cuts the time down to 1 second (which is still somewhat slower than expected). While searching around I came across #26255, but in my case the number of file descriptors isn't the issue -- setting ulimit -n 1024 doesn't fix it. Here's the output from both runs. The numerous Depends decorator instantiated... messages seem to chew up most of the time.

time salt-call --local test.true -l trace

[DEBUG   ] Reading configuration from /etc/salt/minion
[DEBUG   ] Changed git to gitfs in minion opts' fileserver_backend list
[DEBUG   ] Using cached minion ID from /etc/salt/minion_id: [...]
[TRACE   ] The required configuration section, 'fluent_handler', was not found the in the configuration. Not loading the fluent logging handlers module.
[TRACE   ] None of the required configuration sections, 'logstash_udp_handler' and 'logstash_zmq_handler', were found in the configuration. Not loading the Logstash logging handlers module.
[DEBUG   ] Configuration file path: /etc/salt/minion
[WARNING ] Insecure logging configuration detected! Sensitive data may be logged.
[DEBUG   ] Grains refresh requested. Refreshing grains.
[DEBUG   ] Reading configuration from /etc/salt/minion
[TRACE   ] 'drill' could not be found in the following search path: '['/usr/local/sbin', '/usr/local/bin', '/usr/sbin', '/usr/bin', '/sbin', '/bin', '/snap/bin']'
[TRACE   ] 'esxcli' could not be found in the following search path: '['/usr/local/sbin', '/usr/local/bin', '/usr/sbin', '/usr/bin', '/sbin', '/bin', '/snap/bin']'
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (True,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (True,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (True,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (True,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (True,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (True,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (True,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (True,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (True,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (True,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Depends decorator instantiated with dep list of (False,)
[TRACE   ] Error loading grains.napalm: "napalm"" (/usr/lib/python3/dist-packages/salt/grains/__pycache__/napalm.cpython-36.pyc) cannot be loaded: NAPALM is not installed or not running in a (proxy) minion
[TRACE   ] Loading core.append_domain grain
[TRACE   ] Loading core.default_gateway grain
[TRACE   ] Loading core.dns grain
[TRACE   ] Loading core.get_machine_id grain
[TRACE   ] Loading core.get_master grain
[TRACE   ] Loading core.get_server_id grain
[TRACE   ] Loading core.hostname grain
[TRACE   ] Loading core.hwaddr_interfaces grain
[TRACE   ] Loading core.id_ grain
[TRACE   ] Loading core.ip4_interfaces grain
[TRACE   ] Loading core.ip6_interfaces grain
[TRACE   ] Loading core.ip_fqdn grain
[TRACE   ] Loading core.ip_interfaces grain
[TRACE   ] Loading core.linux_distribution grain
[TRACE   ] Loading core.locale_info grain
[TRACE   ] Loading core.os_data grain
[TRACE   ] Loading core.path grain
[TRACE   ] Loading core.pythonexecutable grain
[TRACE   ] Loading core.pythonpath grain
[TRACE   ] Loading core.pythonversion grain
[TRACE   ] Loading core.saltpath grain
[TRACE   ] Loading core.saltversion grain
[TRACE   ] Loading core.saltversioninfo grain
[TRACE   ] Loading core.zmqversion grain
[TRACE   ] Loading disks.disks grain
[TRACE   ] Device loop1 reports itself as an HDD
[TRACE   ] Device loop6 reports itself as an HDD
[TRACE   ] Device loop4 reports itself as an HDD
[TRACE   ] Device sr0 reports itself as an HDD
[TRACE   ] Device loop2 reports itself as an HDD
[TRACE   ] Device loop0 reports itself as an HDD
[TRACE   ] Device loop7 reports itself as an HDD
[TRACE   ] Device vda reports itself as an HDD
[TRACE   ] Device loop5 reports itself as an HDD
[TRACE   ] Device loop3 reports itself as an HDD
[TRACE   ] Loading extra.config grain
[DEBUG   ] Loading static grains from /etc/salt/grains
[TRACE   ] Loading extra.shell grain
[TRACE   ] Loading mdadm.mdadm grain
[TRACE   ] Loading minion_process.grains grain
[TRACE   ] Loading opts.opts grain
[TRACE   ] Loading zfs.zfs grain
[TRACE   ] 'zfs-fuse' could not be found in the following search path: '['/usr/local/sbin', '/usr/local/bin', '/usr/sbin', '/usr/bin', '/sbin', '/bin', '/snap/bin']'
[TRACE   ] 'zpool' could not be found in the following search path: '['/usr/local/sbin', '/usr/local/bin', '/usr/sbin', '/usr/bin', '/sbin', '/bin', '/snap/bin']'
[DEBUG   ] Determining pillar cache
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[TRACE   ] Depends decorator instantiated with dep list of ('non_existantmodulename',)
[TRACE   ] Unloading test.missing_func because dependency (non_existantmodulename) is not imported
[DEBUG   ] LazyLoaded test.true
[DEBUG   ] LazyLoaded nested.output
[TRACE   ] data = {'local': True}
local:
    True
5.48user 0.19system 0:05.67elapsed 100%CPU (0avgtext+0avgdata 62488maxresident)k
0inputs+8outputs (0major+53578minor)pagefaults 0swaps

time salt-call --local --skip-grains test.true -l trace

[DEBUG   ] Reading configuration from /etc/salt/minion
[DEBUG   ] Changed git to gitfs in minion opts' fileserver_backend list
[DEBUG   ] Using cached minion ID from /etc/salt/minion_id: [...]
[TRACE   ] The required configuration section, 'fluent_handler', was not found the in the configuration. Not loading the fluent logging handlers module.
[TRACE   ] None of the required configuration sections, 'logstash_udp_handler' and 'logstash_zmq_handler', were found in the configuration. Not loading the Logstash logging handlers module.
[DEBUG   ] Configuration file path: /etc/salt/minion
[WARNING ] Insecure logging configuration detected! Sensitive data may be logged.
[DEBUG   ] Grains refresh requested. Refreshing grains.
[DEBUG   ] Determining pillar cache
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[TRACE   ] Depends decorator instantiated with dep list of ('non_existantmodulename',)
[TRACE   ] Unloading test.missing_func because dependency (non_existantmodulename) is not imported
[DEBUG   ] LazyLoaded test.true
[DEBUG   ] LazyLoaded nested.output
[TRACE   ] data = {'local': True}
local:
    True
1.06user 0.11system 0:01.18elapsed 99%CPU (0avgtext+0avgdata 58560maxresident)k
0inputs+24outputs (0major+28912minor)pagefaults 0swaps

Versions Report

Salt Version:
           Salt: 2018.3.2
 
Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.6.1
      docker-py: Not Installed
          gitdb: 2.0.3
      gitpython: 2.1.8
          ioflo: Not Installed
         Jinja2: 2.10
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 3.6.5 (default, Apr  1 2018, 05:46:30)
   python-gnupg: 0.4.1
         PyYAML: 3.12
          PyZMQ: 16.0.2
           RAET: Not Installed
          smmap: 2.0.3
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.2.5
 
System Versions:
           dist: Ubuntu 18.04 bionic
         locale: UTF-8
        machine: x86_64
        release: 4.15.0-23-generic
         system: Linux
        version: Ubuntu 18.04 bionic
@Ch3LL
Copy link
Contributor

Ch3LL commented Jul 26, 2018

i am not seeing >5 seconds when I attempt to replicate i'm seeing about 3 seconds, but still longer then we want.

I believe you are right I believe the culprit is the @depends decorator particularly in the vsphere.py file. If i remove that file my time goes back down to 0.94s

ping @saltstack/team-cloud is there a reason we are using this decorator instead of handling the dependencies in virtual?

@Ch3LL Ch3LL added Bug broken, incorrect, or confusing behavior severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around P3 Priority 3 labels Jul 26, 2018
@Ch3LL Ch3LL added this to the Approved milestone Jul 26, 2018
@gtmanfred
Copy link
Contributor

gtmanfred commented Jul 26, 2018

@Depends allows for using some functions inside of a module when others cant be used.

__virtual__ cannot specify which functions can be used even if the main library is not installed.

For example, lets say part of a module uses a commandline utility, and the other functions actually use the imported library. and then lets say that you can only pip install the python package on 2.7, 3.5 and 3.6, centos 7 uses python3.4, so you can never install for 3.4, so the stuff using the imported library cannot be used, but the stuff that can still use the command line utility can still be used if you just pip install it on 2.7.

That is why we use @Depends and @salt.utils.decorators.path.which.

Both of these are resolved at the load time though, so it should not affect already loaded modules, just the first time they are loaded for an instance. which is why it affects salt-call.

@angeloudy
Copy link
Contributor

We are also seeing this problem and its causing us some grief. Although

Depends decorator instantiated with dep list of (False,)

only adds 6-7 seconds to every state run, some of our orchestrations are taking 10 minutes to execute instead of 2 minutes because all that overhead adds up.

@gtmanfred I don't quite understand your point about python versions, but if our environment is tightly controlled to use only a single python version, is there any workaround to avoid the poor performance behaviour?

@angeloudy
Copy link
Contributor

After I configured disable_modules on the minion

disable_modules:
  - vsphere
  - esxi
  - esxcli

, it runs a little bit faster, but still quite slow. I can still see @Depends in the trace. It seems disable_modules does not prevent loading the module.

@gtmanfred
Copy link
Contributor

Sure, you may only use one python version, but we are supporting several.

@gtmanfred
Copy link
Contributor

How long does it take to run when you run the salt-minion and make the calls through the publish bus from the master using salt <minion> test.true?

@angeloudy
Copy link
Contributor

There's no difference if I run salt-call or salt <minion> on the master(probably a few ms ).
I have now made it much faster by adding grains_cache: True to the minion config.

@max-arnold
Copy link
Contributor

@kartiksubbarao Could you try undocumented disable_grains minion option?

disable_grains:
  - esxi

disable_modules:
  - vsphere

@kartiksubbarao
Copy link
Contributor Author

@max-arnold That definitely helps. I ran a comparison just now, it cuts down the runtime from 6 seconds to 1.7 seconds.

@stromnet
Copy link

stromnet commented Apr 7, 2019

FYI; I have had the same slowness issues on multiple FreeBSD 11.2 machines with salt 2019.2.0.

Adding disabled_grains & disabled_modules (both vsphare and esxi* as from examples above) gave great performance boost in running pretty simple states, with a total execution time from ~15-30s down to ~3s for 2 local hosts.

@stale
Copy link

stale bot commented Jan 8, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

@bobrik
Copy link
Contributor

bobrik commented May 3, 2020

I don't think this should've been closed. The issue still exists in the latest release.

@bobrik
Copy link
Contributor

bobrik commented May 3, 2020

I opened #57062 to fix this for good.

dwoz pushed a commit that referenced this issue May 9, 2020
Some very good background can be found on StackOverflow:

* https://stackoverflow.com/questions/17407119/python-inspect-stack-is-slow

I filed an issue about slow `inspect.stack()` in Python some time ago:

* https://bugs.python.org/issue39643

Slow `inspect.stack()` is a problem, but it's not the problem in this case.
The problem is that Salt asks Python to get a full blown stack with
all the frames, but then discards everything but the second frame
from the top. This is very wasteful, and it's much more economic
to ask for the current frame and walk back once.

Here's how long it takes to run `test.ping` with existing code:

```
$ time sudo salt-call --local test.ping
local:
    True

real	0m12.166s
user	0m11.679s
sys	0m0.499s
```

And this is how much better it gets with the proposed change:

```
$ time sudo salt-call --local test.ping
local:
    True

real	0m2.092s
user	0m1.772s
sys	0m0.336s
```

If you follow the advice from #48773 and disable `vmware` module,
which is responsible for the most calls into inspect module,
you won't get much better than that:

```
$ cat /etc/salt/minion
disable_grains:
- esxi
disable_modules:
- vsphere

$ time sudo salt-call --local test.ping
local:
    True

real	0m2.006s
user	0m1.671s
sys	0m0.353s
```

Closes #48773.
@sagetherage sagetherage added the ZRelease-Sodium retired label label May 18, 2020
@sagetherage sagetherage removed the stale label May 18, 2020
openqa-git-sync pushed a commit to os-autoinst/salt-states-openqa that referenced this issue Jun 18, 2024
saltstack/salt#48773 is meanwhile closed,
there was an additional feature added to salt [1] and we face problems
with our mine (which is mostly based on grains). So lets try to remove
this option and see if our mine behaves better after that.

[1] saltstack/salt#57062
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 P3 Priority 3 severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around ZRelease-Sodium retired label
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants