第26讲 dequeuebuffer latency -凯发k8旗舰厅

本讲是android camera性能分析专题的第26讲,我们介绍dequeuebuffer latency,包括如下内容:

  1. dequeuebuffer latency是什么
  2. dequeuebuffer latency配置
  3. dequeeubuffer latency实战
资源 描述
在线课程
知识星球 星球名称:深入浅出android camera
星球id: 17296815
wechat 极客笔记圈

dequeuebuffer latency是什么

dequeuebuffer latency 用于衡量/记录从bufferqueue里面获取buffer的耗时。

影响:

  • 如果该耗时太长,会拉低capturerequest的帧率,具体体现在送给hal的capturerequest速度变慢。

每一个camera3outputstream都会统计dequeuebuffer latency。

  • 这里的output/input stream是相对hal而言,hal输出的流是output stream,输入给hal的流是input stream

dequeuebuffer:

  • 通过graphicbufferproducer从bufferqueue里面获取一张未使用的buffer

dequeuebuffer latency是什么

dequeuebuffer latency配置

dequeuebuffer latency直方图配置

  • 分成10份(默认值),间隔为5ms
  • static const int32_t kdequeuelatencybinsize = 5; // in ms

添加sample的时机

  • 在每个capturerequest的preparehalrequests中会调用getbuffer,进而触发到对bufferqueue的dequeuebuffer操作。
  • camera3outputstream会对每次dequeuebuffer操作耗时做记录,然后作为一个sample添加到cameralatencyhistogram。

dequeuebuffer latency配置

dequeeubuffer latency实战

  • 代码讲解
    nsecs_t dequeuestart = systemtime(system_time_monotonic);
    size_t batchsize = mbatchsize.load();
    if (batchsize == 1) {
      sp anw = consumer;
      res = anw->dequeuebuffer(anw.get(), anb, fencefd);
    } else {
      std::unique_lock batchlock(mbatchlock);
      res = ok;
      if (mbatchedbuffers.size() == 0) {
          if (remainingbuffers == 0) {
              aloge("%s: cannot get buffer while all buffers are handed out", __function__);
              return invalid_operation;
          }
          if (batchsize > remainingbuffers) {
              batchsize = remainingbuffers;
          }
          batchlock.unlock();
          // refill batched buffers
          std::vector batchedbuffers;
          batchedbuffers.resize(batchsize);
          res = consumer->dequeuebuffers(&batchedbuffers);
          batchlock.lock();
          if (res != ok) {
              aloge("%s: batch dequeuebuffers call failed! %s (%d)",
                      __function__, strerror(-res), res);
          } else {
              mbatchedbuffers = std::move(batchedbuffers);
          }
      }
      if (res == ok) {
          // dispatch batch buffers
          *anb = mbatchedbuffers.back().buffer;
          *fencefd = mbatchedbuffers.back().fencefd;
          mbatchedbuffers.pop_back();
      }
    }
    nsecs_t dequeueend = systemtime(system_time_monotonic);
    mdequeuebufferlatency.add(dequeuestart, dequeueend);
  • 实战演示,请参阅视频

camera课程

python教程

java教程

web教程

数据库教程

图形图像教程

办公软件教程

linux教程

计算机教程

大数据教程

开发工具教程

android camera性能分析

网站地图