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

Benchmark with array access very slow when done on main. OSR issue? #16976

Open
DartBot opened this issue Feb 20, 2014 · 3 comments
Open

Benchmark with array access very slow when done on main. OSR issue? #16976

DartBot opened this issue Feb 20, 2014 · 3 comments
Labels
area-vm type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@DartBot
Copy link

DartBot commented Feb 20, 2014

This issue was originally filed by @mdakin


Following code runs in ~1500ms on my machine, If I move the loops into a function and call it it is much faster ~90ms. This looks like an issue related to OSR. If I use rnd.length instead of rs in the inner loop limit, it is even slower ~2500ms.

Dart SDK version 1.2.0-dev.5.11, Unchecked mode.

import "dart:typed_data";
import "dart:math";
 
void main() {
  int rs = 1 << 20;
  int iter = 50;
  Float64List rnd = new Float64List(rs);
  Random r = new Random(1);
  for (int i = 0; i < rs; i++) {
    rnd[i] = r.nextDouble() * PI;
  }
 
  Stopwatch sw = new Stopwatch();
  sw.start();
  double total = 0.0;
  for (int j = 0; j < iter; j++) {
    for (int i = 0; i < rs; i++) {
      total += rnd[i];
    }
  }
  var e = sw.elapsedMilliseconds;
  print("Time: $e");
}

@DartBot
Copy link
Author

DartBot commented Feb 20, 2014

This comment was originally written by @ahmetaa


After moving contents to a function, only in the second call it runs faster in stable version.

Dart Editor version 1.1.3.release (STABLE)
Dart SDK version 1.1.3

@fsc8000
Copy link
Contributor

fsc8000 commented Feb 20, 2014

Added Area-VM, Triaged labels.

@fsc8000
Copy link
Contributor

fsc8000 commented Feb 20, 2014

I diagnosed the issue and the problem is that the current OSR support does not work well if a function contains multiple loops like the example: OSR is never triggered the second time, but it should be.


Set owner to @fsc8000.
Added Accepted label.

@kevmoo kevmoo added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed priority-unassigned labels Feb 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

3 participants