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

Commit 454c5524 authored by Alec Mouri's avatar Alec Mouri Committed by Android (Google) Code Review
Browse files

Revert "Add some tracing for release fences"

This reverts commit 3118f969.

Reason for revert: b/368514217

Change-Id: Id69a0bd8850d2b6c093f7ce78817cdf5705215b1
parent 3118f969
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@
#include <sys/epoll.h>
#include <sys/eventfd.h>

#include <gui/FenceMonitor.h>
#include <gui/FrameRateUtils.h>
#include <gui/GLConsumer.h>
#include <gui/IProducerListener.h>
@@ -476,16 +475,6 @@ void BLASTBufferQueue::releaseBufferCallbackLocked(
    ATRACE_CALL();
    BQA_LOGV("releaseBufferCallback %s", id.to_string().c_str());

    if (CC_UNLIKELY(atrace_is_tag_enabled(ATRACE_TAG_GRAPHICS))) {
        if (!mFenceMonitor) {
            std::string monitorName = "release :";
            monitorName.append(mName.c_str());
            mFenceMonitor.emplace(monitorName.c_str());
        }

        mFenceMonitor->queueFence(releaseFence);
    }

    // Calculate how many buffers we need to hold before we release them back
    // to the buffer queue. This will prevent higher latency when we are running
    // on a lower refresh rate than the max supported. We only do that for EGL
+11 −25
Original line number Diff line number Diff line
@@ -25,18 +25,9 @@
namespace android::gui {

FenceMonitor::FenceMonitor(const char* name) : mName(name), mFencesQueued(0), mFencesSignaled(0) {
    mThread = std::thread(&FenceMonitor::loop, this);
}

FenceMonitor::~FenceMonitor() {
    {
        std::lock_guard<std::mutex> lock(mMutex);
        mStopped = true;
        mCondition.notify_one();
    }
    if (mThread.joinable()) {
        mThread.join();
    }
    std::thread thread(&FenceMonitor::loop, this);
    pthread_setname_np(thread.native_handle(), mName);
    thread.detach();
}

void FenceMonitor::queueFence(const sp<Fence>& fence) {
@@ -44,26 +35,24 @@ void FenceMonitor::queueFence(const sp<Fence>& fence) {

    std::lock_guard<std::mutex> lock(mMutex);
    if (fence->getSignalTime() != Fence::SIGNAL_TIME_PENDING) {
        snprintf(message, sizeof(message), "%s fence %u has signaled", mName.c_str(),
                 mFencesQueued);
        snprintf(message, sizeof(message), "%s fence %u has signaled", mName, mFencesQueued);
        ATRACE_NAME(message);
        // Need an increment on both to make the trace number correct.
        mFencesQueued++;
        mFencesSignaled++;
        return;
    }
    snprintf(message, sizeof(message), "Trace %s fence %u", mName.c_str(), mFencesQueued);
    snprintf(message, sizeof(message), "Trace %s fence %u", mName, mFencesQueued);
    ATRACE_NAME(message);

    mQueue.push_back(fence);
    mCondition.notify_one();
    mFencesQueued++;
    ATRACE_INT(mName.c_str(), int32_t(mQueue.size()));
    ATRACE_INT(mName, int32_t(mQueue.size()));
}

void FenceMonitor::loop() {
    pthread_setname_np(pthread_self(), mName.c_str());
    while (!mStopped) {
    while (true) {
        threadLoop();
    }
}
@@ -73,18 +62,15 @@ void FenceMonitor::threadLoop() {
    uint32_t fenceNum;
    {
        std::unique_lock<std::mutex> lock(mMutex);
        while (mQueue.empty() && !mStopped) {
        while (mQueue.empty()) {
            mCondition.wait(lock);
        }
        if (mStopped) {
            return;
        }
        fence = mQueue[0];
        fenceNum = mFencesSignaled;
    }
    {
        char message[64];
        snprintf(message, sizeof(message), "waiting for %s %u", mName.c_str(), fenceNum);
        snprintf(message, sizeof(message), "waiting for %s %u", mName, fenceNum);
        ATRACE_NAME(message);

        status_t result = fence->waitForever(message);
@@ -96,7 +82,7 @@ void FenceMonitor::threadLoop() {
        std::lock_guard<std::mutex> lock(mMutex);
        mQueue.pop_front();
        mFencesSignaled++;
        ATRACE_INT(mName.c_str(), int32_t(mQueue.size()));
        ATRACE_INT(mName, int32_t(mQueue.size()));
    }
}

+0 −3
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@
#include <com_android_graphics_libgui_flags.h>
#include <gui/BufferItem.h>
#include <gui/BufferItemConsumer.h>
#include <gui/FenceMonitor.h>
#include <gui/IGraphicBufferConsumer.h>
#include <gui/IGraphicBufferProducer.h>
#include <gui/SurfaceComposerClient.h>
@@ -317,8 +316,6 @@ private:

    std::unordered_set<uint64_t> mSyncedFrameNumbers GUARDED_BY(mMutex);

    std::optional<gui::FenceMonitor> mFenceMonitor GUARDED_BY(mMutex);

#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BUFFER_RELEASE_CHANNEL)
    class BufferReleaseReader {
    public:
+2 −6
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@
#include <cstdint>
#include <deque>
#include <mutex>
#include <thread>

#include <ui/Fence.h>

@@ -29,20 +28,17 @@ class FenceMonitor {
public:
    explicit FenceMonitor(const char* name);
    void queueFence(const sp<Fence>& fence);
    ~FenceMonitor();

private:
    void loop();
    void threadLoop();

    std::string mName;
    const char* mName;
    uint32_t mFencesQueued;
    uint32_t mFencesSignaled;
    std::deque<sp<Fence>> mQueue;
    std::condition_variable mCondition;
    std::mutex mMutex;
    std::thread mThread;
    std::atomic_bool mStopped = false;
};

} // namespace android::gui
 No newline at end of file
+0 −4
Original line number Diff line number Diff line
@@ -769,10 +769,6 @@ void Layer::prepareReleaseCallbacks(ftl::Future<FenceResult> futureFenceResult,
        // Older fences for the same layer stack can be dropped when a new fence arrives.
        // An assumption here is that RenderEngine performs work sequentially, so an
        // incoming fence will not fire before an existing fence.
        SFTRACE_NAME(
                ftl::Concat("Adding additional fence for: ", ftl::truncated<20>(mName.c_str()),
                            ", Replacing?: ", mAdditionalPreviousReleaseFences.contains(layerStack))
                        .c_str());
        mAdditionalPreviousReleaseFences.emplace_or_replace(layerStack,
                                                            std::move(futureFenceResult));
    }
Loading