Skip to content

fix(ImageCache): Avoid bad IC stats when no files were read #3765

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

Merged
merged 1 commit into from
Feb 4, 2023
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
31 changes: 18 additions & 13 deletions src/libtexture/imagecache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1875,7 +1875,8 @@ ImageCacheImpl::getstats(int level) const
spin_lock lock(m_perthread_info_mutex);
size_t nthreads = m_all_perthread_info.size();
if (nthreads > 1 || level > 2) {
double perthreadtime = stats.fileio_time / (float)nthreads;
double perthreadtime = stats.fileio_time
/ std::max(size_t(1), nthreads);
print(out, " ({} average per thread, for {} threads)",
Strutil::timeintervalformat(perthreadtime), nthreads);
}
Expand All @@ -1895,14 +1896,16 @@ ImageCacheImpl::getstats(int level) const
m_stat_tiles_created, m_stat_tiles_current,
m_stat_tiles_peak);
print(out, " total tile requests : {}\n", stats.find_tile_calls);
print(out, " micro-cache misses : {} ({:.1f}%)\n",
stats.find_tile_microcache_misses,
100.0 * stats.find_tile_microcache_misses
/ (double)stats.find_tile_calls);
print(out, " main cache misses : {} ({:.1f}%)\n",
stats.find_tile_cache_misses,
100.0 * stats.find_tile_cache_misses
/ (double)stats.find_tile_calls);
if (stats.find_tile_microcache_misses)
print(out, " micro-cache misses : {} ({:.1f}%)\n",
stats.find_tile_microcache_misses,
100.0 * stats.find_tile_microcache_misses
/ (double)stats.find_tile_calls);
if (stats.find_tile_cache_misses)
print(out, " main cache misses : {} ({:.1f}%)\n",
stats.find_tile_cache_misses,
100.0 * stats.find_tile_cache_misses
/ (double)stats.find_tile_calls);
print(out, " redundant reads: {} tiles, {}\n",
total_redundant_tiles,
Strutil::memformat(total_redundant_bytes));
Expand Down Expand Up @@ -2011,11 +2014,13 @@ ImageCacheImpl::getstats(int level) const
nprinted, r, mb, file->iotime(),
onefile_stat_line(file, -1, false));
}
if (nprinted == 0)
if (nprinted == 0) {
print(out, " (nothing took more than 0.25s)\n");
double fast = files.back()->bytesread() / (1024.0 * 1024.0)
/ files.back()->iotime();
print(out, " (fastest was {:.1f} MB/s)\n", fast);
} else {
double fast = files.back()->bytesread() / (1024.0 * 1024.0)
/ files.back()->iotime();
print(out, " (fastest was {:.1f} MB/s)\n", fast);
}
if (total_redundant_tiles > 0) {
std::sort(files.begin(), files.end(), redundantbytes_compare);
print(out, " Top files by redundant I/O:\n");
Expand Down