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

Very slow execution on RISC-V except for AOT #49253

Closed
maks opened this issue Jun 14, 2022 · 7 comments
Closed

Very slow execution on RISC-V except for AOT #49253

maks opened this issue Jun 14, 2022 · 7 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.

Comments

@maks
Copy link

maks commented Jun 14, 2022

Using:

dart-sdk/bin/dart --version
Dart SDK version: 2.18.0-165.1.beta (beta) (Mon Jun 13 15:34:45 2022 +0200) on "linux_riscv64"

on a Sipeed Lichee RV I see very slow startup and execution times.

I'm running a custom built debian (prebuilt from here):

uname -a
Linux licheerv 5.17.0-rc2-379425-g06b026a8b714 #1 PREEMPT Sat Mar 5 16:51:08 CET 2022 riscv64 GNU/Linux

I have disabled swap, so I'm sure it not swapping that is causing this.

Running a simple print ("helloworld") or even dart --help takes a long time:

time dart-sdk/bin/dart test.dart 
hello world

real	0m35.885s
user	0m30.863s
sys	0m2.835s

and

time dart-sdk/bin/dart --help    
A command-line utility for Dart development.

Usage: dart <command|dart-file> [arguments]

Global options:
-h, --help                 Print this usage information.
...
real	0m19.514s
user	0m11.457s
sys	0m1.820s

Compiling was much worse:

time dart-sdk/bin/dart compile exe test.dart
Info: Compiling with sound null safety
Generated: /home/rv/test.exe

real	2m57.245s
user	2m33.873s
sys	0m14.425s

Though the compiled binary is fine:

time test.exe   
-bash: test.exe: command not found

real	0m0.015s
user	0m0.000s
sys	0m0.012s

And other things seem to take a reasonable amount of time too, eg. compiling a hello world in C:

time gcc test.c -o test

real	0m0.623s
user	0m0.320s
sys	0m0.288s
@vsmenon vsmenon added the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label Jun 14, 2022
@vsmenon
Copy link
Member

vsmenon commented Jun 14, 2022

@rmacnak-google - fyi

@rmacnak-google
Copy link
Contributor

Can you split running from source into these two steps and report which is slow?

$ time dart-sdk/bin/dart --snapshot=test.dart.dill test.dart
$ time dart-sdk/bin/dart test.dart.dill

@maks
Copy link
Author

maks commented Jun 14, 2022

Yes of course, sorry about that @rmacnak-google , I should of thought to do that. Here are the results:

rv@licheerv:~$ time dart-sdk/bin/dart --snapshot=test.dart.dill test.dart
Info: Compiling with sound null safety

real	0m36.367s
user	0m31.154s
sys	0m2.931s
rv@licheerv:~$ time dart-sdk/bin/dart test.dart.dill
hello world

real	0m4.884s
user	0m2.453s
sys	0m0.460s

I only ran the above 3 times, but the times for each run are all with a ~5% of each other.

And for completeness my test.dart is:

void main() {
  print("hello world");
}

@maks
Copy link
Author

maks commented Jun 14, 2022

I'm happy to run other tests to try to debug this further if that would help. I know this is very new hardware and its only beta channel but I thought it might be helpful to report real world usage.

The dev board itself is very nice and tiny form factor, yet seems to have reasonable amount of CPU perf and RAM for its power usage, and with the only slightly larger carrierboard you get full size HDMl & USB-A so I can see even these early boards being very popular for a whole range of embedded/kiosk/infotainment applications and it would be great to be able to use Dart (and eventually) Flutter on them.

@maks maks changed the title Very slow execution on RISCV except for AOT Very slow execution on RISC-V except for AOT Jul 4, 2022
@rmacnak-google
Copy link
Contributor

time test.exe   
-bash: test.exe: command not found

real	0m0.015s
user	0m0.000s
sys	0m0.012s

The AOT time contains an error, so it does not reflect AOT performance. Can you re-run this with the correct path?

@maks
Copy link
Author

maks commented Jul 24, 2022

Sorry about that and for the delay in replying @rmacnak-google
Re-running it with the path correctly set I get:

time ./test.exe
hello world

real	0m1.088s
user	0m0.032s
sys	0m0.048s

Please do let me know if there is anything else I can do to help or if there are any specific newer SDK builds you would like me to test,

@rmacnak-google
Copy link
Contributor

We got a DevTerm Kit R-01, which also has a Allwinner D1, and can reproduce similar performance measurements.

What's going on is that since Dart 2 the cost of the frontend / running from source and the up-front cost of the core libraries is significantly higher than in Dart 1 (compare #34172). Since the D1 is a rather slow CPU, this cost is much more noticeable than on a desktop. There's no RISC-V specific issue here, and the VM implements nearly all the same optimizations for RISC-V as it does for x86 or ARM (except for SIMD).

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.
Projects
None yet
Development

No branches or pull requests

3 participants