summaryrefslogtreecommitdiffstats
path: root/src/util/disk_cache.c
Commit message (Collapse)AuthorAgeFilesLines
* util/disk_cache: do eviction before creating .tmpGrazvydas Ignotas2017-03-161-10/+8
| | | | | | | | | | | | | | cache_put() first creates a .tmp file and then tries to do eviction. The recently added LRU eviction code selects non-empty directory with the oldest access time, but that may easily be the one with just the new .tmp file, especially on Linux where atime is updated lazily (with "relatime" mount option, which is the default). So when cache is small, if random doesn't hit another dir LRU keeps selecting the same dir with just the .tmp and not deleting anything. To fix this (and the tests), do eviction earlier. Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* util/disk_cache: scale cache according to filesystem sizeAlan Swanson2017-03-151-3/+8
| | | | | | | | Select higher of current 1G default or 10% of filesystem where cache is located. Acked-by: Timothy Arceri <[email protected]> Reviewed-by: Grazvydas Ignotas <[email protected]>
* util/disk_cache: actually enforce cache sizeAlan Swanson2017-03-151-1/+5
| | | | | | | | | | Currently only a one in one out eviction so if at max_size and cache files were to constantly increase in size then so would the cache. Restrict to limit of 8 evictions per new cache entry. V2: (Timothy Arceri) fix make check tests Reviewed-by: Grazvydas Ignotas <[email protected]>
* util/disk_cache: use LRU eviction rather than random evictionAlan Swanson2017-03-151-43/+34
| | | | | | | | | | | Still using fast random selection of two-character subdirectory in which to check cache files rather than scanning entire cache. v2: Factor out double strlen call v3: C99 declaration of variables where used Reviewed-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* util/disk_cache: don't fallback to an empty cache dir on evictTimothy Arceri2017-03-151-6/+27
| | | | | | | | | | If we fail to randomly select a two letter cache dir, don't select an empty dir on fallback. In real world use we should never hit the fallback path but it can be hit by tests when the cache is set to a very small max value. Reviewed-by: Grazvydas Ignotas <[email protected]>
* util/disk_cache: use a thread queue to write to shader cacheTimothy Arceri2017-03-151-13/+28
| | | | | | | | | | | | | | This should help reduce any overhead added by the shader cache when programs are not found in the cache. To avoid creating any special function just for the sake of the tests we add a one second delay whenever we call dick_cache_put() to give it time to finish. V2: poll for file when waiting for thread in test V3: fix poll delay to really be 100ms, and simplify the wait function Reviewed-by: Grazvydas Ignotas <[email protected]>
* util/disk_cache: add helpers for creating/destroying disk cache put jobsTimothy Arceri2017-03-151-0/+40
| | | | | | | V2: Make a copy of the data so we don't have to worry about it being freed before we are done compressing/writing. Reviewed-by: Grazvydas Ignotas <[email protected]>
* util/disk_cache: add thread queue to disk cacheTimothy Arceri2017-03-151-1/+15
| | | | | Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Grazvydas Ignotas <[email protected]>
* util/disk_cache: fix size subtraction on 32bitGrazvydas Ignotas2017-03-091-3/+3
| | | | | | | | | | Negating size_t on 32bit produces a 32bit result. This was effectively adding values close to UINT_MAX to the cache size (the files are usually small) instead of intended subtraction. Fixes 'make check' disk_cache failures on 32bit. Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* util/disk_cache: fix compressed size calculationGrazvydas Ignotas2017-03-091-1/+1
| | | | | | | | | It incorrectly doubles the size on each iteration. Fixes: 85a9b1b5 "util/disk_cache: compress individual cache entries" Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* util/disk_cache: fix make checkTimothy Arceri2017-03-061-17/+0
| | | | | Fixes make check after 11f0efec2e615f5233d which caused disk cache to create an additional directory.
* Revert "glsl: Switch to disable-by-default for the GLSL shader cache"Timothy Arceri2017-03-061-7/+0
| | | | | | | | | This reverts commit 0f60c6616e93cba72bff4fbfedb72a753ef78e05. Piglit and all games tested so far seem to be working without issue. This change will allow wide user testing and we can decided before the next release if we need to turn it off again. Reviewed-by: Marek Olšák <[email protected]>
* util/disk_cache: support caches for multiple architecturesTimothy Arceri2017-03-061-0/+26
| | | | | | | | | | | | | | Previously we were deleting the entire cache if a user switched between 32 and 64 bit applications. V2: make the check more generic, it should now work with any platform we are likely to support. V3: Use suggestion from Emil to make even more generic/fix issue with __ILP32__ not being declared on gcc for regular 32-bit builds. Tested-by: Grazvydas Ignotas <[email protected]> Tested-by: Dieter Nützel <[email protected]>
* util/disk_cache: mark read-only arguments constGrazvydas Ignotas2017-03-061-17/+18
| | | | | | | No functional changes. Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* util/disk_cache: compress individual cache entriesTimothy Arceri2017-03-031-23/+150
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reduces the cache size for Deus Ex from ~160M to ~30M for radeonsi (these numbers differ from Grigori's results below probably due to different graphics quality settings). I'm also seeing the following improvements in minimum fps in the Shadow of Mordor benchmark on an i5-6400 [email protected], with a HDD: no-cache: ~10fps with-cache-no-compression: ~15fps with-cache-and-compression: ~20fps Note: The with cache results are from the second run after closing and opening the game to avoid the in-memory cache. Since we mainly care about decompression I went with Z_BEST_COMPRESSION as suggested on irc by Steinar H. Gunderson who has benchmarked decompression speeds. Grigori Goronzy provided the following stats for Deus Ex: Mankind Divided start-up times on a Athlon X4 860k with a SSD: No Cache 215 sec Cold Cache zlib BEST_COMPRESSION 285 sec Warm Cache zlib BEST_COMPRESSION 33 sec Cold Cache zlib BEST_SPEED 264 sec Warm Cache zlib BEST_SPEED 33 sec Cold Cache no compression 266 sec Warm Cache no compression 34 sec The total cache size for that game is 48 MiB with BEST_COMPRESSION, 56 MiB with BEST_SPEED and 170 MiB with no compression. These numbers suggest that it may be ok to go with Z_BEST_SPEED but we should gather some actual decompression times before doing so. Other options might be to do the compression in a separate thread, this might allow us to use a higher compression algorithim such as LZMA. Reviewed-by: Grigori Goronzy <[email protected]> Acked-by: Marek Olšák <[email protected]>
* util/disk_cache: add support for detecting corrupt cache entriesTimothy Arceri2017-03-031-3/+34
| | | | | | | V2: fix pointer increments for writing/reading crc Acked-by: Marek Olšák <[email protected]> Reviewed-by: Grigori Goronzy <[email protected]>
* util/disk_cache: fix bug with deleting old cache dirsTimothy Arceri2017-02-231-4/+6
| | | | | | | | | | If there was more than a single directory in the .cache/mesa dir then it would only remove one (or none) of the directories. Apparently Valgrind was also reporting: Conditional jump or move depends on uninitialised value Reviewed-by: Edward O'Callaghan <[email protected]>
* util/disk_cache: create timestamp and gpu_id dirs when MESA_GLSL_CACHE_DIR ↵Timothy Arceri2017-02-221-2/+8
| | | | | | | | is used The make check test is also updated to make sure these dirs are created. Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: disable on disk shader cache when running as another userTimothy Arceri2017-02-171-0/+4
| | | | Reviewed-by: Nicolai Hähnle <[email protected]>
* util/disk_cache: check cache exists before calling munmap()Timothy Arceri2017-02-171-1/+2
| | | | Reviewed-by: Nicolai Hähnle <[email protected]>
* util/disk_cache: add support for removing old versions of the cacheTimothy Arceri2017-02-171-0/+37
| | | | Reviewed-by: Nicolai Hähnle <[email protected]>
* util/disk_cache: allow drivers to pass a directory structureTimothy Arceri2017-02-171-4/+24
| | | | | | | | | | | | | | In order to avoid costly fallback recompiles when cache items are created with an old version of Mesa or for a different gpu on the same system we want to create directories that look like this: ./{TIMESTAMP}_{LLVM_TIMESTAMP}/{GPU_ID} Note: The disk cache util will take a single timestamp string, it is up to the backend to concatenate the llvm string with the mesa string if applicable. Reviewed-by: Nicolai Hähnle <[email protected]>
* util/disk_cache: do not allow space in MESA_GLSL_CACHE_MAX_SIZEEmil Velikov2017-02-161-2/+0
| | | | | | | No other env var used in mesa allows for space in the variable contents. Signed-off-by: Emil Velikov <[email protected]> Acked-by: Timothy Arceri <[email protected]>
* util/disk_cache: correctly use stat(3)Timothy Arceri2017-02-131-4/+4
| | | | | | | | | I forgot to error check stat() and also I wasn't using the subdir in is_two_character_sub_directory(). Fixes: d7b3707c612 "util/disk_cache: use stat() to check if entry is a directory" Reviewed-by: Plamena Manolova <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* util/disk_cache: use stat() to check if entry is a directoryTimothy Arceri2017-02-101-9/+24
| | | | | | | | d_type is not supported on all systems. Tested-by: Vinson Lee <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97967
* util/disk_cache: error check asprintf()Timothy Arceri2017-02-101-5/+7
| | | | | | | Fixes: f3d911463e8 "util/disk_cache: stop using ralloc_asprintf() unnecessarily" Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* util/disk_cache: stop using ralloc_asprintf() unnecessarilyTimothy Arceri2017-02-091-13/+12
| | | | Reviewed-by: Anuj Phogat <[email protected]>
* util: add a disk_cache_remove() functionTimothy Arceri2017-02-091-0/+22
| | | | | | | | | | This will be used to remove cache items created with old versions of Mesa or other invalid cache items from the cache. V2: rename stub function (cache_* funtions were renamed disk_cache_*) in master. Reviewed-by: Anuj Phogat <[email protected]>
* glsl: Switch to disable-by-default for the GLSL shader cacheCarl Worth2017-01-311-0/+7
| | | | | | | | | | | | | | | | | The shader cache is expected to be developed incrementally over a fairly long series of commits. For that period of instability, we require users to opt into the shader cache by setting: MESA_GLSL_CACHE_ENABLE=1 In the future, when the shader cache is complete, we can revert this commit so that the cache will be on by default. The user can always disable the cache with MESA_GLSL_CACHE_DISABLE=1. That functionality is not affected by this commit, (nor will it be affected by the future revert). Reviewed-by: Eric Anholt <[email protected]>
* utils: build sha1/disk cache only with Android/AutoconfEmil Velikov2017-01-181-0/+4
| | | | | | | | | | Earlier commit imported a SHA1 implementation and relaxed the SHA1 and disk cache handling, broking the Windows builds. Restrict things for now until we get to a proper fix. Fixes: d1efa09d342 "util: import sha1 implementation from OpenBSD" Signed-off-by: Emil Velikov <[email protected]>
* util: import sha1 implementation from OpenBSD17.0-branchpointEmil Velikov2017-01-181-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At the moment we support 5+ different implementations each with varying amount of bugs - from thread safely problems [1], to outright broken implementation(s) [2] In order to accommodate these we have 150+ lines of configure script and extra two configure toggles. Whist an actual implementation being ~200loc and our current compat wrapping ~250. Let's not forget that different people use different code paths, thus effectively makes it harder to test and debug since the default implementation is automatically detected. To minimise all these lovely experiences, import the "100% Public Domain" OpenBSD sha1 implementation. Clearly document any changes needed to get building correctly, since many/most of those can be upstreamed making future syncs easier. As an added bonus this will avoid all the 'fun' experiences trying to integrate it with the Android and SCons builds. v2: Manually expand __BEGIN_DECLS/__END_DECLS and document (Tapani). Furthermore it seems that some games (or surrounding runtime) static link against OpenSSL resulting in conflicts. For more information see the discussion thread [3] Bugzilla [1]: https://bugs.freedesktop.org/show_bug.cgi?id=94904 Bugzilla [2]: https://bugs.freedesktop.org/show_bug.cgi?id=97967 [3] https://lists.freedesktop.org/archives/mesa-dev/2017-January/140748.html Cc: Mark Janes <[email protected]> Cc: Vinson Lee <[email protected]> Cc: Tapani Pälli <[email protected]> Cc: Jonathan Gray <[email protected]> Tested-by: Jonathan Gray <[email protected]> Signed-off-by: Emil Velikov <[email protected]> Acked-by: Tapani Pälli <[email protected]> (v1) Acked-by: Jason Ekstrand <[email protected]> (v1)
* util/disk_cache: close a previously opened handle in disk_cache_put (v2)Gwan-gyeong Mun2016-11-221-6/+5
| | | | | | | | | | | | | | We're missing the close() to the matching open(). CID 1373407 v2: Fixes from Emil Velikov's review Update the teardown in reverse order of the setup/init. Cc: "13.0" <[email protected]> Signed-off-by: Mun Gwan-gyeong <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> (v1)
* util/disk_cache: use unambiguous namingMarek Olšák2016-11-151-15/+15
| | | | Reviewed-by: Emil Velikov <[email protected]>
* util: import cache.c/h from glslMarek Olšák2016-11-151-0/+712
It's not dependent on GLSL and it can be useful for shader caches that don't deal with GLSL. v2: address review comments v3: keep the other 3 lines in configure.ac Reviewed-by: Emil Velikov <[email protected]>