Skip to content
Open
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
1 change: 1 addition & 0 deletions tsl/profiler/lib/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -435,5 +435,6 @@ cc_library(
"@com_google_absl//absl/time",
"@xla//xla/tsl/platform:env",
"@xla//xla/tsl/platform:errors",
"@xla//xla/tsl/platform:logging",
],
)
11 changes: 10 additions & 1 deletion tsl/profiler/lib/continuous_profiler_orchestrator.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ class ContinuousProfilerOrchestrator : public ProfilerInterface {
// Stops background thread and profiling.
absl::Status Stop() override {
StopIngestionThread();
auto result = profiler_->Consume();
if (result.ok()) {
absl::MutexLock lock(&mutex_);
circular_buffer_.push_back(std::move(result->data));
} else if (!absl::IsUnimplemented(result.status())) {
LOG(WARNING) << "Final Consume failed during Stop: " << result.status();
}
return profiler_->Stop();
}

Expand Down Expand Up @@ -102,7 +109,6 @@ class ContinuousProfilerOrchestrator : public ProfilerInterface {
ProfilerType* profiler() { return profiler_.get(); }
const ProfilerType* profiler() const { return profiler_.get(); }

private:
std::vector<std::any> PopBuffer() {
absl::MutexLock lock(mutex_);
std::vector<std::any> chunks;
Expand All @@ -113,7 +119,10 @@ class ContinuousProfilerOrchestrator : public ProfilerInterface {
circular_buffer_.clear();
return chunks;
}

private:
void IngestionLoop() {
LOG(INFO) << "ContinuousProfilerOrchestrator::IngestionLoop started";
while (true) {
absl::StatusOr<ConsumeResult> result = profiler_->Consume();

Expand Down
Loading