Skip to content

Commit

Permalink
Merge pull request #55420 from duckfez/gitfs_file_cache_perf_logging
Browse files Browse the repository at this point in the history
Added performance tracing/logging to gitfs file_list cache rebuild
  • Loading branch information
dwoz committed Dec 3, 2019
2 parents 8a5c5a4 + bf14def commit 8fb2548
Showing 1 changed file with 8 additions and 0 deletions.
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

0 comments on commit 8fb2548

Please sign in to comment.