Skip to content

Commit

Permalink
Bug 1575448 - De/serialize ProfilerMarkerPayload derived objects - r=…
Browse files Browse the repository at this point in the history
…gregtatum

Payloads will serialize themselves into a `BlocksRingBuffer` entry when first
captured.
Later they will be deserialized, to stream JSON for the output profile.

Differential Revision: https://phabricator.services.mozilla.com/D43428

--HG--
extra : moz-landing-system : lando
  • Loading branch information
squelart committed Sep 18, 2019
1 parent 0ffe75f commit fc93e3d
Show file tree
Hide file tree
Showing 11 changed files with 1,846 additions and 162 deletions.
31 changes: 30 additions & 1 deletion dom/media/mediasink/VideoSink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,45 @@ class VideoFrameMarkerPayload : public ProfilerMarkerPayload {
mAudioPositionUs(aAudioPositionUs),
mVideoFrameTimeUs(aVideoFrameTimeUs) {}

BlocksRingBuffer::Length TagAndSerializationBytes() const override {
return CommonPropsTagAndSerializationBytes() +
BlocksRingBuffer::SumBytes(mAudioPositionUs, mVideoFrameTimeUs);
}

void SerializeTagAndPayload(
BlocksRingBuffer::EntryWriter& aEntryWriter) const override {
static const DeserializerTag tag = TagForDeserializer(Deserialize);
SerializeTagAndCommonProps(tag, aEntryWriter);
aEntryWriter.WriteObject(mAudioPositionUs);
aEntryWriter.WriteObject(mVideoFrameTimeUs);
}

static UniquePtr<ProfilerMarkerPayload> Deserialize(
BlocksRingBuffer::EntryReader& aEntryReader) {
ProfilerMarkerPayload::CommonProps props =
DeserializeCommonProps(aEntryReader);
auto audioPositionUs = aEntryReader.ReadObject<int64_t>();
auto videoFrameTimeUs = aEntryReader.ReadObject<int64_t>();
return UniquePtr<ProfilerMarkerPayload>(new VideoFrameMarkerPayload(
std::move(props), audioPositionUs, videoFrameTimeUs));
}

void StreamPayload(SpliceableJSONWriter& aWriter,
const TimeStamp& aProcessStartTime,
UniqueStacks& aUniqueStacks) {
UniqueStacks& aUniqueStacks) const override {
StreamCommonProps("UpdateRenderVideoFrames", aWriter, aProcessStartTime,
aUniqueStacks);
aWriter.IntProperty("audio", mAudioPositionUs);
aWriter.IntProperty("video", mVideoFrameTimeUs);
}

private:
VideoFrameMarkerPayload(CommonProps&& aCommonProps, int64_t aAudioPositionUs,
int64_t aVideoFrameTimeUs)
: ProfilerMarkerPayload(std::move(aCommonProps)),
mAudioPositionUs(aAudioPositionUs),
mVideoFrameTimeUs(aVideoFrameTimeUs) {}

int64_t mAudioPositionUs;
int64_t mVideoFrameTimeUs;
};
Expand Down
26 changes: 23 additions & 3 deletions gfx/layers/ipc/CompositorBridgeParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2536,12 +2536,32 @@ int32_t RecordContentFrameTime(
ContentFramePayload(const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime)
: ProfilerMarkerPayload(aStartTime, aEndTime) {}
virtual void StreamPayload(SpliceableJSONWriter& aWriter,
const TimeStamp& aProcessStartTime,
UniqueStacks& aUniqueStacks) override {
mozilla::BlocksRingBuffer::Length TagAndSerializationBytes()
const override {
return CommonPropsTagAndSerializationBytes();
}
void SerializeTagAndPayload(
mozilla::BlocksRingBuffer::EntryWriter& aEntryWriter) const override {
static const DeserializerTag tag = TagForDeserializer(Deserialize);
SerializeTagAndCommonProps(tag, aEntryWriter);
}
void StreamPayload(SpliceableJSONWriter& aWriter,
const TimeStamp& aProcessStartTime,
UniqueStacks& aUniqueStacks) const override {
StreamCommonProps("CONTENT_FRAME_TIME", aWriter, aProcessStartTime,
aUniqueStacks);
}

private:
explicit ContentFramePayload(CommonProps&& aCommonProps)
: ProfilerMarkerPayload(std::move(aCommonProps)) {}
static mozilla::UniquePtr<ProfilerMarkerPayload> Deserialize(
mozilla::BlocksRingBuffer::EntryReader& aEntryReader) {
ProfilerMarkerPayload::CommonProps props =
DeserializeCommonProps(aEntryReader);
return UniquePtr<ProfilerMarkerPayload>(
new ContentFramePayload(std::move(props)));
}
};
AUTO_PROFILER_STATS(add_marker_with_ContentFramePayload);
profiler_add_marker_for_thread(
Expand Down
26 changes: 23 additions & 3 deletions gfx/layers/ipc/ContentCompositorBridgeParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,32 @@ void ContentCompositorBridgeParent::ShadowLayersUpdated(
ContentBuildPayload(const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime)
: ProfilerMarkerPayload(aStartTime, aEndTime) {}
virtual void StreamPayload(SpliceableJSONWriter& aWriter,
const TimeStamp& aProcessStartTime,
UniqueStacks& aUniqueStacks) override {
mozilla::BlocksRingBuffer::Length TagAndSerializationBytes()
const override {
return CommonPropsTagAndSerializationBytes();
}
void SerializeTagAndPayload(
mozilla::BlocksRingBuffer::EntryWriter& aEntryWriter) const override {
static const DeserializerTag tag = TagForDeserializer(Deserialize);
SerializeTagAndCommonProps(tag, aEntryWriter);
}
void StreamPayload(SpliceableJSONWriter& aWriter,
const TimeStamp& aProcessStartTime,
UniqueStacks& aUniqueStacks) const override {
StreamCommonProps("CONTENT_FULL_PAINT_TIME", aWriter, aProcessStartTime,
aUniqueStacks);
}

private:
explicit ContentBuildPayload(CommonProps&& aCommonProps)
: ProfilerMarkerPayload(std::move(aCommonProps)) {}
static mozilla::UniquePtr<ProfilerMarkerPayload> Deserialize(
mozilla::BlocksRingBuffer::EntryReader& aEntryReader) {
ProfilerMarkerPayload::CommonProps props =
DeserializeCommonProps(aEntryReader);
return UniquePtr<ProfilerMarkerPayload>(
new ContentBuildPayload(std::move(props)));
}
};
AUTO_PROFILER_STATS(add_marker_with_ContentBuildPayload);
profiler_add_marker_for_thread(
Expand Down
24 changes: 23 additions & 1 deletion gfx/layers/wr/WebRenderBridgeParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,34 @@ class SceneBuiltNotification : public wr::NotificationHandler {
ContentFullPaintPayload(const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime)
: ProfilerMarkerPayload(aStartTime, aEndTime) {}
mozilla::BlocksRingBuffer::Length TagAndSerializationBytes()
const override {
return CommonPropsTagAndSerializationBytes();
}
void SerializeTagAndPayload(
mozilla::BlocksRingBuffer::EntryWriter& aEntryWriter)
const override {
static const DeserializerTag tag =
TagForDeserializer(Deserialize);
SerializeTagAndCommonProps(tag, aEntryWriter);
}
void StreamPayload(SpliceableJSONWriter& aWriter,
const TimeStamp& aProcessStartTime,
UniqueStacks& aUniqueStacks) override {
UniqueStacks& aUniqueStacks) const override {
StreamCommonProps("CONTENT_FULL_PAINT_TIME", aWriter,
aProcessStartTime, aUniqueStacks);
}

private:
explicit ContentFullPaintPayload(CommonProps&& aCommonProps)
: ProfilerMarkerPayload(std::move(aCommonProps)) {}
static mozilla::UniquePtr<ProfilerMarkerPayload> Deserialize(
mozilla::BlocksRingBuffer::EntryReader& aEntryReader) {
ProfilerMarkerPayload::CommonProps props =
DeserializeCommonProps(aEntryReader);
return UniquePtr<ProfilerMarkerPayload>(
new ContentFullPaintPayload(std::move(props)));
}
};

AUTO_PROFILER_STATS(add_marker_with_ContentFullPaintPayload);
Expand Down
Loading

0 comments on commit fc93e3d

Please sign in to comment.