{"action":"created","issue":{"url":"https://api.github.com/repos/amethyst/amethyst/issues/10","repository_url":"https://api.github.com/repos/amethyst/amethyst","labels_url":"https://api.github.com/repos/amethyst/amethyst/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/amethyst/amethyst/issues/10/comments","events_url":"https://api.github.com/repos/amethyst/amethyst/issues/10/events","html_url":"https://github.com/amethyst/amethyst/issues/10","id":127335555,"number":10,"title":"Implement thread-safe ECS","user":{"login":"ebkalderon","id":322831,"avatar_url":"https://avatars.githubusercontent.com/u/322831?v=3","gravatar_id":"","url":"https://api.github.com/users/ebkalderon","html_url":"https://github.com/ebkalderon","followers_url":"https://api.github.com/users/ebkalderon/followers","following_url":"https://api.github.com/users/ebkalderon/following{/other_user}","gists_url":"https://api.github.com/users/ebkalderon/gists{/gist_id}","starred_url":"https://api.github.com/users/ebkalderon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebkalderon/subscriptions","organizations_url":"https://api.github.com/users/ebkalderon/orgs","repos_url":"https://api.github.com/users/ebkalderon/repos","events_url":"https://api.github.com/users/ebkalderon/events{/privacy}","received_events_url":"https://api.github.com/users/ebkalderon/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/amethyst/amethyst/labels/diff:%20medium","name":"diff: medium","color":"fef2c0"},{"url":"https://api.github.com/repos/amethyst/amethyst/labels/pri:%20critical","name":"pri: critical","color":"f7c6c7"},{"url":"https://api.github.com/repos/amethyst/amethyst/labels/status:%20in-progress","name":"status: in-progress","color":"bfe5bf"},{"url":"https://api.github.com/repos/amethyst/amethyst/labels/type:%20feature","name":"type: feature","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/amethyst/amethyst/milestones/1","html_url":"https://github.com/amethyst/amethyst/milestones/1.0","labels_url":"https://api.github.com/repos/amethyst/amethyst/milestones/1/labels","id":1480348,"number":1,"title":"1.0","description":null,"creator":{"login":"ebkalderon","id":322831,"avatar_url":"https://avatars.githubusercontent.com/u/322831?v=3","gravatar_id":"","url":"https://api.github.com/users/ebkalderon","html_url":"https://github.com/ebkalderon","followers_url":"https://api.github.com/users/ebkalderon/followers","following_url":"https://api.github.com/users/ebkalderon/following{/other_user}","gists_url":"https://api.github.com/users/ebkalderon/gists{/gist_id}","starred_url":"https://api.github.com/users/ebkalderon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebkalderon/subscriptions","organizations_url":"https://api.github.com/users/ebkalderon/orgs","repos_url":"https://api.github.com/users/ebkalderon/repos","events_url":"https://api.github.com/users/ebkalderon/events{/privacy}","received_events_url":"https://api.github.com/users/ebkalderon/received_events","type":"User","site_admin":false},"open_issues":9,"closed_issues":6,"state":"open","created_at":"2016-01-02T11:23:56Z","updated_at":"2016-03-14T17:50:34Z","due_on":null,"closed_at":null},"comments":43,"created_at":"2016-01-19T00:01:42Z","updated_at":"2016-03-24T15:50:33Z","closed_at":null,"body":"With game state management mostly stable, the next step is to implement an entity-component-system framework in the engine. This framework must follow the [pure ECS model](http://shaneenishry.com/blog/2014/12/27/misconceptions-of-component-based-entity-systems/), in which entities are just IDs and components are POD structs.\r\n\r\nThough the ECS model is extremely flexible and easy to data-drive, it has its shortcomings:\r\n\r\n* Difficult to cache important data\r\n* Difficult to parallelize, heavy reliance on mutable state\r\n\r\nIn [a useful Reddit post](https://www.reddit.com/r/rust/comments/415a1x/github_ebkalderonamethyst_dataoriented_game/cz0dgf1), tomaka describes an alternative model similar to MVC with some parallelism. I propose a combination of the two designs resulting in a thread-safe ECS.\r\n\r\n(Quoted from the [other announcements section in *TWIA* Issue 1](https://thisweekinamethyst.wordpress.com/2016/01/18/this-week-in-amethyst-1/))\r\n\r\nClearly, the World struct containing our entities and components is analogous to the model in MVC. But systems typically require mutable state even for strictly read-only operations, so they don’t fit into either views or controllers, nor are they easy to parallelize.\r\n\r\nHowever, there are two possible ways to remedy this issue.\r\n\r\n1. Systems are split into two separate traits: Updaters and Viewers. The Viewers only require read access to the World, so they can run in parallel. Updaters request mutable access to the World and submit a list of changes they want to make to the content. These changes are applied serially according to a predetermined priority.\r\n2. Systems are kept as one unit (perhaps renamed to “Processors” for clarity), and they all read the World struct in parallel but can optionally submit changes to the World, which are applied serially once everyone has finished reading.\r\n\r\nExperiments are ongoing on the [ecs branch](https://github.com/ebkalderon/amethyst/tree/ecs/src/ecs)."},"comment":{"url":"https://api.github.com/repos/amethyst/amethyst/issues/comments/200897185","html_url":"https://github.com/amethyst/amethyst/issues/10#issuecomment-200897185","issue_url":"https://api.github.com/repos/amethyst/amethyst/issues/10","id":200897185,"user":{"login":"kvark","id":107301,"avatar_url":"https://avatars.githubusercontent.com/u/107301?v=3","gravatar_id":"","url":"https://api.github.com/users/kvark","html_url":"https://github.com/kvark","followers_url":"https://api.github.com/users/kvark/followers","following_url":"https://api.github.com/users/kvark/following{/other_user}","gists_url":"https://api.github.com/users/kvark/gists{/gist_id}","starred_url":"https://api.github.com/users/kvark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kvark/subscriptions","organizations_url":"https://api.github.com/users/kvark/orgs","repos_url":"https://api.github.com/users/kvark/repos","events_url":"https://api.github.com/users/kvark/events{/privacy}","received_events_url":"https://api.github.com/users/kvark/received_events","type":"User","site_admin":false},"created_at":"2016-03-24T15:50:33Z","updated_at":"2016-03-24T15:50:33Z","body":"Found this GDC talk at Vulkan session: https://youtu.be/xXyZ4YaktyU?t=5005\r\nIt's about Nitrous engine, and they are using message-based communication between jobs. This doesn't really have much to do with ECS, but it does support @OvermindDL1 approach."}}