Last active
April 12, 2017 21:51
-
-
Save pcn/6d3928139a633c1f51d542a6643d1e6b to your computer and use it in GitHub Desktop.
Looking up jids takes a lot longer than you'd think in salt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import salt.config | |
import salt.runner | |
import salt.client | |
import time | |
import cProfile | |
o = salt.config.client_config("/etc/salt/master") | |
l = salt.client.LocalClient() | |
rc = salt.runner.RunnerClient(o) | |
start_time = time.time() | |
jids = list() | |
for count in range(10, 20): | |
jids.append(l.cmd_async('saltmaster', 'cmd.run', ['sleep {}; date'.format(count)])) | |
print "adding jobs took {}".format(time.time() - start_time) | |
start_time = time.time() | |
print "jids are: {}".format(jids) | |
# pr = cProfile.Profile() | |
# pr.enable() | |
import salt.minion | |
mm = salt.minion.MasterMinion(o) | |
o.get('ext_job_cache') | |
start_time = time.time() | |
jc = o.get('master_job_cache') | |
for jid in jids: | |
mm.returners['{}.get_jid'.format(jc)](jid) | |
print "Looking up {} jobs via returner, took {}".format(len(jids), time.time() - start_time) | |
for jid in jids: | |
rc.cmd('jobs.lookup_jid', [jid]) | |
#pr.disable() | |
print "Looking up {} jobs, took {}".format(len(jids), time.time() - start_time) | |
# pr.print_stats(sort='time') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment