Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random number generator is unbelievably bad. #499

Closed
whesse opened this issue Nov 17, 2011 · 19 comments
Closed

Random number generator is unbelievably bad. #499

whesse opened this issue Nov 17, 2011 · 19 comments
Assignees
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-isolate P1 A high priority bug; for example, a single project is unusable or has many test failures

Comments

@whesse
Copy link
Contributor

whesse commented Nov 17, 2011

The Dart VM pseudorandom number generator is very very bad. It generates
approximately one pseudorandom bit per call. The bits of consecutive random numbers are almost all the same, just shifted. We should copy the V8 random number generator, or some other one that works better. Here is the output of printing consecutive random numbers, in binary, followed by the code that does so:

                 100100000000011
     100100000000010010000000001
     110110000000001001000000000
     111111000000000100100000000
      11111100000000010010000000
     101011110000000001001000000
     110001111000000000100011111
      11000111100000000010001111
       1100011110000000001000111
        110001111000000000100011
         11000111100000000010001
          1100011110000000001000
           110001111000000000100
            11000111100000000010
             1100011110000000001
              110001111000000000
     100100000011000111100000000
      10010000001100011110000000
       1001000000110001111000000
     100000100000011000111011111
      10000010000001100011101111
       1000001000000110001110111
        100000100000011000111011
         10000010000001100011101
          1000001000000110001110
           100000100000011000111
            10000010000001100011
             1000001000000110001
              100000100000011000
     100100000010000010000001100
     110110000001000001000000110
     111111000000100000100000011
     111011100000010000010000001
      11101110000001000001000000
       1110111000000100000100000
        111011100000010000010000
     100111101110000001000001000
     110111110111000000100000011
      11011111011100000010000001
       1101111101110000001000000
        110111110111000000100000
         11011111011100000010000

void main() {
  for (var i=0 ; i < 100 ; ++i) {
    var binary = (Math.random() * 0x8000000).toInt().toRadixString(2);
    while (binary.length < 32) {
      binary = " " + binary;
    }
    print(binary);
  }
}

@iposva-google
Copy link
Contributor

Set owner to @iposva-google.

@DartBot
Copy link

DartBot commented Nov 17, 2011

This comment was originally written by drfibonacci@google.com


Added Triaged label.

@iposva-google
Copy link
Contributor

Added Accepted label.

@DartBot
Copy link

DartBot commented Nov 22, 2011

This comment was originally written by whessedk...@gmail.com


The V8 PNG is pretty good - I worked on it recently. I would recommend it. The question of how to seed Isolates, so they aren't predictable, and how to replay with a predictable seed, for testing, should also be addressed.

@DartBot
Copy link

DartBot commented Dec 9, 2011

This comment was originally written by drfibonacci@google.com


Issue #771 has been merged into this issue.

@DartBot
Copy link

DartBot commented Dec 9, 2011

This comment was originally written by drfibonacci@google.com


Issue #245 has been merged into this issue.

@floitschG
Copy link
Contributor

Issue #1983 might be another duplicate.

@whesse
Copy link
Contributor Author

whesse commented Mar 5, 2012

Issue #1983 has been merged into this issue.

@DartBot
Copy link

DartBot commented Mar 21, 2012

This comment was originally written by kmagnu...@gmail.com


@whess ... seeding the built-in random number generator should not be allowed... this ends up reducing flexibility of implementation. Code needing deterministic numbers for testing should accept a random number generator as an input. This dependency injection will allow you to get a deterministic sequence without locking the language implementation into a given PRNG.

@sethladd
Copy link
Contributor

FYI this came up on the mailing list again today: https://groups.google.com/a/dartlang.org/group/misc/browse_thread/thread/b872ef7b23c03237#

@jmesserly
Copy link

upping to high pri ... this breaks just about every app that tries to do simulation ... physics, games, etc :)


Removed Priority-Medium label.
Added Priority-High label.

@dgrove
Copy link
Contributor

dgrove commented Apr 29, 2012

Issue #2805 has been merged into this issue.

@iposva-google
Copy link
Contributor

Sorry, I should have marked this as started as of about a week ago. We had been evaluating different approaches and I expect to have something ready in about a week.


Added Started label.

@DartBot
Copy link

DartBot commented May 12, 2012

This comment was originally written by dave.sno...@gmail.com


This just happened to me in the hackathon.

@sigmundch
Copy link
Member

Added Isolates label.

@DartBot
Copy link

DartBot commented May 19, 2012

This comment was originally written by rev...@gmail.com


Any progress? First thing I tried in Dart was random and .. well.. not so much.

@floitschG
Copy link
Contributor

Ivan uploaded a CL for review: https://chromiumcodereview.appspot.com/10389150/
I expect it to land next week.

@whesse
Copy link
Contributor Author

whesse commented Jun 11, 2012

Issue #3463 has been merged into this issue.

@DartBot
Copy link

DartBot commented Jun 25, 2012

This comment was originally written by dha...@google.com


I have a Mersenne twister implementation, if it would help anyone. (Copyright restrictions mean that I can contribute it to Dart easily but would require additional time to submit elsewhere.) I still need to do some testing on it to make sure it's compliant -- I was able to find a test sequence for the 64-bit variant but not for the 32-bit variant.

@whesse whesse added Type-Defect P1 A high priority bug; for example, a single project is unusable or has many test failures area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. labels Jun 25, 2012
@nex3 nex3 added area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-isolate and removed area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. labels Jun 8, 2015
nex3 pushed a commit that referenced this issue Aug 31, 2016
dart-bot pushed a commit that referenced this issue Feb 22, 2018
See angular issue #499 for a stack trace. When autocompleting a member
on dynamic, the member contributor checks to find a member definition
higher up in the tree that should lead to specific members to suggest.

However, in the angular plugin, the ASTs passed in are often fragments.
Account for the case where a node has no parent earlier than expected.

Change-Id: Ib30d9f1aef77241224f604c5994489aa9448b0c2
Reviewed-on: https://dart-review.googlesource.com/42884
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
copybara-service bot pushed a commit that referenced this issue Feb 8, 2023
dartdoc:
494a6bed  2023-02-02  Sam Rawlins  Bump markdown dep to a pre-release of 7.0.0 (#3321)
ad6f1612  2023-02-02  Devon Carew  introduce an environmentProvider abstraction (#3324)
d0b73000  2023-02-02  Sam Rawlins  Prepare testing code for some upcoming Warnings (#3322)
936a7888  2023-02-01  Sam Rawlins  Add text about front-end manual testing (#3286)
cbee812d  2023-02-01  Sam Rawlins  Avoid renaming generator params (#3316)
bcaa0349  2023-02-01  Sam Rawlins  Privatize Library.sdkLib and move getClassByName (#3317)
af32def5  2023-01-31  dependabot[bot]  Bump github/codeql-action from 2.1.39 to 2.2.1 (#3313)
528e97da  2023-01-31  dependabot[bot]  Bump actions/cache from 3.2.3 to 3.2.4 (#3312)
54020672  2023-02-01  Parker Lougheed  Begin changelog for next release after 6.1.5 (#3315)

markdown:
f51c24c  2023-02-01  Zhiguang Chen  Prepend a line ending if the p tag is removed and there is an element before it in a *tight* list (#513)
dd3e3a1  2023-01-31  dependabot[bot]  Bump dart-lang/setup-dart from 1.3 to 1.4 (#510)
5f25fc9  2023-01-31  dependabot[bot]  Bump actions/checkout from 3.2.0 to 3.3.0 (#511)
54266b2  2023-01-31  Kevin Moore  Prepare to release v7.0.0 (#509)
d6ceff9  2023-01-31  Zhiguang Chen  Add line endings before HTML blocks (#508)
ccd3c8b  2023-01-29  Zhiguang Chen  Rewrite link reference definitions (#506)
e8f84dc  2023-01-24  Kevin Moore  Update GFM to 0.29.0.gfm.7 (#507)
93f67b0  2023-01-20  Zhiguang Chen  Add an `enableTagfilter` option to `HtmlRenderer` to eanble GFM `tagfilter` extension (#447)
d110770  2023-01-13  Zhiguang Chen  Rewrite SetextHeaderSyntax (#500)
c1b9bc6  2023-01-09  Sam Rawlins  Migrate from no-implicit-casts to strict-casts (#504)
3e78c08  2023-01-01  dependabot[bot]  Bump actions/checkout from 3.0.2 to 3.2.0 (#501)
417747f  2022-12-15  Zhiguang Chen  Refactor list syntax (#499)
30ec05f  2022-11-29  Zhiguang Chen  Do not escape single quote(apostrophe) inside code (#498)
c3d1136  2022-11-29  Zhiguang Chen  introduce a Line class (#494)
Change-Id: I9d971b927b72500ab84cce461a60fe1a86818e2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281543
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-isolate P1 A high priority bug; for example, a single project is unusable or has many test failures
Projects
None yet
Development

No branches or pull requests

9 participants