From 9f17a23a42c64d0a941d9b2e3aa0b1804ca4b0f8 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Mon, 24 Feb 2020 12:29:42 +1100 Subject: [PATCH] videorenderframecache: use hash-prefix directory structure Many file systems become inefficient with a lot of files in the same directory. To solve this we use a semi-arbitrary system to split up all cache files into several folders to keep things performant. --- app/render/backend/videorenderframecache.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/render/backend/videorenderframecache.cpp b/app/render/backend/videorenderframecache.cpp index 3712847b3..a45591414 100644 --- a/app/render/backend/videorenderframecache.cpp +++ b/app/render/backend/videorenderframecache.cpp @@ -103,11 +103,8 @@ const QMap &VideoRenderFrameCache::time_hash_map() const return time_hash_map_; } -QString VideoRenderFrameCache::CachePathName(const QByteArray &hash, const PixelFormat::Format& pix_fmt) const +QString VideoRenderFrameCache::CachePathName(const QByteArray& hash, const PixelFormat::Format& pix_fmt) const { - QDir this_cache_dir = QDir(GetMediaCacheLocation()); - this_cache_dir.mkpath("."); - QString ext; if (pix_fmt == PixelFormat::PIX_FMT_RGBA8 || pix_fmt == PixelFormat::PIX_FMT_RGBA16U) { @@ -117,7 +114,10 @@ QString VideoRenderFrameCache::CachePathName(const QByteArray &hash, const Pixel ext = QStringLiteral("exr"); } - QString filename = QStringLiteral("%1.%2").arg(QString(hash.toHex()), ext); + QDir cache_dir(QDir(GetMediaCacheLocation()).filePath(QString(hash.left(1).toHex()))); + cache_dir.mkpath("."); - return this_cache_dir.filePath(filename); + QString filename = QStringLiteral("%1.%2").arg(QString(hash.mid(1).toHex()), ext); + + return cache_dir.filePath(filename); }