Skip to content

Commit f1c4fd3

Browse files
camillobruniV8 LUCI CQ
authored andcommitted
[profiling] Create process-unique CPU profile ids
In https://crrev.com/c/3522896 we changed the last_id_ to be a member variable. This subtly changed how profile id's were generated. This CL changes this part back to a static variable that guarantees process-wide unique profile ids. Bug: chromium:1330726, chromium:1297283 Change-Id: I5f3dddcbbc156d0dee7d1eedde8a731c53d080dc Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3684289 Auto-Submit: Camillo Bruni <[email protected]> Commit-Queue: Camillo Bruni <[email protected]> Reviewed-by: Shu-yu Guo <[email protected]> Cr-Commit-Position: refs/heads/main@{#80902}
1 parent c553b02 commit f1c4fd3

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

src/profiler/profile-generator.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,8 @@ void ContextFilter::OnMoveEvent(Address from_address, Address to_address) {
570570

571571
using v8::tracing::TracedValue;
572572

573+
std::atomic<ProfilerId> CpuProfilesCollection::last_id_{0};
574+
573575
CpuProfile::CpuProfile(CpuProfiler* profiler, ProfilerId id, const char* title,
574576
CpuProfilingOptions options,
575577
std::unique_ptr<DiscardedSamplesDelegate> delegate)
@@ -892,10 +894,7 @@ size_t CodeMap::GetEstimatedMemoryUsage() const {
892894
}
893895

894896
CpuProfilesCollection::CpuProfilesCollection(Isolate* isolate)
895-
: profiler_(nullptr),
896-
current_profiles_semaphore_(1),
897-
last_id_(0),
898-
isolate_(isolate) {
897+
: profiler_(nullptr), current_profiles_semaphore_(1), isolate_(isolate) {
899898
USE(isolate_);
900899
}
901900

src/profiler/profile-generator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ class V8_EXPORT_PRIVATE CpuProfilesCollection {
587587
// Accessed by VM thread and profile generator thread.
588588
std::vector<std::unique_ptr<CpuProfile>> current_profiles_;
589589
base::Semaphore current_profiles_semaphore_;
590-
ProfilerId last_id_;
590+
static std::atomic<ProfilerId> last_id_;
591591
Isolate* isolate_;
592592
};
593593

0 commit comments

Comments
 (0)