Skip to content

Commit 13a0b46

Browse files
hoxyqfacebook-github-bot
authored andcommitted
Use sampling profile serializer and emit profiles in traces (facebook#48315)
Summary: Pull Request resolved: facebook#48315 # Changelog: [Internal] > NOTE: Some CI jobs are expected to fail, because changes in Hermes D67353585 should be landed first, and then grafted to Static Hermes. Use newly added serializer and record Trace Events for profiles. Reviewed By: huntie Differential Revision: D67353586 fbshipit-source-id: f3738418ec1d47ef4435f00120823845ea5e2fe5
1 parent 87d4300 commit 13a0b46

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

packages/react-native/ReactCommon/jsinspector-modern/TracingAgent.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "TracingAgent.h"
99

1010
#include <jsinspector-modern/tracing/PerformanceTracer.h>
11+
#include <jsinspector-modern/tracing/RuntimeSamplingProfileTraceEventSerializer.h>
1112

1213
namespace facebook::react::jsinspector_modern {
1314

@@ -46,6 +47,7 @@ bool TracingAgent::handleRequest(const cdp::PreparsedRequest& req) {
4647
}
4748

4849
instanceAgent_->startTracing();
50+
instanceTracingStartTimestamp_ = std::chrono::steady_clock::now();
4951
frontendChannel_(cdp::jsonResult(req.id));
5052

5153
return true;
@@ -60,6 +62,10 @@ bool TracingAgent::handleRequest(const cdp::PreparsedRequest& req) {
6062
return true;
6163
}
6264
instanceAgent_->stopTracing();
65+
tracing::RuntimeSamplingProfileTraceEventSerializer::serializeAndBuffer(
66+
PerformanceTracer::getInstance(),
67+
instanceAgent_->collectTracingProfile().getRuntimeSamplingProfile(),
68+
instanceTracingStartTimestamp_);
6369

6470
bool correctlyStopped = PerformanceTracer::getInstance().stopTracing();
6571
if (!correctlyStopped) {

packages/react-native/ReactCommon/jsinspector-modern/TracingAgent.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ class TracingAgent {
5050
* currently no active instance.
5151
*/
5252
std::shared_ptr<InstanceAgent> instanceAgent_;
53+
54+
/**
55+
* Timestamp of when we started tracing of an Instance, will be used as a
56+
* a start of JavaScript samples recording.
57+
*/
58+
std::chrono::steady_clock::time_point instanceTracingStartTimestamp_;
5359
};
5460

5561
} // namespace facebook::react::jsinspector_modern

0 commit comments

Comments
 (0)