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

Benchmark EnsoMultiValue and speed it up #11846

Open
JaroslavTulach opened this issue Dec 12, 2024 · 1 comment · May be fixed by #11924
Open

Benchmark EnsoMultiValue and speed it up #11846

JaroslavTulach opened this issue Dec 12, 2024 · 1 comment · May be fixed by #11924
Assignees
Labels
-compiler p-medium Should be completed in the next few sprints

Comments

@JaroslavTulach
Copy link
Member

EnsoMultiValue with visible and hidden types as introduced by:

hasn't been optimized for speed and is known to perform certain operations magnitude slower than regular enso values.

  • write benchmarks
  • speed the operations up
@JaroslavTulach JaroslavTulach added p-medium Should be completed in the next few sprints -compiler labels Dec 12, 2024
@JaroslavTulach JaroslavTulach self-assigned this Dec 12, 2024
@JaroslavTulach JaroslavTulach moved this from ❓New to ⚙️ Design in Issues Board Dec 19, 2024
@JaroslavTulach
Copy link
Member Author

JaroslavTulach commented Dec 19, 2024

Here is a the basic benchmark:

diff --git engine/runtime-benchmarks/src/main/java/org/enso/interpreter/bench/benchmarks/semantic/ArrayProxyBenchmarks.java engine/runtime-benchmarks/src/main/java/org/enso/interpreter/bench/benchmarks/semantic/ArrayProxyBenchmarks.java
index 1327a37cee..19acb8eac0 100644
--- engine/runtime-benchmarks/src/main/java/org/enso/interpreter/bench/benchmarks/semantic/ArrayProxyBenchmarks.java
+++ engine/runtime-benchmarks/src/main/java/org/enso/interpreter/bench/benchmarks/semantic/ArrayProxyBenchmarks.java
@@ -42,13 +42,30 @@ public class ArrayProxyBenchmarks {
         """
         import Standard.Base.Data.Vector.Vector
         import Standard.Base.Data.Array_Proxy.Array_Proxy
+        from Standard.Base import Integer
+
         sum arr =
             go acc i = if i >= arr.length then acc else
-                @Tail_Call go (acc + arr.at i) i+1
+                v = arr.at i
+                sum = acc + v
+                @Tail_Call go sum i+1
             go 0 0
 
+        type Rational
+                Number quotient:Integer fraction:Integer
+
+        Rational.from (that:Integer) = Rational.Number that 1
+
         make_vector n =
-            Vector.new n (i -> 3 + 5*i)
+            Vector.new n i->
+                r = 3 + 5*i
+                r:Integer
+
+        make_int_rational_vector n =
+            Vector.new n i->
+                r = 3 + 5*i
+                r:Integer&Rational
+
         make_computing_proxy n =
             Array_Proxy.new n (i -> 3 + 5*i)
         make_delegating_proxy n =
@@ -70,6 +87,9 @@ public class ArrayProxyBenchmarks {
       case "sumOverVector":
         test_builder = "make_vector";
         break;
+      case "sumOverMultiIntegerRationalVector":
+        test_builder = "make_int_rational_vector";
+        break;
       case "sumOverComputingProxy":
         test_builder = "make_computing_proxy";
         break;
@@ -94,6 +114,11 @@ public class ArrayProxyBenchmarks {
     performBenchmark(matter);
   }
 
+  @Benchmark
+  public void sumOverMultiIntegerRationalVector(Blackhole matter) {
+    performBenchmark(matter);
+  }
+
   @Benchmark
   public void sumOverComputingProxy(Blackhole matter) {
     performBenchmark(matter);

It piggy backs on Array_Proxy benchmarks, but it shows the difference:

  • benchOnly ArrayProxyBenchmarks.sumOverVector takes 0.062 ms/op
  • benchOnly ArrayProxyBenchmarks.sumOverMultiIntegerRationalVector takes 4.814 ms/op

e.g. the r:Integer&Rational is 80x slower. It shouldn't be that slow! We don't need the same speed, but this kind of slowdown is too much.

Real benchmark in the PR is just inspired by this diff.

@JaroslavTulach JaroslavTulach linked a pull request Dec 19, 2024 that will close this issue
3 tasks
@JaroslavTulach JaroslavTulach linked a pull request Dec 20, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-compiler p-medium Should be completed in the next few sprints
Projects
Status: ⚙️ Design
Development

Successfully merging a pull request may close this issue.

1 participant