{"action":"created","issue":{"url":"https://api.github.com/repos/chapel-lang/chapel/issues/3264","repository_url":"https://api.github.com/repos/chapel-lang/chapel","labels_url":"https://api.github.com/repos/chapel-lang/chapel/issues/3264/labels{/name}","comments_url":"https://api.github.com/repos/chapel-lang/chapel/issues/3264/comments","events_url":"https://api.github.com/repos/chapel-lang/chapel/issues/3264/events","html_url":"https://github.com/chapel-lang/chapel/pull/3264","id":132488382,"number":3264,"title":"Add a mutex to our jemalloc chunk alloc hook","user":{"login":"ronawho","id":1588337,"avatar_url":"https://avatars.githubusercontent.com/u/1588337?v=3","gravatar_id":"","url":"https://api.github.com/users/ronawho","html_url":"https://github.com/ronawho","followers_url":"https://api.github.com/users/ronawho/followers","following_url":"https://api.github.com/users/ronawho/following{/other_user}","gists_url":"https://api.github.com/users/ronawho/gists{/gist_id}","starred_url":"https://api.github.com/users/ronawho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ronawho/subscriptions","organizations_url":"https://api.github.com/users/ronawho/orgs","repos_url":"https://api.github.com/users/ronawho/repos","events_url":"https://api.github.com/users/ronawho/events{/privacy}","received_events_url":"https://api.github.com/users/ronawho/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-02-09T17:59:41Z","updated_at":"2016-02-09T18:23:38Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/chapel-lang/chapel/pulls/3264","html_url":"https://github.com/chapel-lang/chapel/pull/3264","diff_url":"https://github.com/chapel-lang/chapel/pull/3264.diff","patch_url":"https://github.com/chapel-lang/chapel/pull/3264.patch"},"body":"It looks like our chunk_alloc might not be called inside a lock like I thought\r\nit was. This adds a simple mutex to protect getting the current pointer into\r\nthe shared heap. Note that the critical section (computing our current index\r\ninto the shared heap) will be very fast, so we shouldn't have much contention\r\non this lock (uncontended locks/unlocks happen in user-space and are fast)\r\n\r\nThis resolves the knucleotide regressions for gasnet-fast mentioned in #3252\r\n\r\nBenH provided the following reduced knucleotide-like test case that allowed me\r\nto track this down:\r\n\r\n```chapel\r\nproc calculate() {\r\n  var freqDom : domain(uint);\r\n  var freqs : [freqDom] int;\r\n  for i in 1..100000 do freqs[i:uint] += i;\r\n  return freqs;\r\n}\r\n\r\nproc main() {\r\n  var ret = calculate();\r\n  writeln(ret.size);\r\n}\r\n```\r\n\r\nWithout the lock this failed every ~3 runs, and with the lock it passed 10,000 trials"},"comment":{"url":"https://api.github.com/repos/chapel-lang/chapel/issues/comments/181991436","html_url":"https://github.com/chapel-lang/chapel/pull/3264#issuecomment-181991436","issue_url":"https://api.github.com/repos/chapel-lang/chapel/issues/3264","id":181991436,"user":{"login":"ronawho","id":1588337,"avatar_url":"https://avatars.githubusercontent.com/u/1588337?v=3","gravatar_id":"","url":"https://api.github.com/users/ronawho","html_url":"https://github.com/ronawho","followers_url":"https://api.github.com/users/ronawho/followers","following_url":"https://api.github.com/users/ronawho/following{/other_user}","gists_url":"https://api.github.com/users/ronawho/gists{/gist_id}","starred_url":"https://api.github.com/users/ronawho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ronawho/subscriptions","organizations_url":"https://api.github.com/users/ronawho/orgs","repos_url":"https://api.github.com/users/ronawho/repos","events_url":"https://api.github.com/users/ronawho/events{/privacy}","received_events_url":"https://api.github.com/users/ronawho/received_events","type":"User","site_admin":false},"created_at":"2016-02-09T18:23:38Z","updated_at":"2016-02-09T18:23:38Z","body":"Just double checking: you're ok with the static mutex init and always destroying it, even though we only need it for the shared heap case right?"}}