本讲是android camera性能分析专题的第28讲,我们介绍cameraserver buffer limit latency,包括如下内容:
- buffer limit latency是什么
- buffer limit latency配置
- buffer limit latency实战
资源 | 描述 |
---|---|
在线课程 | |
知识星球 | 星球名称:深入浅出android camera 星球id: 17296815 |
极客笔记圈 |
buffer limit latency是什么
buffer limit latency用于衡量当某路stream dequeue buffer数量达到producer的最大值后,等待hal处理的耗时。
什么是numoutstandingbuffers
- 已经送给hal,hal正在处理,未返回的buffer数量
- 视频讲解演示如何查看每路stream的numoutstandingbuffers
什么是camera_stream::max_buffers
- camera hal配置的,在未返回buffer的情况下,最多dequeuebuffer的数量
- 视频讲解演示如何查看每路stream hal配置的最大max_buffers
buffer limit latency配置
buffer limit latency直方图配置
-
分成10份(默认值), 间隔为33ms
- static const int32_t kbufferlimitlatencybinsize = 33; //in ms
- latency histogram of the wait time for handout buffer count to drop below max_buffers.
添加sample的时机
- 当numoutstandingbuffers等于camera_stream::max_buffers时,会等待新的buffer返回,该latency衡量的是这个等待时间
buffer limit latency实战
// wait for new buffer returned back if we are running into the limit.
size_t numoutstandingbuffers = gethandoutoutputbuffercountlocked();
if (numoutstandingbuffers == camera_stream::max_buffers) {
alogv("%s: already dequeued max output buffers (%d), wait for next returned one.",
__function__, camera_stream::max_buffers);
nsecs_t waitstart = systemtime(system_time_monotonic);
if (waitbuffertimeout < kwaitforbufferduration) {
waitbuffertimeout = kwaitforbufferduration;
}
res = moutputbufferreturnedsignal.waitrelative(mlock, waitbuffertimeout);
nsecs_t waitend = systemtime(system_time_monotonic);
mbufferlimitlatency.add(waitstart, waitend);
if (res != ok) {
if (res == timed_out) {
aloge("%s: wait for output buffer return timed out after %lldms (max_buffers %d)",
__function__, waitbuffertimeout / 1000000ll,
camera_stream::max_buffers);
}
return res;
}
size_t updatednumoutstandingbuffers = gethandoutoutputbuffercountlocked();
if (updatednumoutstandingbuffers >= numoutstandingbuffers) {
aloge("%s: outsanding buffer count goes from %zu to %zu, "
"getbuffer(s) call must not run in parallel!", __function__,
numoutstandingbuffers, updatednumoutstandingbuffers);
return invalid_operation;
}
}