{"action":"created","issue":{"url":"https://api.github.com/repos/MovingBlocks/Terasology/issues/1510","labels_url":"https://api.github.com/repos/MovingBlocks/Terasology/issues/1510/labels{/name}","comments_url":"https://api.github.com/repos/MovingBlocks/Terasology/issues/1510/comments","events_url":"https://api.github.com/repos/MovingBlocks/Terasology/issues/1510/events","html_url":"https://github.com/MovingBlocks/Terasology/pull/1510","id":53971385,"number":1510,"title":"Fix autosave spikes","user":{"login":"flo","id":3511,"avatar_url":"https://avatars.githubusercontent.com/u/3511?v=3","gravatar_id":"","url":"https://api.github.com/users/flo","html_url":"https://github.com/flo","followers_url":"https://api.github.com/users/flo/followers","following_url":"https://api.github.com/users/flo/following{/other_user}","gists_url":"https://api.github.com/users/flo/gists{/gist_id}","starred_url":"https://api.github.com/users/flo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flo/subscriptions","organizations_url":"https://api.github.com/users/flo/orgs","repos_url":"https://api.github.com/users/flo/repos","events_url":"https://api.github.com/users/flo/events{/privacy}","received_events_url":"https://api.github.com/users/flo/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-10T21:09:00Z","updated_at":"2015-01-12T03:16:55Z","closed_at":"2015-01-12T03:14:02Z","pull_request":{"url":"https://api.github.com/repos/MovingBlocks/Terasology/pulls/1510","html_url":"https://github.com/MovingBlocks/Terasology/pull/1510","diff_url":"https://github.com/MovingBlocks/Terasology/pull/1510.diff","patch_url":"https://github.com/MovingBlocks/Terasology/pull/1510.patch"},"body":"This patch series fixes the spikes caused by the preperation for the autosave.\r\n\r\nMeasured times for autosave preparations of a game with a few modules on a perli noise world (1st, 2nd, 3ds save etc.):\r\n* Before: 415 ms, 210 ms, 107 ms, 98 ms, 88 ms, 82 ms, 81 ms, 81 ms ...\r\n* After: 10 ms, 2 ms, 2 ms, 2 ms ...\r\n\r\nWith autosave preperation I mean the amount of time spent on the main thread to prepare a autosave when it is time to do so. The total amount of time spend on the main thread per frame needs to be below 16ms. Since time is spend on game logic and rendering too, even times like 81ms will cause noticeable spikes. Thez may not be annoying but give you the indrect feeling that the game is struggling to run smooth.\r\n\r\nThe patch series archives this by doing the entity serialization not in the main thread, but later in the thread that stores the save game. This thread gets represented by the class SaveTransaction. This patch series gives the save transaction / the  storage manager (ReadWriteStorageManager) a private entity manager. This private entity manager gets updated by the saving thread via a entity set delta recorded as the entties got changed on the main thread.\r\n\r\nTo me it seems that are still things that could be done better, but I think this is a nice point to make a cut and merge it in."},"comment":{"url":"https://api.github.com/repos/MovingBlocks/Terasology/issues/comments/69526356","html_url":"https://github.com/MovingBlocks/Terasology/pull/1510#issuecomment-69526356","issue_url":"https://api.github.com/repos/MovingBlocks/Terasology/issues/1510","id":69526356,"user":{"login":"Cervator","id":1063833,"avatar_url":"https://avatars.githubusercontent.com/u/1063833?v=3","gravatar_id":"","url":"https://api.github.com/users/Cervator","html_url":"https://github.com/Cervator","followers_url":"https://api.github.com/users/Cervator/followers","following_url":"https://api.github.com/users/Cervator/following{/other_user}","gists_url":"https://api.github.com/users/Cervator/gists{/gist_id}","starred_url":"https://api.github.com/users/Cervator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cervator/subscriptions","organizations_url":"https://api.github.com/users/Cervator/orgs","repos_url":"https://api.github.com/users/Cervator/repos","events_url":"https://api.github.com/users/Cervator/events{/privacy}","received_events_url":"https://api.github.com/users/Cervator/received_events","type":"User","site_admin":false},"created_at":"2015-01-12T03:16:55Z","updated_at":"2015-01-12T03:16:55Z","body":"Tested around some both in single and multiplayer - no issues noted :-)\r\n\r\nI did spot what appears to be a pre-existing issue - could recreate without this PR. If I travel a ways from spawn (with hspeed in case it matters, just jumping far), enough for the spawn area to unload, then die and respawn with the spawn area reloading after piles of the usual \"unavailable chunk\" spam I get:\r\n\r\n```\r\n22:03:40.180 [main] ERROR o.t.l.debug.ChunkEventErrorLogger - Multiple loads of chunk (-2, -1, -2)\r\n22:03:40.231 [main] ERROR o.t.l.debug.ChunkEventErrorLogger - Multiple loads of chunk (1, -1, -3)\r\n22:03:40.481 [main] ERROR o.t.l.debug.ChunkEventErrorLogger - Multiple loads of chunk (0, 0, -4)\r\n```\r\n\r\nEtc. Doesn't seem to break anything, probably just inefficient with something needing tweaking.\r\n\r\nMerged - thanks! Yay for performance fixes :-)"}}