{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang-nursery/rand/issues/554","repository_url":"https://api.github.com/repos/rust-lang-nursery/rand","labels_url":"https://api.github.com/repos/rust-lang-nursery/rand/issues/554/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang-nursery/rand/issues/554/comments","events_url":"https://api.github.com/repos/rust-lang-nursery/rand/issues/554/events","html_url":"https://github.com/rust-lang-nursery/rand/pull/554","id":341232636,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAxNDQ5NjQ1","number":554,"title":"Universal seeder","user":{"login":"dhardy","id":134893,"node_id":"MDQ6VXNlcjEzNDg5Mw==","avatar_url":"https://avatars1.githubusercontent.com/u/134893?v=4","gravatar_id":"","url":"https://api.github.com/users/dhardy","html_url":"https://github.com/dhardy","followers_url":"https://api.github.com/users/dhardy/followers","following_url":"https://api.github.com/users/dhardy/following{/other_user}","gists_url":"https://api.github.com/users/dhardy/gists{/gist_id}","starred_url":"https://api.github.com/users/dhardy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhardy/subscriptions","organizations_url":"https://api.github.com/users/dhardy/orgs","repos_url":"https://api.github.com/users/dhardy/repos","events_url":"https://api.github.com/users/dhardy/events{/privacy}","received_events_url":"https://api.github.com/users/dhardy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-07-14T12:22:09Z","updated_at":"2018-07-15T08:07:26Z","closed_at":null,"author_association":"COLLABORATOR","pull_request":{"url":"https://api.github.com/repos/rust-lang-nursery/rand/pulls/554","html_url":"https://github.com/rust-lang-nursery/rand/pull/554","diff_url":"https://github.com/rust-lang-nursery/rand/pull/554.diff","patch_url":"https://github.com/rust-lang-nursery/rand/pull/554.patch"},"body":"This is much more powerful than `seed_from_u64` (#537).\r\n\r\n```rust\r\nlet mut rng = Seeder::from(\"stripy zebra\").make_rng::<XorShiftRng>()\r\n```\r\n\r\nSipHash is a keyed hash function optimised for speed on short messages. I adapted this to support unlimited length output with `SipRng`.\r\n\r\nQuality should be roughly crypto-grade, though I haven't attempted any kind of crypto-analysis and would not like to bet on the strength without at least some further review.\r\n\r\nUnsurprisingly, PractRand hasn't picked up any issues (two \"unusual\" items under 64 GiB on this run, none up to 128 GiB with a slightly different construction).\r\n\r\nPerformance is reasonable though of course not close to fast RNGs (I didn't bother using caching for `next_u32` here; for seeding at least it's not useful):\r\n```\r\ntest gen_bytes_sip         ... bench:     701,138 ns/iter (+/- 15,817) = 1460 MB/s\r\ntest gen_u32_sip           ... bench:       5,167 ns/iter (+/- 145) = 774 MB/s\r\ntest gen_u64_sip           ... bench:       5,212 ns/iter (+/- 98) = 1534 MB/s\r\ntest init_sip              ... bench:          25 ns/iter (+/- 1)\r\n# for comparison:\r\ntest gen_bytes_hc128       ... bench:     448,607 ns/iter (+/- 35,948) = 2282 MB/s\r\ntest gen_u32_hc128         ... bench:       2,196 ns/iter (+/- 214) = 1821 MB/s\r\ntest gen_u64_hc128         ... bench:       3,938 ns/iter (+/- 240) = 2031 MB/s\r\ntest init_hc128            ... bench:       4,863 ns/iter (+/- 382)\r\ntest gen_bytes_xorshift    ... bench:     298,913 ns/iter (+/- 8,830) = 3425 MB/s\r\ntest gen_u32_xorshift      ... bench:       1,206 ns/iter (+/- 54) = 3316 MB/s\r\ntest gen_u64_xorshift      ... bench:       1,804 ns/iter (+/- 107) = 4434 MB/s\r\ntest init_xorshift         ... bench:          13 ns/iter (+/- 0)\r\n```\r\nFor the intended usage, seeding other RNGs, this performance is perfectly adequate.\r\n\r\nNote that the `Seeder` type is mostly for convenience. We could just recommend using `from_rng`, *except* that this method is currently documented as not being value-stable (which thus defeats the whole point of this code).\r\n\r\nI may still make some tweaks to this, but so far it looks quite nice to me. Comments welcome."},"comment":{"url":"https://api.github.com/repos/rust-lang-nursery/rand/issues/comments/405074844","html_url":"https://github.com/rust-lang-nursery/rand/pull/554#issuecomment-405074844","issue_url":"https://api.github.com/repos/rust-lang-nursery/rand/issues/554","id":405074844,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNTA3NDg0NA==","user":{"login":"dhardy","id":134893,"node_id":"MDQ6VXNlcjEzNDg5Mw==","avatar_url":"https://avatars1.githubusercontent.com/u/134893?v=4","gravatar_id":"","url":"https://api.github.com/users/dhardy","html_url":"https://github.com/dhardy","followers_url":"https://api.github.com/users/dhardy/followers","following_url":"https://api.github.com/users/dhardy/following{/other_user}","gists_url":"https://api.github.com/users/dhardy/gists{/gist_id}","starred_url":"https://api.github.com/users/dhardy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhardy/subscriptions","organizations_url":"https://api.github.com/users/dhardy/orgs","repos_url":"https://api.github.com/users/dhardy/repos","events_url":"https://api.github.com/users/dhardy/events{/privacy}","received_events_url":"https://api.github.com/users/dhardy/received_events","type":"User","site_admin":false},"created_at":"2018-07-15T08:07:26Z","updated_at":"2018-07-15T08:07:26Z","author_association":"COLLABORATOR","body":"This proves there are no stupid mistakes, I guess. No surprises really:\r\n```\r\n~/rust/rand/rand_sip$ ../target/release/examples/cat | practrand stdin64\r\nRNG_test using PractRand version 0.93\r\nRNG = RNG_stdin64, seed = 0xf050c744\r\ntest set = normal, folding = standard (64 bit)\r\n\r\nrng=RNG_stdin64, seed=0xf050c744\r\nlength= 256 megabytes (2^28 bytes), time= 3.4 seconds\r\n  no anomalies in 159 test result(s)\r\n\r\nrng=RNG_stdin64, seed=0xf050c744\r\nlength= 512 megabytes (2^29 bytes), time= 7.1 seconds\r\n  no anomalies in 169 test result(s)\r\n\r\nrng=RNG_stdin64, seed=0xf050c744\r\nlength= 1 gigabyte (2^30 bytes), time= 14.3 seconds\r\n  no anomalies in 180 test result(s)\r\n\r\nrng=RNG_stdin64, seed=0xf050c744\r\nlength= 2 gigabytes (2^31 bytes), time= 28.0 seconds\r\n  no anomalies in 191 test result(s)\r\n\r\nrng=RNG_stdin64, seed=0xf050c744\r\nlength= 4 gigabytes (2^32 bytes), time= 55.7 seconds\r\n  no anomalies in 201 test result(s)\r\n\r\nrng=RNG_stdin64, seed=0xf050c744\r\nlength= 8 gigabytes (2^33 bytes), time= 110 seconds\r\n  no anomalies in 212 test result(s)\r\n\r\nrng=RNG_stdin64, seed=0xf050c744\r\nlength= 16 gigabytes (2^34 bytes), time= 217 seconds\r\n  Test Name                         Raw       Processed     Evaluation\r\n  [Low16/64]FPF-14+6/16:cross       R=  +3.9  p =  1.1e-3   unusual          \r\n  ...and 222 test result(s) without anomalies\r\n\r\nrng=RNG_stdin64, seed=0xf050c744\r\nlength= 32 gigabytes (2^35 bytes), time= 428 seconds\r\n  Test Name                         Raw       Processed     Evaluation\r\n  [Low1/64]BCFN(2+0,13-1,T)         R=  -7.0  p =1-1.3e-3   unusual          \r\n  ...and 232 test result(s) without anomalies\r\n\r\nrng=RNG_stdin64, seed=0xf050c744\r\nlength= 64 gigabytes (2^36 bytes), time= 855 seconds\r\n  no anomalies in 244 test result(s)\r\n\r\nrng=RNG_stdin64, seed=0xf050c744\r\nlength= 128 gigabytes (2^37 bytes), time= 8532 seconds\r\n  no anomalies in 255 test result(s)\r\n\r\nrng=RNG_stdin64, seed=0xf050c744\r\nlength= 256 gigabytes (2^38 bytes), time= 10195 seconds\r\n  Test Name                         Raw       Processed     Evaluation\r\n  [Low4/64]BCFN(2+2,13-0,T)         R=  +8.0  p =  8.6e-4   unusual          \r\n  ...and 264 test result(s) without anomalies\r\n\r\nrng=RNG_stdin64, seed=0xf050c744\r\nlength= 512 gigabytes (2^39 bytes), time= 13601 seconds\r\n  no anomalies in 276 test result(s)\r\n\r\nrng=RNG_stdin64, seed=0xf050c744\r\nlength= 1 terabyte (2^40 bytes), time= 20634 seconds                                                                                   \r\n  no anomalies in 287 test result(s)                                                                                                   \r\n                                                                                                                                       \r\nrng=RNG_stdin64, seed=0xf050c744                                                                                                       \r\nlength= 2 terabytes (2^41 bytes), time= 34936 seconds                                                                                  \r\n  no anomalies in 297 test result(s)                                                                                                   \r\n                                                                                                                                       \r\nrng=RNG_stdin64, seed=0xf050c744                                                                                                       \r\nlength= 4 terabytes (2^42 bytes), time= 61827 seconds                                                                                  \r\n  no anomalies in 308 test result(s)                                                                                                   \r\n```"}}
{"actor":{"display_login":"dhardy"}}