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

Added performance tracing/logging to gitfs file_list cache rebuild #55420

Merged
merged 3 commits into from
Dec 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions salt/utils/gitfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2943,14 +2943,21 @@ def _file_lists(self, load, form):
if cache_match is not None:
return cache_match
if refresh_cache:
log.trace('Start rebuilding gitfs file_list cache')
ret = {'files': set(), 'symlinks': {}, 'dirs': set()}
if salt.utils.stringutils.is_hex(load['saltenv']) \
or load['saltenv'] in self.envs():
for repo in self.remotes:
start = time.time()
repo_files, repo_symlinks = repo.file_list(load['saltenv'])
ret['files'].update(repo_files)
ret['symlinks'].update(repo_symlinks)
ret['dirs'].update(repo.dir_list(load['saltenv']))
log.profile(
'gitfs file_name cache rebuild repo=%s duration=%s seconds',
repo.id,
time.time() - start
)
ret['files'] = sorted(ret['files'])
ret['dirs'] = sorted(ret['dirs'])

Expand All @@ -2961,6 +2968,7 @@ def _file_lists(self, load, form):
# NOTE: symlinks are organized in a dict instead of a list, however
# the 'symlinks' key will be defined above so it will never get to
# the default value in the call to ret.get() below.
log.trace('Finished rebuilding gitfs file_list cache')
return ret.get(form, [])
# Shouldn't get here, but if we do, this prevents a TypeError
return {} if form == 'symlinks' else []
Expand Down