@@ -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
/*
@@ -260,6 +264,8 @@ static void fscache_clear(void)
260
264
{
261
265
hashmap_clear_and_free (& map , struct fsentry , ent );
262
266
hashmap_init (& map , (hashmap_cmp_fn )fsentry_cmp , NULL , 0 );
267
+ lstat_requests = opendir_requests = 0 ;
268
+ fscache_misses = fscache_requests = 0 ;
263
269
}
264
270
265
271
/*
@@ -306,6 +312,7 @@ static struct fsentry *fscache_get(struct fsentry *key)
306
312
int dir_not_found ;
307
313
308
314
EnterCriticalSection (& mutex );
315
+ fscache_requests ++ ;
309
316
/* check if entry is in cache */
310
317
fse = fscache_get_wait (key );
311
318
if (fse ) {
@@ -369,6 +376,7 @@ static struct fsentry *fscache_get(struct fsentry *key)
369
376
}
370
377
371
378
/* add directory listing to the cache */
379
+ fscache_misses ++ ;
372
380
fscache_add (fse );
373
381
374
382
/* lookup file entry if requested (fse already points to directory) */
@@ -406,6 +414,8 @@ int fscache_enable(int enable)
406
414
return 0 ;
407
415
408
416
InitializeCriticalSection (& mutex );
417
+ lstat_requests = opendir_requests = 0 ;
418
+ fscache_misses = fscache_requests = 0 ;
409
419
hashmap_init (& map , (hashmap_cmp_fn ) fsentry_cmp , NULL , 0 );
410
420
initialized = 1 ;
411
421
}
@@ -422,6 +432,10 @@ int fscache_enable(int enable)
422
432
opendir = dirent_opendir ;
423
433
lstat = mingw_lstat ;
424
434
EnterCriticalSection (& mutex );
435
+ trace_printf_key (& trace_fscache , "fscache: lstat %u, opendir %u, "
436
+ "total requests/misses %u/%u\n" ,
437
+ lstat_requests , opendir_requests ,
438
+ fscache_requests , fscache_misses );
425
439
fscache_clear ();
426
440
LeaveCriticalSection (& mutex );
427
441
}
@@ -454,6 +468,7 @@ int fscache_lstat(const char *filename, struct stat *st)
454
468
if (!fscache_enabled (filename ))
455
469
return mingw_lstat (filename , st );
456
470
471
+ lstat_requests ++ ;
457
472
/* split filename into path + name */
458
473
len = strlen (filename );
459
474
if (len && is_dir_sep (filename [len - 1 ]))
@@ -533,6 +548,7 @@ DIR *fscache_opendir(const char *dirname)
533
548
if (!fscache_enabled (dirname ))
534
549
return dirent_opendir (dirname );
535
550
551
+ opendir_requests ++ ;
536
552
/* prepare name (strip trailing '/', replace '.') */
537
553
len = strlen (dirname );
538
554
if ((len == 1 && dirname [0 ] == '.' ) ||
0 commit comments