{"action":"created","issue":{"url":"https://api.github.com/repos/tgstation/tgstation/issues/36866","repository_url":"https://api.github.com/repos/tgstation/tgstation","labels_url":"https://api.github.com/repos/tgstation/tgstation/issues/36866/labels{/name}","comments_url":"https://api.github.com/repos/tgstation/tgstation/issues/36866/comments","events_url":"https://api.github.com/repos/tgstation/tgstation/issues/36866/events","html_url":"https://github.com/tgstation/tgstation/pull/36866","id":310254395,"number":36866,"title":"Last spotted near a cavern hauling a container of detritus, local madman reduces overlay lag by up to 15,719%","user":{"login":"Robustin","id":6372371,"avatar_url":"https://avatars2.githubusercontent.com/u/6372371?v=4","gravatar_id":"","url":"https://api.github.com/users/Robustin","html_url":"https://github.com/Robustin","followers_url":"https://api.github.com/users/Robustin/followers","following_url":"https://api.github.com/users/Robustin/following{/other_user}","gists_url":"https://api.github.com/users/Robustin/gists{/gist_id}","starred_url":"https://api.github.com/users/Robustin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Robustin/subscriptions","organizations_url":"https://api.github.com/users/Robustin/orgs","repos_url":"https://api.github.com/users/Robustin/repos","events_url":"https://api.github.com/users/Robustin/events{/privacy}","received_events_url":"https://api.github.com/users/Robustin/received_events","type":"User","site_admin":false},"labels":[{"id":31457173,"url":"https://api.github.com/repos/tgstation/tgstation/labels/Performance","name":"Performance","color":"0b02e1","default":false},{"id":380349558,"url":"https://api.github.com/repos/tgstation/tgstation/labels/Refactor","name":"Refactor","color":"FF9933","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2018-03-31T16:46:54Z","updated_at":"2018-03-31T22:25:11Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/tgstation/tgstation/pulls/36866","html_url":"https://github.com/tgstation/tgstation/pull/36866","diff_url":"https://github.com/tgstation/tgstation/pull/36866.diff","patch_url":"https://github.com/tgstation/tgstation/pull/36866.patch"},"body":"So after scavenging overhaul code for a few days, after dozens and dozens of tests, the data added up to a horrifying realization.\r\n\r\nThe very heart of our overlay code, a single line that basically boiled down to overlays = new_overlays, was the cause of so much overlay lag. Human overlay code was by far the biggest culprit. Most objects have 0-2 overlays but humans are marching around with 20+ most of the time and the current system was spending a LOT of effort comparing 20+ image with 20+ other images and then apparently rendering them all anyway. Human overlays are at least 10x the cost of any other overlay process and on a busy server the overlay compiling was 2x the cost of any other system.\r\n\r\nI compared the cost of overlay changes by picking up/dropping a PDA in the dorms 250 times, with a 50% chance to use our current overlay compiler and a 50% chance to use a \"direct addition/removal (+=, -=) approach:\r\n\r\nCURRENT | 1120ms | 133 | (avg:8.4210529327392578)\r\n-- | -- | -- | --\r\nSCRAPS | 6ms | 112 | (avg:0.0535714291036129)\r\n\r\nNow this PR makes our whole overlay subsystem use that approach for overlay compiling and the early results look incredible. The best part is this is just the START of improvements. Humans benefits the most because their icon system was already designed for small, incremental overlay updates. By moving other code from \"Cut everything, then put it all back\" to only updating the necessary overlays (cough, APC's), we can see similar improvements. \r\n\r\n"},"comment":{"url":"https://api.github.com/repos/tgstation/tgstation/issues/comments/377727764","html_url":"https://github.com/tgstation/tgstation/pull/36866#issuecomment-377727764","issue_url":"https://api.github.com/repos/tgstation/tgstation/issues/36866","id":377727764,"user":{"login":"Bombpants","id":30200941,"avatar_url":"https://avatars0.githubusercontent.com/u/30200941?v=4","gravatar_id":"","url":"https://api.github.com/users/Bombpants","html_url":"https://github.com/Bombpants","followers_url":"https://api.github.com/users/Bombpants/followers","following_url":"https://api.github.com/users/Bombpants/following{/other_user}","gists_url":"https://api.github.com/users/Bombpants/gists{/gist_id}","starred_url":"https://api.github.com/users/Bombpants/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bombpants/subscriptions","organizations_url":"https://api.github.com/users/Bombpants/orgs","repos_url":"https://api.github.com/users/Bombpants/repos","events_url":"https://api.github.com/users/Bombpants/events{/privacy}","received_events_url":"https://api.github.com/users/Bombpants/received_events","type":"User","site_admin":false},"created_at":"2018-03-31T22:25:11Z","updated_at":"2018-03-31T22:25:11Z","author_association":"NONE","body":"Space was on fire?"}}
{"actor":{"display_login":"Bombpants"}}