@@ -11,6 +11,10 @@ static int initialized;
11
11
static volatile long enabled ;
12
12
static struct hashmap map ;
13
13
static CRITICAL_SECTION mutex ;
14
+ static unsigned int lstat_requests ;
15
+ static unsigned int opendir_requests ;
16
+ static unsigned int fscache_requests ;
17
+ static unsigned int fscache_misses ;
14
18
static struct trace_key trace_fscache = TRACE_KEY_INIT (FSCACHE );
15
19
16
20
/*
@@ -265,6 +269,8 @@ static void fscache_clear(void)
265
269
{
266
270
hashmap_clear_and_free (& map , struct fsentry , ent );
267
271
hashmap_init (& map , (hashmap_cmp_fn )fsentry_cmp , NULL , 0 );
272
+ lstat_requests = opendir_requests = 0 ;
273
+ fscache_misses = fscache_requests = 0 ;
268
274
}
269
275
270
276
/*
@@ -311,6 +317,7 @@ static struct fsentry *fscache_get(struct fsentry *key)
311
317
int dir_not_found ;
312
318
313
319
EnterCriticalSection (& mutex );
320
+ fscache_requests ++ ;
314
321
/* check if entry is in cache */
315
322
fse = fscache_get_wait (key );
316
323
if (fse ) {
@@ -374,6 +381,7 @@ static struct fsentry *fscache_get(struct fsentry *key)
374
381
}
375
382
376
383
/* add directory listing to the cache */
384
+ fscache_misses ++ ;
377
385
fscache_add (fse );
378
386
379
387
/* lookup file entry if requested (fse already points to directory) */
@@ -411,6 +419,8 @@ int fscache_enable(int enable)
411
419
return 0 ;
412
420
413
421
InitializeCriticalSection (& mutex );
422
+ lstat_requests = opendir_requests = 0 ;
423
+ fscache_misses = fscache_requests = 0 ;
414
424
hashmap_init (& map , (hashmap_cmp_fn ) fsentry_cmp , NULL , 0 );
415
425
initialized = 1 ;
416
426
}
@@ -427,6 +437,10 @@ int fscache_enable(int enable)
427
437
opendir = dirent_opendir ;
428
438
lstat = mingw_lstat ;
429
439
EnterCriticalSection (& mutex );
440
+ trace_printf_key (& trace_fscache , "fscache: lstat %u, opendir %u, "
441
+ "total requests/misses %u/%u\n" ,
442
+ lstat_requests , opendir_requests ,
443
+ fscache_requests , fscache_misses );
430
444
fscache_clear ();
431
445
LeaveCriticalSection (& mutex );
432
446
}
@@ -459,6 +473,7 @@ int fscache_lstat(const char *filename, struct stat *st)
459
473
if (!fscache_enabled (filename ))
460
474
return mingw_lstat (filename , st );
461
475
476
+ lstat_requests ++ ;
462
477
/* split filename into path + name */
463
478
len = strlen (filename );
464
479
if (len && is_dir_sep (filename [len - 1 ]))
@@ -540,6 +555,7 @@ DIR *fscache_opendir(const char *dirname)
540
555
if (!fscache_enabled (dirname ))
541
556
return dirent_opendir (dirname );
542
557
558
+ opendir_requests ++ ;
543
559
/* prepare name (strip trailing '/', replace '.') */
544
560
len = strlen (dirname );
545
561
if ((len == 1 && dirname [0 ] == '.' ) ||
0 commit comments