{"action":"created","comment":{"url":"https://api.github.com/repos/tgstation/tgstation/pulls/comments/182599013","pull_request_review_id":113427122,"id":182599013,"diff_hunk":"@@ -155,37 +150,30 @@ SUBSYSTEM_DEF(overlays)\n \n \toverlays = build_appearance_list(overlays)\n \n-\tLAZYINITLIST(our_overlays)\t//always initialized after this point\n+\tLAZYINITLIST(add_overlays) //always initialized after this point\n \tLAZYINITLIST(priority_overlays)\n-\n-\tvar/list/cached_overlays = our_overlays\t//sanic\n-\tvar/list/cached_priority = priority_overlays\n-\tvar/init_o_len = cached_overlays.len\n-\tvar/init_p_len = cached_priority.len  //starter pokemon\n-\tvar/need_compile\n+\tLAZYINITLIST(remove_overlays)\n \n \tif(priority)\n-\t\tcached_priority += overlays  //or in the image. Can we use [image] = image?\n-\t\tneed_compile = init_p_len != cached_priority.len\n+\t\tpriority_overlays += overlays  //or in the image. Can we use [image] = image?","path":"code/controllers/subsystem/overlays.dm","position":71,"original_position":71,"commit_id":"a73e33d3d2144cb2fcbbe21d285fb3040dc5be54","original_commit_id":"f9da1d1837f8e5e7d540b2d3e7ff605e01fb27aa","user":{"login":"optimumtact","id":2544323,"avatar_url":"https://avatars2.githubusercontent.com/u/2544323?v=4","gravatar_id":"","url":"https://api.github.com/users/optimumtact","html_url":"https://github.com/optimumtact","followers_url":"https://api.github.com/users/optimumtact/followers","following_url":"https://api.github.com/users/optimumtact/following{/other_user}","gists_url":"https://api.github.com/users/optimumtact/gists{/gist_id}","starred_url":"https://api.github.com/users/optimumtact/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/optimumtact/subscriptions","organizations_url":"https://api.github.com/users/optimumtact/orgs","repos_url":"https://api.github.com/users/optimumtact/repos","events_url":"https://api.github.com/users/optimumtact/events{/privacy}","received_events_url":"https://api.github.com/users/optimumtact/received_events","type":"User","site_admin":false},"body":"oI see, that is confusing","created_at":"2018-04-18T23:35:19Z","updated_at":"2018-04-18T23:35:19Z","html_url":"https://github.com/tgstation/tgstation/pull/36866#discussion_r182599013","pull_request_url":"https://api.github.com/repos/tgstation/tgstation/pulls/36866","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/tgstation/tgstation/pulls/comments/182599013"},"html":{"href":"https://github.com/tgstation/tgstation/pull/36866#discussion_r182599013"},"pull_request":{"href":"https://api.github.com/repos/tgstation/tgstation/pulls/36866"}},"in_reply_to_id":178443850},"pull_request":{"url":"https://api.github.com/repos/tgstation/tgstation/pulls/36866","id":178690404,"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","issue_url":"https://api.github.com/repos/tgstation/tgstation/issues/36866","number":36866,"state":"open","locked":false,"title":"refactors overlays to append/remove individual overlays instead of cutting","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},"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-------------------------------\r\nEdit: Live results from testing, massive improvements but still not perfect. My plate is full now but it wouldn't be too hard to make human's icon building not include null overlays and see what that does for performance - since multi-icon overlay updates for humans are the difference between .05ms and .2-.4ms overlay compiles. \r\n\r\n**BAGIL TESTMERGE:**\r\n/mob/living/carbon/human => 6456ms (21553) (avg:0.29954066872596741)\r\n**BAGIL NO TESTMERGE:**\r\n/mob/living/carbon/human => 146251ms (22649) (avg:6.4572830200195312)\r\n\r\n**That's over 2 minutes of processing time cleared out by this PR for a midpop round.** ","created_at":"2018-03-31T16:46:54Z","updated_at":"2018-04-18T23:35:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3543db4b5d51bf2c3b7a1c12db081a121f8814ff","assignee":null,"assignees":[],"requested_reviewers":[{"login":"Cyberboss","id":8171642,"avatar_url":"https://avatars3.githubusercontent.com/u/8171642?v=4","gravatar_id":"","url":"https://api.github.com/users/Cyberboss","html_url":"https://github.com/Cyberboss","followers_url":"https://api.github.com/users/Cyberboss/followers","following_url":"https://api.github.com/users/Cyberboss/following{/other_user}","gists_url":"https://api.github.com/users/Cyberboss/gists{/gist_id}","starred_url":"https://api.github.com/users/Cyberboss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cyberboss/subscriptions","organizations_url":"https://api.github.com/users/Cyberboss/orgs","repos_url":"https://api.github.com/users/Cyberboss/repos","events_url":"https://api.github.com/users/Cyberboss/events{/privacy}","received_events_url":"https://api.github.com/users/Cyberboss/received_events","type":"User","site_admin":false}],"requested_teams":[],"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}],"milestone":null,"commits_url":"https://api.github.com/repos/tgstation/tgstation/pulls/36866/commits","review_comments_url":"https://api.github.com/repos/tgstation/tgstation/pulls/36866/comments","review_comment_url":"https://api.github.com/repos/tgstation/tgstation/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tgstation/tgstation/issues/36866/comments","statuses_url":"https://api.github.com/repos/tgstation/tgstation/statuses/a73e33d3d2144cb2fcbbe21d285fb3040dc5be54","head":{"label":"Robustin:THEBIGONE","ref":"THEBIGONE","sha":"a73e33d3d2144cb2fcbbe21d285fb3040dc5be54","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},"repo":{"id":85407743,"name":"tgstation","full_name":"Robustin/tgstation","owner":{"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},"private":false,"html_url":"https://github.com/Robustin/tgstation","description":"the /tg/station branch of SS13","fork":true,"url":"https://api.github.com/repos/Robustin/tgstation","forks_url":"https://api.github.com/repos/Robustin/tgstation/forks","keys_url":"https://api.github.com/repos/Robustin/tgstation/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Robustin/tgstation/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Robustin/tgstation/teams","hooks_url":"https://api.github.com/repos/Robustin/tgstation/hooks","issue_events_url":"https://api.github.com/repos/Robustin/tgstation/issues/events{/number}","events_url":"https://api.github.com/repos/Robustin/tgstation/events","assignees_url":"https://api.github.com/repos/Robustin/tgstation/assignees{/user}","branches_url":"https://api.github.com/repos/Robustin/tgstation/branches{/branch}","tags_url":"https://api.github.com/repos/Robustin/tgstation/tags","blobs_url":"https://api.github.com/repos/Robustin/tgstation/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Robustin/tgstation/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Robustin/tgstation/git/refs{/sha}","trees_url":"https://api.github.com/repos/Robustin/tgstation/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Robustin/tgstation/statuses/{sha}","languages_url":"https://api.github.com/repos/Robustin/tgstation/languages","stargazers_url":"https://api.github.com/repos/Robustin/tgstation/stargazers","contributors_url":"https://api.github.com/repos/Robustin/tgstation/contributors","subscribers_url":"https://api.github.com/repos/Robustin/tgstation/subscribers","subscription_url":"https://api.github.com/repos/Robustin/tgstation/subscription","commits_url":"https://api.github.com/repos/Robustin/tgstation/commits{/sha}","git_commits_url":"https://api.github.com/repos/Robustin/tgstation/git/commits{/sha}","comments_url":"https://api.github.com/repos/Robustin/tgstation/comments{/number}","issue_comment_url":"https://api.github.com/repos/Robustin/tgstation/issues/comments{/number}","contents_url":"https://api.github.com/repos/Robustin/tgstation/contents/{+path}","compare_url":"https://api.github.com/repos/Robustin/tgstation/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Robustin/tgstation/merges","archive_url":"https://api.github.com/repos/Robustin/tgstation/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Robustin/tgstation/downloads","issues_url":"https://api.github.com/repos/Robustin/tgstation/issues{/number}","pulls_url":"https://api.github.com/repos/Robustin/tgstation/pulls{/number}","milestones_url":"https://api.github.com/repos/Robustin/tgstation/milestones{/number}","notifications_url":"https://api.github.com/repos/Robustin/tgstation/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Robustin/tgstation/labels{/name}","releases_url":"https://api.github.com/repos/Robustin/tgstation/releases{/id}","deployments_url":"https://api.github.com/repos/Robustin/tgstation/deployments","created_at":"2017-03-18T14:33:38Z","updated_at":"2018-03-27T15:31:45Z","pushed_at":"2018-04-18T22:54:28Z","git_url":"git://github.com/Robustin/tgstation.git","ssh_url":"git@github.com:Robustin/tgstation.git","clone_url":"https://github.com/Robustin/tgstation.git","svn_url":"https://github.com/Robustin/tgstation","homepage":"http://www.tgstation13.org/","size":1137372,"stargazers_count":0,"watchers_count":0,"language":"DM","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"tgstation:master","ref":"master","sha":"a577206f79a1b1cecf1c1fd43bbbbbc3ee01dd7a","user":{"login":"tgstation","id":1363778,"avatar_url":"https://avatars2.githubusercontent.com/u/1363778?v=4","gravatar_id":"","url":"https://api.github.com/users/tgstation","html_url":"https://github.com/tgstation","followers_url":"https://api.github.com/users/tgstation/followers","following_url":"https://api.github.com/users/tgstation/following{/other_user}","gists_url":"https://api.github.com/users/tgstation/gists{/gist_id}","starred_url":"https://api.github.com/users/tgstation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgstation/subscriptions","organizations_url":"https://api.github.com/users/tgstation/orgs","repos_url":"https://api.github.com/users/tgstation/repos","events_url":"https://api.github.com/users/tgstation/events{/privacy}","received_events_url":"https://api.github.com/users/tgstation/received_events","type":"Organization","site_admin":false},"repo":{"id":3234987,"name":"tgstation","full_name":"tgstation/tgstation","owner":{"login":"tgstation","id":1363778,"avatar_url":"https://avatars2.githubusercontent.com/u/1363778?v=4","gravatar_id":"","url":"https://api.github.com/users/tgstation","html_url":"https://github.com/tgstation","followers_url":"https://api.github.com/users/tgstation/followers","following_url":"https://api.github.com/users/tgstation/following{/other_user}","gists_url":"https://api.github.com/users/tgstation/gists{/gist_id}","starred_url":"https://api.github.com/users/tgstation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgstation/subscriptions","organizations_url":"https://api.github.com/users/tgstation/orgs","repos_url":"https://api.github.com/users/tgstation/repos","events_url":"https://api.github.com/users/tgstation/events{/privacy}","received_events_url":"https://api.github.com/users/tgstation/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tgstation/tgstation","description":"the /tg/station branch of SS13","fork":false,"url":"https://api.github.com/repos/tgstation/tgstation","forks_url":"https://api.github.com/repos/tgstation/tgstation/forks","keys_url":"https://api.github.com/repos/tgstation/tgstation/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tgstation/tgstation/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tgstation/tgstation/teams","hooks_url":"https://api.github.com/repos/tgstation/tgstation/hooks","issue_events_url":"https://api.github.com/repos/tgstation/tgstation/issues/events{/number}","events_url":"https://api.github.com/repos/tgstation/tgstation/events","assignees_url":"https://api.github.com/repos/tgstation/tgstation/assignees{/user}","branches_url":"https://api.github.com/repos/tgstation/tgstation/branches{/branch}","tags_url":"https://api.github.com/repos/tgstation/tgstation/tags","blobs_url":"https://api.github.com/repos/tgstation/tgstation/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tgstation/tgstation/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tgstation/tgstation/git/refs{/sha}","trees_url":"https://api.github.com/repos/tgstation/tgstation/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tgstation/tgstation/statuses/{sha}","languages_url":"https://api.github.com/repos/tgstation/tgstation/languages","stargazers_url":"https://api.github.com/repos/tgstation/tgstation/stargazers","contributors_url":"https://api.github.com/repos/tgstation/tgstation/contributors","subscribers_url":"https://api.github.com/repos/tgstation/tgstation/subscribers","subscription_url":"https://api.github.com/repos/tgstation/tgstation/subscription","commits_url":"https://api.github.com/repos/tgstation/tgstation/commits{/sha}","git_commits_url":"https://api.github.com/repos/tgstation/tgstation/git/commits{/sha}","comments_url":"https://api.github.com/repos/tgstation/tgstation/comments{/number}","issue_comment_url":"https://api.github.com/repos/tgstation/tgstation/issues/comments{/number}","contents_url":"https://api.github.com/repos/tgstation/tgstation/contents/{+path}","compare_url":"https://api.github.com/repos/tgstation/tgstation/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tgstation/tgstation/merges","archive_url":"https://api.github.com/repos/tgstation/tgstation/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tgstation/tgstation/downloads","issues_url":"https://api.github.com/repos/tgstation/tgstation/issues{/number}","pulls_url":"https://api.github.com/repos/tgstation/tgstation/pulls{/number}","milestones_url":"https://api.github.com/repos/tgstation/tgstation/milestones{/number}","notifications_url":"https://api.github.com/repos/tgstation/tgstation/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tgstation/tgstation/labels{/name}","releases_url":"https://api.github.com/repos/tgstation/tgstation/releases{/id}","deployments_url":"https://api.github.com/repos/tgstation/tgstation/deployments","created_at":"2012-01-21T17:32:47Z","updated_at":"2018-04-18T20:46:08Z","pushed_at":"2018-04-18T23:31:40Z","git_url":"git://github.com/tgstation/tgstation.git","ssh_url":"git@github.com:tgstation/tgstation.git","clone_url":"https://github.com/tgstation/tgstation.git","svn_url":"https://github.com/tgstation/tgstation","homepage":"https://www.tgstation13.org/","size":1113320,"stargazers_count":504,"watchers_count":504,"language":"DM","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1757,"mirror_url":null,"archived":false,"open_issues_count":1156,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0"},"forks":1757,"open_issues":1156,"watchers":504,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tgstation/tgstation/pulls/36866"},"html":{"href":"https://github.com/tgstation/tgstation/pull/36866"},"issue":{"href":"https://api.github.com/repos/tgstation/tgstation/issues/36866"},"comments":{"href":"https://api.github.com/repos/tgstation/tgstation/issues/36866/comments"},"review_comments":{"href":"https://api.github.com/repos/tgstation/tgstation/pulls/36866/comments"},"review_comment":{"href":"https://api.github.com/repos/tgstation/tgstation/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tgstation/tgstation/pulls/36866/commits"},"statuses":{"href":"https://api.github.com/repos/tgstation/tgstation/statuses/a73e33d3d2144cb2fcbbe21d285fb3040dc5be54"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"optimumtact"}}