Patch Detail
Show a patch.
GET /api/1.1/patches/2836/?format=api
{ "id": 2836, "url": "https://patchwork.libcamera.org/api/1.1/patches/2836/?format=api", "web_url": "https://patchwork.libcamera.org/patch/2836/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20200216161642.152263-2-niklas.soderlund@ragnatech.se>", "date": "2020-02-16T16:16:41", "name": "[libcamera-devel,1/2] libcamera: V4L2BufferCache: Improve cache eviction strategy", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "a081f8a9471833377a5fb892e72775f00a3c3769", "submitter": { "id": 5, "url": "https://patchwork.libcamera.org/api/1.1/people/5/?format=api", "name": "Niklas Söderlund", "email": "niklas.soderlund@ragnatech.se" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/2836/mbox/", "series": [ { "id": 676, "url": "https://patchwork.libcamera.org/api/1.1/series/676/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=676", "date": "2020-02-16T16:16:40", "name": "libcamera: V4L2BufferCache: Improve cache eviction strategy", "version": 1, "mbox": "https://patchwork.libcamera.org/series/676/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/2836/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/2836/checks/", "tags": {}, "headers": { "Return-Path": "<niklas.soderlund@ragnatech.se>", "Received": [ "from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net\n\t[195.74.38.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 632DE60438\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 16 Feb 2020 17:17:34 +0100 (CET)", "from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de\n\t[79.202.35.146]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA\n\tid d64c5259-50d7-11ea-9f85-005056917a89;\n\tSun, 16 Feb 2020 17:17:33 +0100 (CET)" ], "X-Halon-ID": "d64c5259-50d7-11ea-9f85-005056917a89", "Authorized-sender": "niklas@soderlund.pp.se", "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sun, 16 Feb 2020 17:16:41 +0100", "Message-Id": "<20200216161642.152263-2-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.25.0", "In-Reply-To": "<20200216161642.152263-1-niklas.soderlund@ragnatech.se>", "References": "<20200216161642.152263-1-niklas.soderlund@ragnatech.se>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 1/2] libcamera: V4L2BufferCache: Improve\n\tcache eviction strategy", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "X-List-Received-Date": "Sun, 16 Feb 2020 16:17:34 -0000" }, "content": "The strategy used to find a free cache entry in the first implementation\nwas not the smartest, it picked the first free entry. This lead to\nunwanted performance issues as they cache was not used as good as it\ncould for imported buffers.\n\nImprove this by adding a last usage timestamp to the cache entries and\nchange the eviction strategy to use the oldest free entry instead of the\nfirst one it finds.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/libcamera/include/v4l2_videodevice.h | 1 +\n src/libcamera/v4l2_videodevice.cpp | 9 ++++++---\n 2 files changed, 7 insertions(+), 3 deletions(-)", "diff": "diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h\nindex fcf072641420dacf..f04feed87b24f28f 100644\n--- a/src/libcamera/include/v4l2_videodevice.h\n+++ b/src/libcamera/include/v4l2_videodevice.h\n@@ -125,6 +125,7 @@ private:\n \t\tbool operator==(const FrameBuffer &buffer);\n \n \t\tbool free;\n+\t\tutils::time_point lastUsed;\n \n \tprivate:\n \t\tstruct Plane {\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex 99470ce11421c77c..9a4d2479b20f5e27 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -205,6 +205,7 @@ int V4L2BufferCache::get(const FrameBuffer &buffer)\n {\n \tbool hit = false;\n \tint use = -1;\n+\tutils::time_point oldest = utils::clock::now();\n \n \tfor (unsigned int index = 0; index < cache_.size(); index++) {\n \t\tconst Entry &entry = cache_[index];\n@@ -212,8 +213,10 @@ int V4L2BufferCache::get(const FrameBuffer &buffer)\n \t\tif (!entry.free)\n \t\t\tcontinue;\n \n-\t\tif (use < 0)\n+\t\tif (cache_[index].lastUsed < oldest) {\n \t\t\tuse = index;\n+\t\t\toldest = cache_[index].lastUsed;\n+\t\t}\n \n \t\t/* Try to find a cache hit by comparing the planes. */\n \t\tif (cache_[index] == buffer) {\n@@ -245,12 +248,12 @@ void V4L2BufferCache::put(unsigned int index)\n }\n \n V4L2BufferCache::Entry::Entry()\n-\t: free(true)\n+\t: free(true), lastUsed(utils::clock::now())\n {\n }\n \n V4L2BufferCache::Entry::Entry(bool free, const FrameBuffer &buffer)\n-\t: free(free)\n+\t: free(free), lastUsed(utils::clock::now())\n {\n \tfor (const FrameBuffer::Plane &plane : buffer.planes())\n \t\tplanes_.emplace_back(plane);\n", "prefixes": [ "libcamera-devel", "1/2" ] }