-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Access to File.readAsBytes result is slower than expected #29892
Comments
Observatory shows that about 45% of time is being spent within Native ( |
It's likely that we'll need the full example in order to diagnose this. |
Here's the smallest example, that I could isolate. Run each version with Slow import 'dart:io';
import 'dart:typed_data';
const kSize = 10 * 1024 * 1024;
void main() {
new File('tmp.bin').writeAsBytesSync(new Uint8List(kSize));
final foos = <Uint8List>[
new File('tmp.bin').readAsBytesSync() as Uint8List,
new Uint8List(kSize)
];
for (var foo in foos) {
for (var e in new Uint8List.view(foo.buffer)) {}
}
} Fast import 'dart:io';
import 'dart:typed_data';
const kSize = 10 * 1024 * 1024;
void main() {
new File('tmp.bin').writeAsBytesSync(new Uint8List(kSize));
final foos = <Uint8List>[
new Uint8List.fromList(new File('tmp.bin').readAsBytesSync()),
new Uint8List(kSize)
];
for (var foo in foos) {
for (var e in new Uint8List.view(foo.buffer)) {}
}
} When both elements of EDIT: shorten example code. |
Example code above has the same unusual Native CPU time share as a real application.
|
@floitschG @zanderso |
/cc @mraleph (in case you are interested or have an idea of what's going on). |
Taking a look |
This is a regression originally introduced by ae8e670 at least for the microbenchmark case In However in the polymorphic inliner we only reach recognized method inlining if we have a single cid call target: bool PolymorphicInliner::TryInliningPoly(const TargetInfo& target_info) {
if ((!FLAG_precompiled_mode ||
owner_->inliner_->use_speculative_inlining()) &&
target_info.IsSingleCid() &&
TryInlineRecognizedMethod(target_info.cid_start, *target_info.target)) {
owner_->inlined_ = true;
return true;
}
// ... Which means that after ae8e670 we no longer inline @ErikCorryGoogle - please take a look. |
When I disable cid range expansion here is what I get (with
|
Thanks for tracking this down! I have a suggested fix here: https://codereview.chromium.org/2956653002 |
@lexaknyazev how much you can share about your full code in which you are using Dart? I am really interested in assessing if our approach to implementing typed array views scales well for real world use cases. |
@mraleph Source tree (will replace master branch soon): Dataset: Cmd-line (
|
When dispatching polymorphic calls we try to recognize the case where adjacent classes have the same method, so that we can group the classes in the dispatch. That fails for polymorphic methods, which are pretending to be the same method, but actually do a class test on the receiver internally. In this case, we should not expand the classes, because it messes up some other inlining optimizations. R=vegorov@google.com BUG=#29892 Review-Url: https://codereview.chromium.org/2956653002 .
This issue has been fixed. |
Can't provide a small repro atm, but here is my observation:
Data access in this code
is about 2 times slower than here:
Same applies to async version of
File.readAsBytes
.The text was updated successfully, but these errors were encountered: