Terrain cache fixes and optimizations
- Initialize
GenericResourceManager::mExpiryDelay
with value from settings for all resource managers except forNifFileManager
. !3032 (merged) missed that some of them are dynamically created per worldspace and there was not initialization for that. This reduces the number of chunks removed from cache because they are not immediately used. - Fix #7557 (closed) by removing "passes" added by https://github.com/OpenMW/openmw/pull/3126. It's kind of mistery what was the author intention but basically on initial loading for Oblivion (AnvilMainEntrance start cell) with view distance covering all cells 537 chunks were requests by preloader with 320 more than once and 177 by first culling with only 129 being in cache. Now it's 177 requested by preloader without any duplicates and 177 by first culling with 100% cache hit.
- Optimize lookup for a "template" for the terrain chunk by using std::map::lower_bound instead of linear search. This was added by https://github.com/OpenMW/openmw/pull/3126 with linear search is very inefficient.
Test results based on the benchmark from !3101 for Oblivion (4a46d772 - master, 915a8df9 - last commit from MR):
source | key | number | min | max | sum | mean | median | stdev | q95 |
---|---|---|---|---|---|---|---|---|---|
915a8df9.1693334616.log | Cull traversal time taken Camera 1 | 8950 | 0.00034 | 0.01707 | 14.95255 | 0.00167 | 0.00138 | 0.00122 | 0.00361 |
915a8df9.1693334993.log | Cull traversal time taken Camera 1 | 8950 | 0.00034 | 0.02184 | 15.16027 | 0.00169 | 0.00136 | 0.00133 | 0.00375 |
915a8df9.1693334804.log | Cull traversal time taken Camera 1 | 8950 | 0.00034 | 0.01774 | 15.22668 | 0.00170 | 0.00137 | 0.00128 | 0.00374 |
4a46d772.1693334397.log | Cull traversal time taken Camera 1 | 8950 | 0.00000 | 0.16114 | 26.66057 | 0.00298 | 0.00119 | 0.01017 | 0.00726 |
4a46d772.1693334018.log | Cull traversal time taken Camera 1 | 8950 | 0.00000 | 0.16727 | 27.48813 | 0.00307 | 0.00119 | 0.01045 | 0.00785 |
4a46d772.1693334207.log | Cull traversal time taken Camera 1 | 8950 | 0.00000 | 0.16930 | 27.70413 | 0.00310 | 0.00117 | 0.01048 | 0.00779 |
915a8df9.1693334616.log | Draw traversal time taken Camera 1 | 8950 | 0.00056 | 0.01136 | 23.28198 | 0.00260 | 0.00229 | 0.00131 | 0.00506 |
915a8df9.1693334804.log | Draw traversal time taken Camera 1 | 8950 | 0.00058 | 0.01358 | 23.46950 | 0.00262 | 0.00231 | 0.00133 | 0.00503 |
915a8df9.1693334993.log | Draw traversal time taken Camera 1 | 8950 | 0.00060 | 0.01655 | 23.93031 | 0.00267 | 0.00237 | 0.00140 | 0.00516 |
4a46d772.1693334207.log | Draw traversal time taken Camera 1 | 8950 | 0.00000 | 0.04047 | 29.19404 | 0.00326 | 0.00292 | 0.00224 | 0.00760 |
4a46d772.1693334018.log | Draw traversal time taken Camera 1 | 8950 | 0.00000 | 0.04282 | 29.32647 | 0.00328 | 0.00283 | 0.00226 | 0.00800 |
4a46d772.1693334397.log | Draw traversal time taken Camera 1 | 8950 | 0.00000 | 0.03167 | 29.45126 | 0.00329 | 0.00287 | 0.00230 | 0.00806 |
915a8df9.1693334616.log | Frame duration | 8950 | 0.01569 | 0.08176 | 156.88568 | 0.01753 | 0.01667 | 0.00455 | 0.01689 |
915a8df9.1693334804.log | Frame duration | 8950 | 0.01582 | 0.07657 | 157.22544 | 0.01757 | 0.01667 | 0.00474 | 0.01692 |
915a8df9.1693334993.log | Frame duration | 8950 | 0.01567 | 0.08814 | 157.27544 | 0.01757 | 0.01667 | 0.00486 | 0.01690 |
4a46d772.1693334397.log | Frame duration | 8950 | 0.00000 | 0.19605 | 170.13979 | 0.01901 | 0.01667 | 0.01253 | 0.02722 |
4a46d772.1693334207.log | Frame duration | 8950 | 0.00000 | 0.19605 | 170.38327 | 0.01904 | 0.01667 | 0.01200 | 0.02905 |
4a46d772.1693334018.log | Frame duration | 8950 | 0.00000 | 0.20413 | 172.03573 | 0.01922 | 0.01667 | 0.01281 | 0.02944 |
915a8df9.1693334804.log | GPU draw time taken Camera 1 | 8950 | 0.00210 | 0.01370 | 27.56236 | 0.00308 | 0.00254 | 0.00121 | 0.00553 |
915a8df9.1693334616.log | GPU draw time taken Camera 1 | 8950 | 0.00210 | 0.01231 | 27.70777 | 0.00310 | 0.00260 | 0.00119 | 0.00553 |
915a8df9.1693334993.log | GPU draw time taken Camera 1 | 8950 | 0.00221 | 0.01753 | 28.22620 | 0.00315 | 0.00260 | 0.00125 | 0.00564 |
4a46d772.1693334397.log | GPU draw time taken Camera 1 | 8950 | 0.00000 | 0.01603 | 33.70045 | 0.00377 | 0.00320 | 0.00166 | 0.00667 |
4a46d772.1693334207.log | GPU draw time taken Camera 1 | 8950 | 0.00000 | 0.04125 | 33.99920 | 0.00380 | 0.00318 | 0.00169 | 0.00663 |
4a46d772.1693334018.log | GPU draw time taken Camera 1 | 8950 | 0.00000 | 0.03115 | 34.07438 | 0.00381 | 0.00323 | 0.00163 | 0.00663 |
915a8df9.1693334616.log | Rendering traversals time taken | 8950 | 0.00045 | 0.01732 | 17.68347 | 0.00198 | 0.00165 | 0.00128 | 0.00408 |
915a8df9.1693334993.log | Rendering traversals time taken | 8950 | 0.00043 | 0.02207 | 17.86184 | 0.00200 | 0.00164 | 0.00137 | 0.00422 |
915a8df9.1693334804.log | Rendering traversals time taken | 8950 | 0.00046 | 0.01797 | 17.94783 | 0.00201 | 0.00165 | 0.00133 | 0.00418 |
4a46d772.1693334397.log | Rendering traversals time taken | 8950 | 0.00000 | 0.16126 | 30.96960 | 0.00346 | 0.00150 | 0.01018 | 0.00881 |
4a46d772.1693334207.log | Rendering traversals time taken | 8950 | 0.00000 | 0.16942 | 31.94489 | 0.00357 | 0.00152 | 0.01048 | 0.00920 |
4a46d772.1693334018.log | Rendering traversals time taken | 8950 | 0.00000 | 0.16735 | 31.96102 | 0.00357 | 0.00151 | 0.01046 | 0.00913 |
915a8df9.1693334616.log | world_time_taken | 8950 | 0.00005 | 0.07803 | 15.28416 | 0.00171 | 0.00029 | 0.00683 | 0.00136 |
915a8df9.1693334804.log | world_time_taken | 8950 | 0.00005 | 0.07141 | 15.52198 | 0.00173 | 0.00029 | 0.00701 | 0.00134 |
915a8df9.1693334993.log | world_time_taken | 8950 | 0.00005 | 0.08513 | 15.60633 | 0.00174 | 0.00030 | 0.00710 | 0.00136 |
4a46d772.1693334207.log | world_time_taken | 8950 | 0.00000 | 0.23707 | 18.54296 | 0.00207 | 0.00023 | 0.01010 | 0.01072 |
4a46d772.1693334397.log | world_time_taken | 8950 | 0.00000 | 0.18815 | 18.97701 | 0.00212 | 0.00023 | 0.01063 | 0.01092 |
4a46d772.1693334018.log | world_time_taken | 8950 | 0.00000 | 0.22600 | 20.31801 | 0.00227 | 0.00023 | 0.01132 | 0.01230 |
Tested with:
[Terrain]
distant terrain = true
object paging = false
[Camera]
viewing distance = 8192000
[Cells]
preload num threads = 1
pointers cache size = 100
preload distance = 20480
preload cell cache max = 512
preload cell expiry delay = 300
prediction time = 5
cache expiry delay = 10
Edited by elsid