Skip to content

Commit

Permalink
gvfs:trace2:data: add vfs stats
Browse files Browse the repository at this point in the history
Report virtual filesystem summary data.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
  • Loading branch information
jeffhostetler authored and vdye committed Jul 19, 2023
1 parent b25228c commit ca92198
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions virtualfilesystem.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "git-compat-util.h"
#include "environment.h"
#include "gettext.h"
#include "repository.h"
#include "trace2.h"
#include "cache.h"
#include "config.h"
#include "dir.h"
Expand Down Expand Up @@ -257,6 +259,11 @@ void apply_virtualfilesystem(struct index_state *istate)
{
char *buf, *entry;
int i;
int nr_unknown = 0;
int nr_vfs_dirs = 0;
int nr_vfs_rows = 0;
int nr_bulk_skip = 0;
int nr_explicit_skip = 0;

if (!git_config_get_virtualfilesystem())
return;
Expand All @@ -274,35 +281,63 @@ void apply_virtualfilesystem(struct index_state *istate)
if (buf[i] == '\0') {
int pos, len;

nr_vfs_rows++;

len = buf + i - entry;

/* look for a directory wild card (ie "dir1/") */
if (buf[i - 1] == '/') {
nr_vfs_dirs++;
if (ignore_case)
adjust_dirname_case(istate, entry);
pos = index_name_pos(istate, entry, len);
if (pos < 0) {
pos = -pos - 1;
while (pos < istate->cache_nr && !fspathncmp(istate->cache[pos]->name, entry, len)) {
if (istate->cache[pos]->ce_flags & CE_SKIP_WORKTREE)
nr_bulk_skip++;
istate->cache[pos]->ce_flags &= ~CE_SKIP_WORKTREE;
pos++;
}
}
} else {
if (ignore_case) {
struct cache_entry *ce = index_file_exists(istate, entry, len, ignore_case);
if (ce)
if (ce) {
if (ce->ce_flags & CE_SKIP_WORKTREE)
nr_explicit_skip++;
ce->ce_flags &= ~CE_SKIP_WORKTREE;
}
else {
nr_unknown++;
}
} else {
int pos = index_name_pos(istate, entry, len);
if (pos >= 0)
if (pos >= 0) {
if (istate->cache[pos]->ce_flags & CE_SKIP_WORKTREE)
nr_explicit_skip++;
istate->cache[pos]->ce_flags &= ~CE_SKIP_WORKTREE;
}
else {
nr_unknown++;
}
}
}

entry += len + 1;
}
}

if (nr_vfs_rows > 0) {
trace2_data_intmax("vfs", the_repository, "apply/tracked", nr_bulk_skip + nr_explicit_skip);

trace2_data_intmax("vfs", the_repository, "apply/vfs_rows", nr_vfs_rows);
trace2_data_intmax("vfs", the_repository, "apply/vfs_dirs", nr_vfs_dirs);

trace2_data_intmax("vfs", the_repository, "apply/nr_unknown", nr_unknown);
trace2_data_intmax("vfs", the_repository, "apply/nr_bulk_skip", nr_bulk_skip);
trace2_data_intmax("vfs", the_repository, "apply/nr_explicit_skip", nr_explicit_skip);
}
}

/*
Expand Down

0 comments on commit ca92198

Please sign in to comment.