{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/10317","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/10317/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/10317/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/10317/events","html_url":"https://github.com/JuliaLang/julia/issues/10317","id":58825519,"number":10317,"title":"Making Generational GC Thread-Safe","user":{"login":"ArchRobison","id":2983330,"avatar_url":"https://avatars.githubusercontent.com/u/2983330?v=3","gravatar_id":"","url":"https://api.github.com/users/ArchRobison","html_url":"https://github.com/ArchRobison","followers_url":"https://api.github.com/users/ArchRobison/followers","following_url":"https://api.github.com/users/ArchRobison/following{/other_user}","gists_url":"https://api.github.com/users/ArchRobison/gists{/gist_id}","starred_url":"https://api.github.com/users/ArchRobison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArchRobison/subscriptions","organizations_url":"https://api.github.com/users/ArchRobison/orgs","repos_url":"https://api.github.com/users/ArchRobison/repos","events_url":"https://api.github.com/users/ArchRobison/events{/privacy}","received_events_url":"https://api.github.com/users/ArchRobison/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/JuliaLang/julia/labels/multi-threading","name":"multi-threading","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/JuliaLang/julia/milestones/11","html_url":"https://github.com/JuliaLang/julia/milestones/0.4","labels_url":"https://api.github.com/repos/JuliaLang/julia/milestones/11/labels","id":748886,"number":11,"title":"0.4","description":"For tracking release-defining items for 0.4: important new features, breaking changes, and blocking bugs.\r\n\r\nAfter a brief period for deciding scope, adding issues to this milestone is not allowed. Once the items in this milestone are done, 0.4 will enter its stabilizing period and a release candidate can be made soon after.","creator":{"login":"JeffBezanson","id":744556,"avatar_url":"https://avatars.githubusercontent.com/u/744556?v=3","gravatar_id":"","url":"https://api.github.com/users/JeffBezanson","html_url":"https://github.com/JeffBezanson","followers_url":"https://api.github.com/users/JeffBezanson/followers","following_url":"https://api.github.com/users/JeffBezanson/following{/other_user}","gists_url":"https://api.github.com/users/JeffBezanson/gists{/gist_id}","starred_url":"https://api.github.com/users/JeffBezanson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JeffBezanson/subscriptions","organizations_url":"https://api.github.com/users/JeffBezanson/orgs","repos_url":"https://api.github.com/users/JeffBezanson/repos","events_url":"https://api.github.com/users/JeffBezanson/events{/privacy}","received_events_url":"https://api.github.com/users/JeffBezanson/received_events","type":"User","site_admin":false},"open_issues":31,"closed_issues":17,"state":"open","created_at":"2014-08-10T18:13:46Z","updated_at":"2015-03-06T14:44:02Z","due_on":"2015-01-30T05:00:00Z","closed_at":null},"comments":15,"created_at":"2015-02-24T23:41:58Z","updated_at":"2015-03-06T15:31:54Z","closed_at":null,"body":"This issue is for discussing how to make the new GC (#8699) thread-safe.  A GC expert should check the arguments here.  For background, see the elegant state transition diagram in [`src/gc.c`](https://github.com/JuliaLang/julia/blob/master/src/gc.c#L216).\r\n\r\nI'm assuming that garbage collection operates in stop-the-world mode, and for now, that the mark/sweep phase is single-threaded.  Each thread can have its own thread-local `remset`, with occasional duplication across the sets because of the race described below.\r\n\r\n**Key question**: what state transitions can race against each other?  If I understand the GC correctly, the only racy transitions  arise from a write barrier for the same parent, and that transition is `GC_MARKED --> GC_QUEUED`, which changes the low two bits of the memory location from 01 to 10.  If this is indeed the only racy transition, then a plain load, modify, plain store sequence will suffice, since all racing participants will be attempting to write the same value to the location.   To be portable C11, we should use relaxed atomic loads/stores instead of the current assignments into bitfields, but that's a purist nitpick.\r\n\r\nThe possibility of a race will require lightening up on assertions that check for duplicate enqueuing of roots.  There will need to be a `memory_order_acq_rel` fence between normal operation and garbage collection, but that's probably already implied by synchronization between normal operation and garbage collection.\r\n\r\n**Possible problem**: `gc_wb_buf` appears to engaging in other transitions.  If so, which of these might race against each other?  Are these transitions always on different `gc_bits` than the ones affected by `gc_wb`? "},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/77577650","html_url":"https://github.com/JuliaLang/julia/issues/10317#issuecomment-77577650","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/10317","id":77577650,"user":{"login":"ViralBShah","id":744411,"avatar_url":"https://avatars.githubusercontent.com/u/744411?v=3","gravatar_id":"","url":"https://api.github.com/users/ViralBShah","html_url":"https://github.com/ViralBShah","followers_url":"https://api.github.com/users/ViralBShah/followers","following_url":"https://api.github.com/users/ViralBShah/following{/other_user}","gists_url":"https://api.github.com/users/ViralBShah/gists{/gist_id}","starred_url":"https://api.github.com/users/ViralBShah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ViralBShah/subscriptions","organizations_url":"https://api.github.com/users/ViralBShah/orgs","repos_url":"https://api.github.com/users/ViralBShah/repos","events_url":"https://api.github.com/users/ViralBShah/events{/privacy}","received_events_url":"https://api.github.com/users/ViralBShah/received_events","type":"User","site_admin":false},"created_at":"2015-03-06T15:31:54Z","updated_at":"2015-03-06T15:31:54Z","body":"See the thread safety tracker in #10421"}}