{"action":"created","issue":{"url":"https://api.github.com/repos/gonetz/GLideN64/issues/745","labels_url":"https://api.github.com/repos/gonetz/GLideN64/issues/745/labels{/name}","comments_url":"https://api.github.com/repos/gonetz/GLideN64/issues/745/comments","events_url":"https://api.github.com/repos/gonetz/GLideN64/issues/745/events","html_url":"https://github.com/gonetz/GLideN64/pull/745","id":109707563,"number":745,"title":"Changing the texture cache to be a proper LRU cache","user":{"login":"matthewharvey","id":1594441,"avatar_url":"https://avatars.githubusercontent.com/u/1594441?v=3","gravatar_id":"","url":"https://api.github.com/users/matthewharvey","html_url":"https://github.com/matthewharvey","followers_url":"https://api.github.com/users/matthewharvey/followers","following_url":"https://api.github.com/users/matthewharvey/following{/other_user}","gists_url":"https://api.github.com/users/matthewharvey/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewharvey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewharvey/subscriptions","organizations_url":"https://api.github.com/users/matthewharvey/orgs","repos_url":"https://api.github.com/users/matthewharvey/repos","events_url":"https://api.github.com/users/matthewharvey/events{/privacy}","received_events_url":"https://api.github.com/users/matthewharvey/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":17,"created_at":"2015-10-04T22:00:12Z","updated_at":"2015-10-08T02:48:06Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/gonetz/GLideN64/pulls/745","html_url":"https://github.com/gonetz/GLideN64/pull/745","diff_url":"https://github.com/gonetz/GLideN64/pull/745.diff","patch_url":"https://github.com/gonetz/GLideN64/pull/745.patch"},"body":"I change the currently used 'map' of textures to a queue (implemented as a list),\r\nand then remove from the end of the queue when textures need removing from\r\nthe cache, and adding to the beginning of the queue.\r\nThe other operation that is needed is moving the texture to the\r\nfront of the list whenever it is used, so that frequently used\r\ntextures are not deleted.\r\nIn order to make that last operation effecient, I created\r\na map of the locations of these textures, and keep that\r\nproperly updated. This makes the accessing of a texture still O(1).\r\nThen, in order to have the iterators remain valid through insertions\r\nand deletions, I needed to implement the queue as a list.\r\n\r\nThe map and queue implementation is a standard way to implement\r\nan LRU cache, just FYI. Not something I thought of all on my own.\r\n\r\nFixes issue #744 \r\n\r\nI'm hoping that this also fixes issue #534 \r\n\r\nFinally, I may have broken framebuffer textures (I'm not sure how those work). What is a game that uses those so that I can make sure?\r\n\r\nI know this doesn't clean up the texture code any, but I don't quite understand it all do a nice cleanup yet. Maybe later :P"},"comment":{"url":"https://api.github.com/repos/gonetz/GLideN64/issues/comments/146402996","html_url":"https://github.com/gonetz/GLideN64/pull/745#issuecomment-146402996","issue_url":"https://api.github.com/repos/gonetz/GLideN64/issues/745","id":146402996,"user":{"login":"matthewharvey","id":1594441,"avatar_url":"https://avatars.githubusercontent.com/u/1594441?v=3","gravatar_id":"","url":"https://api.github.com/users/matthewharvey","html_url":"https://github.com/matthewharvey","followers_url":"https://api.github.com/users/matthewharvey/followers","following_url":"https://api.github.com/users/matthewharvey/following{/other_user}","gists_url":"https://api.github.com/users/matthewharvey/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewharvey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewharvey/subscriptions","organizations_url":"https://api.github.com/users/matthewharvey/orgs","repos_url":"https://api.github.com/users/matthewharvey/repos","events_url":"https://api.github.com/users/matthewharvey/events{/privacy}","received_events_url":"https://api.github.com/users/matthewharvey/received_events","type":"User","site_admin":false},"created_at":"2015-10-08T02:48:06Z","updated_at":"2015-10-08T02:48:06Z","body":"Graphical glitches should appear when the texture cache is full without my changes, so that would be consistent with a slowdown because the texture cache has to work harder.\r\nI can't think of any way to avoid this. Because this particular game (and not any others I've encountered) creates so many temporary textures, it seems as though it might benefit from an occasional dump of the entire cache. Any other options would cause unacceptable stuttering (clearing out only part of the cache). But there would need to be logic to decide when to clear the cache, and even then building it back might cause stuttering.\r\nYou might be able to split the cache into two lists, and then move the older textures there during adding textures, and then clearing that out at some interval or something, but I can't imagine that making performance any better overall.\r\n\r\nSo are you seeing actual slowing down of the emulator below it's optimal rate? Or is it just increased CPU usage?\r\n\r\nThanks for all of the testing guys! It's really good to know that it's working on other games as well."}}