Skip to content

Commit

Permalink
gvfs:trace2: add region/data events for status deserialization
Browse files Browse the repository at this point in the history
Add trace2 region and data events describing attempts to deserialize
status data using a status cache.

A category:status, label:deserialize region is pushed around the
deserialize code.

Deserialization results when reading from a file are:
    category:status, path   = <path>
    category:status, polled = <number_of_attempts>
    category:status, result = "ok" | "reject"

When reading from STDIN are:
    category:status, path   = "STDIN"
    category:status, result = "ok" | "reject"

Status will fallback and run a normal status scan when a "reject"
is reported (unless "--deserialize-wait=fail").  If "ok" is reported,
status was able to use the status cache and avoid scanning the workdir.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
  • Loading branch information
jeffhostetler committed Oct 10, 2018
1 parent 8b6e8e9 commit e0f95f3
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions wt-status-deserialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,15 +725,18 @@ static int try_deserialize_read_from_file(const struct wt_status *cmd_s,
enum wt_status_deserialize_wait dw,
struct wt_status *des_s)
{
int k, limit;
int k = 0;
int limit;
int result = DESERIALIZE_ERR;

/*
* For "fail" or "no", try exactly once to read the status cache.
* Return an error if the file is stale.
*/
if (dw == DESERIALIZE_WAIT__FAIL || dw == DESERIALIZE_WAIT__NO)
return try_deserialize_read_from_file_1(cmd_s, path, des_s);
if (dw == DESERIALIZE_WAIT__FAIL || dw == DESERIALIZE_WAIT__NO) {
result = try_deserialize_read_from_file_1(cmd_s, path, des_s);
goto done;
}

/*
* Wait for the status cache file to refresh. Wait duration can
Expand All @@ -758,6 +761,12 @@ static int try_deserialize_read_from_file(const struct wt_status *cmd_s,
sleep_millisec(100);
}

done:
trace2_data_string("status", the_repository, "deserialize/path", path);
trace2_data_intmax("status", the_repository, "deserialize/polled", k);
trace2_data_string("status", the_repository, "deserialize/result",
((result == DESERIALIZE_OK) ? "ok" : "reject"));

trace_printf_key(&trace_deserialize,
"wait polled=%d result=%d '%s'",
k, result, path);
Expand All @@ -783,6 +792,8 @@ int wt_status_deserialize(const struct wt_status *cmd_s,
struct wt_status des_s;
int result;

trace2_region_enter("status", "deserialize", the_repository);

if (path && *path && strcmp(path, "0")) {
result = try_deserialize_read_from_file(cmd_s, path, dw, &des_s);
} else {
Expand All @@ -793,8 +804,14 @@ int wt_status_deserialize(const struct wt_status *cmd_s,
* term, since we cannot read stdin multiple times.
*/
result = wt_deserialize_fd(cmd_s, &des_s, 0);

trace2_data_string("status", the_repository, "deserialize/path", "STDIN");
trace2_data_string("status", the_repository, "deserialize/result",
((result == DESERIALIZE_OK) ? "ok" : "reject"));
}

trace2_region_leave("status", "deserialize", the_repository);

if (result == DESERIALIZE_OK)
wt_status_print(&des_s);

Expand Down

0 comments on commit e0f95f3

Please sign in to comment.