-
Notifications
You must be signed in to change notification settings - Fork 185
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
Adopt Prism/YARP as the parser in TruffleRuby #3117
Comments
Some early numbers, on 3 runs of each.
With Prism:
Parsing seems almost twice as fast! (~1900ms vs ~1000ms) |
On commit 90bfaa0 Parsing the core library is about 3-4 times faster with Prism (because there is no need to warmup the parser) and it saves about 200ms startup on JVM!
This no-warmup advantage is very clear when looking at the first files being parsed, 10x faster for the first file and 4x (16x for jvm-ce) faster for the 3rd file (the second file is very small):
|
Here are some measurements for parsing and translating for 1 iteration of yjit-bench railsbench.
Translating seems slower than before, so likely something we can optimize further with a Java profiler. I used this patch to get aggregated parsing+translate timings for all files: diff --git a/src/main/java/org/truffleruby/parser/TranslatorDriver.java b/src/main/java/org/truffleruby/parser/TranslatorDriver.java
index 6f5f20fa73..ebd0423f4f 100644
--- a/src/main/java/org/truffleruby/parser/TranslatorDriver.java
+++ b/src/main/java/org/truffleruby/parser/TranslatorDriver.java
@@ -479,10 +479,12 @@ public final class TranslatorDriver {
name = name.substring(lastSlash + 1, lastDot);
}
Metrics.printTime(id + "-" + name);
- } else if (context.getCoreLibrary().isLoadingRubyCore()) {
- // Only show times for core (the biggest contributor) to avoid multiple metrics with
- // the same name, which is not supported in mx_truffleruby_benchmark.py.
- Metrics.printTime(id + "-core");
+ } else {
+ Metrics.printTime(id);
+// } else if (context.getCoreLibrary().isLoadingRubyCore()) {
+// // Only show times for core (the biggest contributor) to avoid multiple metrics with
+// // the same name, which is not supported in mx_truffleruby_benchmark.py.
+// Metrics.printTime(id + "-core");
}
}
}
diff --git a/src/main/java/org/truffleruby/parser/YARPTranslatorDriver.java b/src/main/java/org/truffleruby/parser/YARPTranslatorDriver.java
index ed1d692756..2977ce2740 100644
--- a/src/main/java/org/truffleruby/parser/YARPTranslatorDriver.java
+++ b/src/main/java/org/truffleruby/parser/YARPTranslatorDriver.java
@@ -612,10 +612,12 @@ public final class YARPTranslatorDriver {
name = name.substring(lastSlash + 1, lastDot);
}
Metrics.printTime(id + "-" + name);
- } else if (context.getCoreLibrary().isLoadingRubyCore()) {
- // Only show times for core (the biggest contributor) to avoid multiple metrics with
- // the same name, which is not supported in mx_truffleruby_benchmark.py.
- Metrics.printTime(id + "-core");
+ } else {
+ Metrics.printTime(id);
+// } else if (context.getCoreLibrary().isLoadingRubyCore()) {
+// // Only show times for core (the biggest contributor) to avoid multiple metrics with
+// // the same name, which is not supported in mx_truffleruby_benchmark.py.
+// Metrics.printTime(id + "-core");
}
}
} |
This will solve a far amount of syntax incompatibilities such as #3038, and provide us with a parser we can very easily re-import.
And it means new syntax would always be supported in YARP early, which will be very helpful when updating to a new Ruby version.
Currently we are using a fork of the parser in JRuby, but this is very difficult to update (notably due to using different types in the fork), so migrating to YARP will address this maintenance problem.
It should also help by replacing the Ripper C extension which is slow and unreliable with the YARP Ripper backend: #2767
The text was updated successfully, but these errors were encountered: