This repository was archived by the owner on Jan 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vm_tools: Add temporary logging to track startup time in tast.
Sommelier is one of the startup tasks that is often slow in tast tests resulting in timeouts. Adding logs so that we can see the timestamps at which certain steps happen. BUG=b:303549040 TEST=none Change-Id: I93da1e1af8438e30a148943b08fdec7907685257 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/4951557 Reviewed-by: Chloe Pelling <[email protected]> Tested-by: Lucy Qu <[email protected]> Commit-Queue: Lucy Qu <[email protected]>
- Loading branch information
Lucy Qu
authored and
Chromeos LUCI
committed
Oct 20, 2023
1 parent
2a9193c
commit a502ad7
Showing
5 changed files
with
147 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2023 The ChromiumOS Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "sommelier-scope-timer.h" // NOLINT(build/include_directory) | ||
|
||
#include <fstream> | ||
#include <iomanip> | ||
#include <iostream> | ||
#include <sstream> | ||
#include <string> | ||
|
||
#define NSEC_PER_SEC 1000000000 | ||
|
||
static inline int64_t timespec_to_ns(timespec* t) { | ||
return (int64_t)t->tv_sec * NSEC_PER_SEC + t->tv_nsec; | ||
} | ||
|
||
ScopeTimer::ScopeTimer(const char* event_name) : event_name_(event_name) { | ||
clock_gettime(CLOCK_MONOTONIC, &start_time_); | ||
} | ||
|
||
ScopeTimer::~ScopeTimer() { | ||
timespec end_time; | ||
clock_gettime(CLOCK_MONOTONIC, &end_time); | ||
int64_t end = timespec_to_ns(&end_time); | ||
int64_t start = timespec_to_ns(&start_time_); | ||
int64_t diff = end - start; | ||
fprintf(stderr, "sommelier_scope_timer: %s: %f seconds\n", event_name_, | ||
static_cast<float>(diff) / static_cast<float>(NSEC_PER_SEC)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2023 The ChromiumOS Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef VM_TOOLS_SOMMELIER_SOMMELIER_SCOPE_TIMER_H_ | ||
#define VM_TOOLS_SOMMELIER_SOMMELIER_SCOPE_TIMER_H_ | ||
|
||
#include <time.h> | ||
#include <string> | ||
|
||
// This is to time certain tasks sommelier performs at startup, see b/303549040 | ||
class ScopeTimer { | ||
public: | ||
explicit ScopeTimer(const char* event_name); | ||
~ScopeTimer(); | ||
|
||
private: | ||
const char* event_name_; | ||
timespec start_time_; | ||
}; // class ScopeTimer | ||
#endif // VM_TOOLS_SOMMELIER_SOMMELIER_SCOPE_TIMER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters