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

InlineByteArrayBaseStore generates CheckSmi operations for certain write sizes #39236

Closed
mraleph opened this issue Nov 5, 2019 · 1 comment
Closed
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-performance Issue relates to performance or code size

Comments

@mraleph
Copy link
Member

mraleph commented Nov 5, 2019

This completely destroys performance in the AOT mode if compiler can't prove that operand is in fact a Smi.

Furthermore this is completely unnecessary because our unboxing should be able to handle both Smi and Mint cases.

Example:

import 'dart:typed_data';

const SIZE = 10 * 1024 * 1024;

@pragma('vm:never-inline')
void ok() {
  final buffer = ByteData(SIZE);
  int value = 0;
  for (var i = 0; i < buffer.lengthInBytes; i += 8) {
    buffer.setInt8(i, value++ & 0xFF);
  }
}

@pragma('vm:never-inline')
void fail() {
  final buffer = ByteData(SIZE);
  int value = 0;
  for (var i = 0; i < buffer.lengthInBytes; i += 8) {
    buffer.setInt8(i, value++);
  }
}

void measure(String name, void Function() cb) {
  final sw = Stopwatch()..start();
  cb();
  print('$name took ${sw.elapsedMilliseconds} ms.');
}


void main() {
  measure('value is known to be smi', ok);
  measure('value is not known to be smi', fail);
}
$ pkg/vm/tool/precompiler2 benchmark.dart benchmark.snap
$ out/ReleaseX64/dart_precompiled_runtime /tmp/bench.snap
value is known to be smi took 9 ms.
value is not known to be smi took 127 ms.

/cc @mkustermann

@mraleph mraleph added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-performance Issue relates to performance or code size labels Nov 5, 2019
@mkustermann
Copy link
Member

@sjindel-google Can you look at this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-performance Issue relates to performance or code size
Projects
None yet
Development

No branches or pull requests

3 participants