Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c629071f authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I5efe6c6f,If7e1c4b3 into main

* changes:
  Add chunk size estimates to Protolog trace packets
  Add option to provide ProtoOutputStream chunk size in newTracePacket
parents b2b56af1 0dbc92a1
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -53,7 +53,22 @@ public class TracingContext<DataSourceInstanceType extends DataSourceInstance, T
     * @return A proto output stream to write a trace packet proto to
     */
    public ProtoOutputStream newTracePacket() {
        final ProtoOutputStream os = new ProtoOutputStream(0);
        return newTracePacket(0);
    }

    /**
     * Creates a new output stream to be used to write a trace packet to. The output stream will be
     * encoded to the proto binary representation when the callback trace function finishes and
     * send over to the native side to be included in the proto buffer.
     *
     * @param estimatedPacketSizeInBytes The estimated size of the trace packet. This will help
     *                                   avoid over allocating memory. We allocate an initial buffer
     *                                   of this size on trace packet creation.
     *                                   If set to 0 8kb is used.
     * @return A proto output stream to write a trace packet proto to
     */
    public ProtoOutputStream newTracePacket(int estimatedPacketSizeInBytes) {
        final ProtoOutputStream os = new ProtoOutputStream(estimatedPacketSizeInBytes);
        mTracePackets.add(os);
        return os;
    }
+6 −6
Original line number Diff line number Diff line
@@ -602,7 +602,7 @@ public abstract class PerfettoProtoLogImpl extends IProtoLogClient.Stub implemen
                        internProtoMessage(ctx, level, logGroup, message.mMessageString);
            }

            final ProtoOutputStream os = ctx.newTracePacket();
            final ProtoOutputStream os = ctx.newTracePacket(32);
            os.write(TIMESTAMP, tsNanos);
            long token = os.start(PROTOLOG_MESSAGE);

@@ -677,7 +677,7 @@ public abstract class PerfettoProtoLogImpl extends IProtoLogClient.Stub implemen
        final ProtoLogDataSource.IncrementalState incrementalState = ctx.getIncrementalState();

        if (!incrementalState.clearReported) {
            final ProtoOutputStream os = ctx.newTracePacket();
            final ProtoOutputStream os = ctx.newTracePacket(8);
            os.write(SEQUENCE_FLAGS, SEQ_INCREMENTAL_STATE_CLEARED);
            incrementalState.clearReported = true;
        }
@@ -686,7 +686,7 @@ public abstract class PerfettoProtoLogImpl extends IProtoLogClient.Stub implemen
        if (!incrementalState.protologGroupInterningSet.contains(logGroup.getId())) {
            incrementalState.protologGroupInterningSet.add(logGroup.getId());

            final ProtoOutputStream os = ctx.newTracePacket();
            final ProtoOutputStream os = ctx.newTracePacket(64);
            final long protologViewerConfigToken = os.start(PROTOLOG_VIEWER_CONFIG);
            final long groupConfigToken = os.start(GROUPS);

@@ -702,7 +702,7 @@ public abstract class PerfettoProtoLogImpl extends IProtoLogClient.Stub implemen
        if (!incrementalState.protologMessageInterningSet.contains(messageHash)) {
            incrementalState.protologMessageInterningSet.add(messageHash);

            final ProtoOutputStream os = ctx.newTracePacket();
            final ProtoOutputStream os = ctx.newTracePacket(128);

            // Dependent on the ProtoLog viewer config packet that contains the group information.
            os.write(SEQUENCE_FLAGS, SEQ_NEEDS_INCREMENTAL_STATE);
@@ -776,7 +776,7 @@ public abstract class PerfettoProtoLogImpl extends IProtoLogClient.Stub implemen
        final ProtoLogDataSource.IncrementalState incrementalState = ctx.getIncrementalState();

        if (!incrementalState.clearReported) {
            final ProtoOutputStream os = ctx.newTracePacket();
            final ProtoOutputStream os = ctx.newTracePacket(8);
            os.write(SEQUENCE_FLAGS, SEQ_INCREMENTAL_STATE_CLEARED);
            incrementalState.clearReported = true;
        }
@@ -785,7 +785,7 @@ public abstract class PerfettoProtoLogImpl extends IProtoLogClient.Stub implemen
            final int internedIndex = internMap.size() + 1;
            internMap.put(string, internedIndex);

            final ProtoOutputStream os = ctx.newTracePacket();
            final ProtoOutputStream os = ctx.newTracePacket(64);
            final long token = os.start(INTERNED_DATA);
            final long innerToken = os.start(fieldId);
            os.write(IID, internedIndex);