-
Notifications
You must be signed in to change notification settings - Fork 323
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
3x slower IfVsCaseBenchmarks_ifBench6In #9165
Comments
After bisecting, I discovered that the regression was introduced by #8779 |
Thank you for the investigation. I am eager to hear more details! Sorry for regressing (again). |
@JaroslavTulach I believe the regression is caused by the newly introduced typechecks in Number binary operations, for example, in Let's have the following program:
And run it with:
And the inspect the generated Truffle ASTs in IGV. In the bad revision (the new one that introduced the regression), we can see a compilation for In the good revision (the old one without regression), there is no compilation for The reason why |
I believe the regression is simply caused by adding type checks (by introducing inline type ascriptions). Runtime type checking is not for free. The question remains, what kind of slowdown are we willing to tolerate? The next step that I will do will be to create a benchmark that will compare the performance of type checks, i.e., a method without type checks VS a method with type checks. I think we do not have any benchmark like that. Once I am done with that benchmark, I will report my further findings here. |
Pavel Marek reports a new STANDUP for today (2024-03-05): Progress: - Bisected and investigated the regression and figured out the root cause - #9165 (comment)
|
There are various sieve benchmarks including one without type ascriptions and another with ascribed type checks and yet another one with ascribed return types. Yes, ascribed versions are slightly ~10% slower. There is another set of benchmarks in ListBenchmarks that compares ascribed and non-ascribed behavior. |
Thanks for the instructions. I see that the diff --git engine/runtime/src/main/java/org/enso/interpreter/node/callable/argument/ReadArgumentCheckNode.java engine/runtime/src/main/java/org/enso/interpreter/node/callable/argument/ReadArgumentCheckNode.java
index f78a439b20..0d0d0c69a9 100644
--- engine/runtime/src/main/java/org/enso/interpreter/node/callable/argument/ReadArgumentCheckNode.java
+++ engine/runtime/src/main/java/org/enso/interpreter/node/callable/argument/ReadArgumentCheckNode.java
@@ -15,6 +15,7 @@ import com.oracle.truffle.api.nodes.InvalidAssumptionException;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeUtil;
import com.oracle.truffle.api.nodes.RootNode;
+import com.oracle.truffle.api.profiles.BranchProfile;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@@ -252,6 +253,7 @@ public abstract class ReadArgumentCheckNode extends Node {
@Child IsValueOfTypeNode checkType;
@CompilerDirectives.CompilationFinal private String expectedTypeMessage;
@CompilerDirectives.CompilationFinal private LazyCheckRootNode lazyCheck;
+ private final BranchProfile multiValueProfile = BranchProfile.create();
TypeCheckNode(String name, Type expectedType) {
super(name);
@@ -319,6 +321,7 @@ public abstract class ReadArgumentCheckNode extends Node {
return lazyCheckFn;
}
if (v instanceof EnsoMultiValue mv) {
+ multiValueProfile.enter();
var result = mv.castTo(expectedType);
if (result != null) {
return result; we can cut the multi value support off as |
Pavel Marek reports a new STANDUP for today (2024-03-06): Progress: - Looking into more recent performance regressions.
|
After a few hours of more in-depth investigation, I am giving up for now with the conclusion that the regression is most-likely caused by just having more Truffle and Graal nodes in the compilation. The initial suspicion of @JaroslavTulach that the bad revision does not inline I have mostly followed this guide and made some notes along the way (Generated outputs and snapshots are in
|
Thank you for your investigation and different point of view. I'll take the issue back - at the end it is clearly my regression, so I should be responsible for fixing it. |
Pavel Marek reports a new STANDUP for today (2024-03-07): Progress: - Giving up further investigation for now, my conclusion is that there are just too many Graal and Truffle nodes in the compilation. It should be finished by 2024-03-08. |
Since January 26, 2024 the
IfVsCaseBenchmarks_ifBench6In
slowed down three times:First slowdown has happened during fourteen days when the measurements were off. Then there was another drop in performance on February 19, 2024.
The text was updated successfully, but these errors were encountered: