diff options
author | Niklas Söderlund <niklas.soderlund@ragnatech.se> | 2020-02-16 16:51:53 +0100 |
---|---|---|
committer | Niklas Söderlund <niklas.soderlund@ragnatech.se> | 2020-03-06 17:45:48 +0100 |
commit | 4e0d1eca10b7d2cf0ccbdbebee698d6b716d075b (patch) | |
tree | 099a879c4532b871351bded5e07b142a318d5e73 /src/libcamera/include | |
parent | 69d1e24ac75dc4003737b926bee3ce05420d047b (diff) |
libcamera: V4L2BufferCache: Improve cache eviction strategy
The strategy used to find a free cache entry in the first implementation
was not the smartest, it picked the first free entry. This lead to
unwanted performance issues as the cache was not used as good as it
could for imported buffers.
Improve this by adding a last usage sequence number to the cache entries
and change the eviction strategy to use the oldest free entry instead of
the first one it finds.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/libcamera/include')
-rw-r--r-- | src/libcamera/include/v4l2_videodevice.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h index 359b3664..04802012 100644 --- a/src/libcamera/include/v4l2_videodevice.h +++ b/src/libcamera/include/v4l2_videodevice.h @@ -7,11 +7,12 @@ #ifndef __LIBCAMERA_V4L2_VIDEODEVICE_H__ #define __LIBCAMERA_V4L2_VIDEODEVICE_H__ +#include <atomic> +#include <memory> #include <string> #include <vector> #include <linux/videodev2.h> -#include <memory> #include <libcamera/buffer.h> #include <libcamera/geometry.h> @@ -120,11 +121,12 @@ private: { public: Entry(); - Entry(bool free, const FrameBuffer &buffer); + Entry(bool free, uint64_t lastUsed, const FrameBuffer &buffer); bool operator==(const FrameBuffer &buffer) const; bool free; + uint64_t lastUsed; private: struct Plane { @@ -140,6 +142,7 @@ private: std::vector<Plane> planes_; }; + std::atomic_uint64_t lastUsedCounter_; std::vector<Entry> cache_; /* \todo Expose the miss counter through an instrumentation API. */ unsigned int missCounter_; |