{"action":"created","issue":{"url":"https://api.github.com/repos/Amanieu/hashbrown/issues/30","repository_url":"https://api.github.com/repos/Amanieu/hashbrown","labels_url":"https://api.github.com/repos/Amanieu/hashbrown/issues/30/labels{/name}","comments_url":"https://api.github.com/repos/Amanieu/hashbrown/issues/30/comments","events_url":"https://api.github.com/repos/Amanieu/hashbrown/issues/30/events","html_url":"https://github.com/Amanieu/hashbrown/pull/30","id":382391560,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMyMTEwNzEz","number":30,"title":"Add Rayon support","user":{"login":"hcpl","id":17436405,"node_id":"MDQ6VXNlcjE3NDM2NDA1","avatar_url":"https://avatars3.githubusercontent.com/u/17436405?v=4","gravatar_id":"","url":"https://api.github.com/users/hcpl","html_url":"https://github.com/hcpl","followers_url":"https://api.github.com/users/hcpl/followers","following_url":"https://api.github.com/users/hcpl/following{/other_user}","gists_url":"https://api.github.com/users/hcpl/gists{/gist_id}","starred_url":"https://api.github.com/users/hcpl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hcpl/subscriptions","organizations_url":"https://api.github.com/users/hcpl/orgs","repos_url":"https://api.github.com/users/hcpl/repos","events_url":"https://api.github.com/users/hcpl/events{/privacy}","received_events_url":"https://api.github.com/users/hcpl/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-11-19T21:02:36Z","updated_at":"2018-11-30T14:13:54Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/Amanieu/hashbrown/pulls/30","html_url":"https://github.com/Amanieu/hashbrown/pull/30","diff_url":"https://github.com/Amanieu/hashbrown/pull/30.diff","patch_url":"https://github.com/Amanieu/hashbrown/pull/30.patch"},"body":"The code is adapted from `rayon-hash` to match the internal structure of SwissTables.\r\n\r\nCompared to `rayon-hash` this implementation adds an `impl Send` for `ParIter` and `Debug` impls for parallel iterators to mirror iterators from `std::collections::{hash_map, hash_set}` and `hashbrown::{hash_map, hash_set}`.\r\n\r\nThe tests pass right now, but there are a couple of questions/potential improvements I would like to see resolved before merging --- mostly about correctness of everything in `external_crate_impls::rayon::raw`.\r\n\r\nI tried to reduce usage of unsafe code from the beginning, so the only unsafe operations left are checking & setting bucket emptiness, getting references & values from buckets, setting `RawTable.items` field and manual impls of `Send`:\r\n- I ended up writing a custom iterator over non-empty buckets in a raw table to emulate the approach from `rayon-hash`. Should I have reused `RawIter` and `RawIntoIter` instead?\r\n- Manual `Send` impls. I have zero experience doing this, so I had to make some guesses based on `Send` and `Sync` docs + `rayon-hash` code.\r\n  From what I could gather, any (only parallel? or sequential too?) iterator should `impl Send` iff:\r\n  + Values the iterator returns immutable/shared references of are `Sync`.\r\n  + Values the iterator returns mutable/unique references of are `Send`.\r\n  + Values the iterator returns directly (by-value) are `Send`.\r\n  E.g. `ParIterMut<'a, K, V>` is an `Iterator<Item = (&'a K, &'a mut V)>`, so the impl is\r\n  ```rust\r\n  unsafe impl<'a, K: Sync, V: Send> Send for ParIterMut<'a, K, V> {}\r\n  ```\r\n- `IntoParIter` relies on a sequence of events to work and I'm not sure if doing so is memory-safe/non-UB:\r\n  + Set `RawTable.items` to 0 without doing any cleanup.\r\n  + Iterate over all non-empty buckets. While doing so, set their control bytes to `EMPTY` and also read the value to pass to the folder.\r\n  + Rely on the default `Drop` impl for `IntoParIter` which will drop the inner table.\r\n\r\nThe point about manual `Send` impls is also applicable for `HashSet` parallel iterators.\r\n\r\ncc @cuviper"},"comment":{"url":"https://api.github.com/repos/Amanieu/hashbrown/issues/comments/443215344","html_url":"https://github.com/Amanieu/hashbrown/pull/30#issuecomment-443215344","issue_url":"https://api.github.com/repos/Amanieu/hashbrown/issues/30","id":443215344,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MzIxNTM0NA==","user":{"login":"Amanieu","id":278509,"node_id":"MDQ6VXNlcjI3ODUwOQ==","avatar_url":"https://avatars0.githubusercontent.com/u/278509?v=4","gravatar_id":"","url":"https://api.github.com/users/Amanieu","html_url":"https://github.com/Amanieu","followers_url":"https://api.github.com/users/Amanieu/followers","following_url":"https://api.github.com/users/Amanieu/following{/other_user}","gists_url":"https://api.github.com/users/Amanieu/gists{/gist_id}","starred_url":"https://api.github.com/users/Amanieu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Amanieu/subscriptions","organizations_url":"https://api.github.com/users/Amanieu/orgs","repos_url":"https://api.github.com/users/Amanieu/repos","events_url":"https://api.github.com/users/Amanieu/events{/privacy}","received_events_url":"https://api.github.com/users/Amanieu/received_events","type":"User","site_admin":false},"created_at":"2018-11-30T14:13:54Z","updated_at":"2018-11-30T14:13:54Z","author_association":"OWNER","body":"Are you still working on this PR?"}}
{"actor":{"display_login":"Amanieu"}}