Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ ParsedTraceEvents ParseCompressedTraceEvents(
ProcessAsyncEvents(response, result);
ProcessCounterEvents(response, result);

if (response.has_full_timespan_start_ps() &&
response.has_full_timespan_end_ps()) {
const Milliseconds start_ms = response.full_timespan_start_ps() / 1e9;
const Milliseconds end_ms = response.full_timespan_end_ps() / 1e9;
if (start_ms <= end_ms) {
result.full_timespan = std::make_pair(start_ms, end_ms);
}
}

if (!visible_range_from_url.isNull() &&
!visible_range_from_url.isUndefined() &&
visible_range_from_url["length"].as<int>() == 2) {
Expand Down
3 changes: 3 additions & 0 deletions plugin/xprof/protobuf/trace_data_response.proto
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,7 @@ message TraceDataResponse {
repeated string interned_strings = 5;
// Details for the trace (e.g., flags for the frontend).
repeated DetailItem details = 6;
// The full timespan of the trace (start time and end time in picoseconds).
optional uint64 full_timespan_start_ps = 7;
optional uint64 full_timespan_end_ps = 8;
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ absl::Status DeltaSeriesProtoConverter::GenerateResponse(
d->set_value(detail.second);
}

if (trace_->has_min_timestamp_ps()) {
response->set_full_timespan_start_ps(trace_->min_timestamp_ps());
}
if (trace_->has_max_timestamp_ps()) {
response->set_full_timespan_end_ps(trace_->max_timestamp_ps());
}

using TidOrName = std::variant<uint64_t, absl::string_view>;

container.ForAllTracks([this, response](uint32_t pid, TidOrName tid_or_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace tensorflow {
namespace profiler {
namespace {

using ::testing::Eq;
using ::testing::EqualsProto;
using ::testing::proto::Partially;

Expand Down Expand Up @@ -416,6 +417,28 @@ TEST(DeltaSeriesProtoConverterTest, PopulatesDetails) {
)pb")));
}

TEST(DeltaSeriesProtoConverterTest, PopulatesFullTimespan) {
Trace trace;
trace.set_min_timestamp_ps(12345000);
trace.set_max_timestamp_ps(67890000);
TestTraceEventsContainer container(trace);

ASSERT_OK_AND_ASSIGN(std::string compressed_result,
ConvertTraceDataToCompressedDeltaSeriesProto(
DeltaSeriesProtoConversionOptions{}, container));

ASSERT_OK_AND_ASSIGN(std::string decompressed,
ZstdCompression::Decompress(compressed_result));

xprof::TraceDataResponse response;
ASSERT_TRUE(response.ParseFromString(decompressed));

EXPECT_TRUE(response.has_full_timespan_start_ps());
EXPECT_THAT(response.full_timespan_start_ps(), Eq(12345000));
EXPECT_TRUE(response.has_full_timespan_end_ps());
EXPECT_THAT(response.full_timespan_end_ps(), Eq(67890000));
}

} // namespace
} // namespace profiler
} // namespace tensorflow