@@ -8,6 +8,10 @@ static int initialized;
8
8
static volatile long enabled ;
9
9
static struct hashmap map ;
10
10
static CRITICAL_SECTION mutex ;
11
+ static unsigned int lstat_requests ;
12
+ static unsigned int opendir_requests ;
13
+ static unsigned int fscache_requests ;
14
+ static unsigned int fscache_misses ;
11
15
static struct trace_key trace_fscache = TRACE_KEY_INIT (FSCACHE );
12
16
13
17
/*
@@ -247,6 +251,8 @@ static void fscache_clear(void)
247
251
{
248
252
hashmap_free (& map , 1 );
249
253
hashmap_init (& map , (hashmap_cmp_fn )fsentry_cmp , NULL , 0 );
254
+ lstat_requests = opendir_requests = 0 ;
255
+ fscache_misses = fscache_requests = 0 ;
250
256
}
251
257
252
258
/*
@@ -293,6 +299,7 @@ static struct fsentry *fscache_get(struct fsentry *key)
293
299
int dir_not_found ;
294
300
295
301
EnterCriticalSection (& mutex );
302
+ fscache_requests ++ ;
296
303
/* check if entry is in cache */
297
304
fse = fscache_get_wait (key );
298
305
if (fse ) {
@@ -355,6 +362,7 @@ static struct fsentry *fscache_get(struct fsentry *key)
355
362
}
356
363
357
364
/* add directory listing to the cache */
365
+ fscache_misses ++ ;
358
366
fscache_add (fse );
359
367
360
368
/* lookup file entry if requested (fse already points to directory) */
@@ -392,6 +400,8 @@ int fscache_enable(int enable)
392
400
return 0 ;
393
401
394
402
InitializeCriticalSection (& mutex );
403
+ lstat_requests = opendir_requests = 0 ;
404
+ fscache_misses = fscache_requests = 0 ;
395
405
hashmap_init (& map , (hashmap_cmp_fn ) fsentry_cmp , NULL , 0 );
396
406
initialized = 1 ;
397
407
}
@@ -408,6 +418,10 @@ int fscache_enable(int enable)
408
418
opendir = dirent_opendir ;
409
419
lstat = mingw_lstat ;
410
420
EnterCriticalSection (& mutex );
421
+ trace_printf_key (& trace_fscache , "fscache: lstat %u, opendir %u, "
422
+ "total requests/misses %u/%u\n" ,
423
+ lstat_requests , opendir_requests ,
424
+ fscache_requests , fscache_misses );
411
425
fscache_clear ();
412
426
LeaveCriticalSection (& mutex );
413
427
}
@@ -439,6 +453,7 @@ int fscache_lstat(const char *filename, struct stat *st)
439
453
if (!fscache_enabled (filename ))
440
454
return mingw_lstat (filename , st );
441
455
456
+ lstat_requests ++ ;
442
457
/* split filename into path + name */
443
458
len = strlen (filename );
444
459
if (len && is_dir_sep (filename [len - 1 ]))
@@ -518,6 +533,7 @@ DIR *fscache_opendir(const char *dirname)
518
533
if (!fscache_enabled (dirname ))
519
534
return dirent_opendir (dirname );
520
535
536
+ opendir_requests ++ ;
521
537
/* prepare name (strip trailing '/', replace '.') */
522
538
len = strlen (dirname );
523
539
if ((len == 1 && dirname [0 ] == '.' ) ||
0 commit comments