Backed out changeset 686ae9e71a9c (bug 1631402) for causing build bustage in MessageChannel.cpp

This commit is contained in:
Noemi Erli 2022-01-06 00:45:48 +02:00
Родитель d99ff74b6c
Коммит 0950d681d3
7 изменённых файлов: 66 добавлений и 4 удалений

Просмотреть файл

@ -86,7 +86,7 @@ struct Copier<T, size, true> {
} // anonymous namespace
PickleIterator::PickleIterator(const Pickle& pickle)
: iter_(pickle.buffers_.Iter()) {
: iter_(pickle.buffers_.Iter()), start_(mozilla::TimeStamp::Now()) {
iter_.Advance(pickle.buffers_, pickle.header_size_);
}
@ -458,6 +458,17 @@ bool Pickle::WriteSentinel(uint32_t sentinel) { return WriteUInt32(sentinel); }
void Pickle::EndRead(PickleIterator& iter, uint32_t ipcMsgType) const {
// FIXME: Deal with the footer somehow...
// DCHECK(iter.iter_.Done());
if (NS_IsMainThread() && ipcMsgType != 0) {
uint32_t latencyMs =
round((mozilla::TimeStamp::Now() - iter.start_).ToMilliseconds());
if (latencyMs >= kMinTelemetryIPCReadLatencyMs) {
mozilla::Telemetry::Accumulate(
mozilla::Telemetry::IPC_READ_MAIN_THREAD_LATENCY_MS,
nsDependentCString(IPC::StringFromIPCMessageType(ipcMsgType)),
latencyMs);
}
}
}
void Pickle::Truncate(PickleIterator* iter) {

Просмотреть файл

@ -32,6 +32,7 @@ class PickleIterator {
friend class Pickle;
mozilla::BufferList<InfallibleAllocPolicy>::IterImpl iter_;
mozilla::TimeStamp start_;
template <typename T>
void CopyInto(T* dest);

Просмотреть файл

@ -30,7 +30,7 @@ Message::Message()
}
Message::Message(int32_t routing_id, msgid_t type, uint32_t segment_capacity,
HeaderFlags flags)
HeaderFlags flags, bool recordWriteLatency)
: UserMessage(&kUserMessageTypeInfo),
Pickle(sizeof(Header), segment_capacity) {
MOZ_COUNT_CTOR(IPC::Message);
@ -46,6 +46,9 @@ Message::Message(int32_t routing_id, msgid_t type, uint32_t segment_capacity,
header()->num_send_rights = 0;
#endif
header()->event_footer_size = 0;
if (recordWriteLatency) {
create_time_ = mozilla::TimeStamp::Now();
}
}
Message::Message(const char* data, int data_len)
@ -69,7 +72,7 @@ Message::Message(Message&& other)
/*static*/ Message* Message::IPDLMessage(int32_t routing_id, msgid_t type,
HeaderFlags flags) {
return new Message(routing_id, type, 0, flags);
return new Message(routing_id, type, 0, flags, true);
}
/*static*/ Message* Message::ForSyncDispatchError(NestedLevel level) {

Просмотреть файл

@ -171,9 +171,12 @@ class Message : public mojo::core::ports::UserMessage, public Pickle {
// Initialize a message with a user-defined type, priority value, and
// destination WebView ID.
//
// NOTE: `recordWriteLatency` is only passed by IPDL generated message code,
// and is used to trigger the IPC_WRITE_LATENCY_MS telemetry.
Message(int32_t routing_id, msgid_t type,
uint32_t segmentCapacity = 0, // 0 for the default capacity.
HeaderFlags flags = HeaderFlags());
HeaderFlags flags = HeaderFlags(), bool recordWriteLatency = false);
Message(const char* data, int data_len);
@ -249,6 +252,8 @@ class Message : public mojo::core::ports::UserMessage, public Pickle {
const char* name() const { return StringFromIPCMessageType(type()); }
const mozilla::TimeStamp& create_time() const { return create_time_; }
uint32_t num_handles() const;
bool is_relay() const { return header()->flags.IsRelay(); }
@ -426,6 +431,8 @@ class Message : public mojo::core::ports::UserMessage, public Pickle {
// deserializing a message.
mutable nsTArray<mozilla::UniqueMachSendRight> attached_send_rights_;
#endif
mozilla::TimeStamp create_time_;
};
class MessageInfo {

Просмотреть файл

@ -853,6 +853,20 @@ bool MessageChannel::Send(UniquePtr<Message> aMsg) {
Telemetry::Accumulate(Telemetry::IPC_MESSAGE_SIZE2, aMsg->size());
}
// If the message was created by the IPC bindings, the create time will be
// recorded. Use this information to report the
// IPC_WRITE_MAIN_THREAD_LATENCY_MS (time from message creation to it being
// sent).
if (NS_IsMainThread() && aMsg->create_time()) {
uint32_t latencyMs = round(
(mozilla::TimeStamp::Now() - aMsg->create_time()).ToMilliseconds());
if (latencyMs >= kMinTelemetryIPCWriteLatencyMs) {
mozilla::Telemetry::Accumulate(
mozilla::Telemetry::IPC_WRITE_MAIN_THREAD_LATENCY_MS,
nsDependentCString(aMsg->name()), latencyMs);
}
}
MOZ_RELEASE_ASSERT(!aMsg->is_sync());
MOZ_RELEASE_ASSERT(aMsg->nested_level() != IPC::Message::NESTED_INSIDE_SYNC);

Просмотреть файл

@ -1943,6 +1943,8 @@ def _generateMessageConstructor(md, segmentSize, protocol, forReply=False):
ExprVar(msgid),
ExprLiteral.Int(int(segmentSize)),
flags,
# Pass `true` to recordWriteLatency to collect telemetry
ExprLiteral.TRUE,
],
)
)

Просмотреть файл

@ -15146,6 +15146,30 @@
"description": "Results of displaying add-on installation notifications.",
"releaseChannelCollection": "opt-out"
},
"IPC_READ_MAIN_THREAD_LATENCY_MS": {
"record_in_processes": ["main", "content", "gpu"],
"products": ["firefox", "fennec"],
"alert_emails": ["mlayzell@mozilla.com"],
"bug_numbers": [1342635],
"expires_in_version": "60",
"kind": "exponential",
"high": 500,
"n_buckets": 20,
"keyed": true,
"description": "Measures the number of milliseconds we spend waiting on the main thread for IPC messages to deserialize their parameters. Note: only messages that take more than 500 microseconds are included in this probe. This probe is keyed on the IPDL message name."
},
"IPC_WRITE_MAIN_THREAD_LATENCY_MS": {
"record_in_processes": ["main", "content", "gpu"],
"products": ["firefox", "fennec"],
"alert_emails": ["mlayzell@mozilla.com"],
"bug_numbers": [1342635],
"expires_in_version": "60",
"kind": "exponential",
"high": 500,
"n_buckets": 20,
"keyed": true,
"description": "Measures the number of milliseconds we spend waiting on the main thread for IPC messages to serialize their parameters. Note: only messages that take more than 500 microseconds are included in this probe. This probe is keyed on the IPDL message name."
},
"INPUT_EVENT_QUEUED_CLICK_MS": {
"record_in_processes": ["main", "content"],
"products": ["firefox", "fennec"],