27 #include "precompiled.h"
34 #if FILE_STATS_ENABLED
37 static size_t vfs_files;
38 static double vfs_size_total;
39 static double vfs_init_elapsed_time;
42 static size_t unique_names;
43 static size_t unique_name_len_total;
44 static size_t open_files_cur, open_files_max;
47 static size_t extant_bufs_cur, extant_bufs_max, extant_bufs_total;
48 static double buf_size_total, buf_aligned_size_total;
51 static size_t user_ios;
52 static double user_io_size_total;
53 static double io_actual_size_total[
FI_MAX_IDX][2];
55 static double io_process_time_total;
56 static size_t io_seeks;
59 static size_t cache_count[2];
60 static double cache_size_total[2];
61 static size_t conflict_misses;
63 static size_t block_cache_count[2];
66 static size_t ab_connection_attempts;
67 static size_t ab_repeated_connections;
73 static double start_time;
74 static void timer_start(
double* start_time_storage = &start_time)
78 ENSURE(*start_time_storage == 0.0);
81 static double timer_reset(
double* start_time_storage = &start_time)
83 double elapsed =
timer_Time() - *start_time_storage;
84 *start_time_storage = 0.0;
97 vfs_size_total += file_size;
103 vfs_size_total -= file_size;
114 vfs_init_elapsed_time += timer_reset();
125 unique_name_len_total += name_len;
132 open_files_max = std::max(open_files_max, open_files_cur);
139 ENSURE(open_files_cur > 0);
151 extant_bufs_max = std::max(extant_bufs_max, extant_bufs_cur);
154 buf_size_total += size;
155 buf_aligned_size_total += alignedSize;
160 ENSURE(extant_bufs_cur > 0);
177 user_io_size_total += user_size;
183 timer_start(&m_startTime);
189 timer_reset(&m_startTime);
197 io_actual_size_total[fi][opcode ==
LIO_WRITE] += size;
198 io_elapsed_time[fi][opcode ==
LIO_WRITE] += timer_reset(&m_startTime);
209 io_process_time_total += timer_reset();
224 PairIB ret = ever_cached_files.insert(atom_fn);
227 conflict_miss_size_total += size;
234 cache_size_total[cr] += size;
240 block_cache_count[cr]++;
250 ab_connection_attempts++;
252 ab_repeated_connections++;
258 template<
typename T>
int percent(
T num,
T divisor)
262 return (
int)(100*num / divisor);
270 const double KB = 1e3;
const double MB = 1e6;
const double ms = 1e-3;
272 debug_printf(L
"--------------------------------------------------------------------------------\n");
280 L
"Total files: %lu (%g MB)\n"
281 L
"Init/mount time: %g ms\n",
282 (
unsigned long)vfs_files, vfs_size_total/MB,
283 vfs_init_elapsed_time/ms
288 L
"Total names: %lu (%lu KB)\n"
289 L
"Max. concurrent: %lu; leaked: %lu.\n",
290 (
unsigned long)unique_names, (
unsigned long)(unique_name_len_total/1000),
291 (
unsigned long)open_files_max, (
unsigned long)open_files_cur
296 L
"Total buffers used: %lu (%g MB)\n"
297 L
"Max concurrent: %lu; leaked: %lu\n"
298 L
"Internal fragmentation: %d%%\n",
299 (
unsigned long)extant_bufs_total, buf_size_total/MB,
300 (
unsigned long)extant_bufs_max, (
unsigned long)extant_bufs_cur,
301 percent(buf_aligned_size_total-buf_size_total, buf_size_total)
306 L
"Total user load requests: %lu (%g MB)\n"
307 L
"IO thoughput [MB/s; 0=never happened]:\n"
308 L
" lowio: R=%.3g, W=%.3g\n"
309 L
" aio: R=%.3g, W=%.3g\n"
310 L
"Average size = %g KB; seeks: %lu; total callback time: %g ms\n"
311 L
"Total data actually read from disk = %g MB\n",
312 (
unsigned long)user_ios, user_io_size_total/MB,
313 #define THROUGHPUT(impl, opcode) (io_elapsed_time[impl][opcode ==
LIO_WRITE] == 0.0)? 0.0 : (io_actual_size_total[impl][opcode ==
LIO_WRITE] / io_elapsed_time[impl][opcode ==
LIO_WRITE] / MB)
316 user_io_size_total/user_ios/KB, (
unsigned long)io_seeks, io_process_time_total/ms,
317 (io_actual_size_total[
FI_LOWIO][0]+io_actual_size_total[
FI_AIO][0])/MB
322 L
"Hits: %lu (%g MB); misses %lu (%g MB); ratio: %u%%\n"
323 L
"Percent of requested bytes satisfied by cache: %u%%; non-compulsory misses: %lu (%u%% of misses)\n"
324 L
"Block hits: %lu; misses: %lu; ratio: %u%%\n",
325 (
unsigned long)cache_count[
CR_HIT], cache_size_total[CR_HIT]/MB, (
unsigned long)cache_count[
CR_MISS], cache_size_total[CR_MISS]/MB, percent(cache_count[CR_HIT], cache_count[CR_HIT]+cache_count[CR_MISS]),
326 percent(cache_size_total[CR_HIT], cache_size_total[CR_HIT]+cache_size_total[CR_MISS]), (
unsigned long)conflict_misses, percent(conflict_misses, cache_count[CR_MISS]),
327 (
unsigned long)block_cache_count[CR_HIT], (
unsigned long)block_cache_count[CR_MISS], percent(block_cache_count[CR_HIT], block_cache_count[CR_HIT]+block_cache_count[CR_MISS])
331 L
"\nvfs_optimizer:\n"
332 L
"Total trace entries: %lu; repeated connections: %lu; unique files: %lu\n",
333 (
unsigned long)ab_connection_attempts, (
unsigned long)ab_repeated_connections, (
unsigned long)(ab_connection_attempts-ab_repeated_connections)
337 #endif // FILE_STATS_ENABLED
#define stats_unique_name(name_len)
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
bool debug_filter_allows(const wchar_t *text)
indicate if the given text would be printed.
#define file_stats_dump()
void NotifyOfSuccess(FileIOImplentation fi, int opcode, off_t size)
#define stats_cb_finish()
#define T(string_literal)
#define stats_io_user_request(user_size)
#define stats_vfs_file_remove(file_size)
#define stats_block_cache(cr)
#define stats_cache(cr, size)
#define stats_buf_alloc(size, alignedSize)
#define stats_vfs_file_add(file_size)
#define stats_vfs_init_finish()
#define stats_vfs_init_start()
void debug_printf(const wchar_t *fmt,...)
write a formatted string to the debug channel, subject to filtering (see below).
#define stats_ab_connection(already_exists)