This is an automated email from the ASF dual-hosted git repository.

mboehm7 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/systemds.git


The following commit(s) were added to refs/heads/main by this push:
     new 692dcc3d1c [SYSTEMDS-3890] Fix opcode lookup performance regression
692dcc3d1c is described below

commit 692dcc3d1c46c79b281bfc85686d750d62f427ad
Author: Matthias Boehm <[email protected]>
AuthorDate: Fri Jun 27 12:32:26 2025 +0200

    [SYSTEMDS-3890] Fix opcode lookup performance regression
    
    With the refactoring of all 100s of opcodes, a stale merge introduced
    a performance regression of the inner opcode lookup, where instead of
    using the lookup table, we made a scan of all opcodes. With the fix the
    runtime for looking up all ~350 opcodes reduced from 0.358ms to 0.004ms.
---
 src/main/java/org/apache/sysds/common/Opcodes.java | 28 ++++++++++------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/src/main/java/org/apache/sysds/common/Opcodes.java 
b/src/main/java/org/apache/sysds/common/Opcodes.java
index 28c5a7a6a8..71f3e3f752 100644
--- a/src/main/java/org/apache/sysds/common/Opcodes.java
+++ b/src/main/java/org/apache/sysds/common/Opcodes.java
@@ -20,11 +20,9 @@
 package org.apache.sysds.common;
 
 import org.apache.sysds.lops.*;
-
 import org.apache.sysds.common.Types.OpOp1;
 import org.apache.sysds.hops.FunctionOp;
 
-import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -390,8 +388,8 @@ public enum Opcodes {
 
        BINUAGGCHAIN("binuaggchain", InstructionType.BinUaggChain),
 
-       CASTDTM("castdtm", InstructionType.Cast),
-       CASTDTF("castdtf", InstructionType.Cast),
+       CASTDTM("castdtm", InstructionType.Variable, InstructionType.Cast),
+       CASTDTF("castdtf", InstructionType.Variable, InstructionType.Cast),
 
        //FED Opcodes
        FEDINIT("fedinit", InstructionType.Init);
@@ -427,7 +425,7 @@ public enum Opcodes {
        private static final Map<String, Opcodes> _lookupMap = new HashMap<>();
 
        static {
-               for (Opcodes op : EnumSet.allOf(Opcodes.class)) {
+               for (Opcodes op : Opcodes.values()) {
                        if (op._name != null) {
                                _lookupMap.put(op._name.toLowerCase(), op);
                        }
@@ -456,19 +454,17 @@ public enum Opcodes {
                if (opcode == null || opcode.trim().isEmpty()) {
                        return null;
                }
-               for (Opcodes op : Opcodes.values()) {
-                       if (op.toString().equalsIgnoreCase(opcode.trim())) {
-                               switch (type) {
-                                       case SPARK:
-                                               return (op.getSpType() != null) 
? op.getSpType() : op.getType();
-                                       case FED:
-                                               return (op.getFedType() != 
null) ? op.getFedType() : op.getType();
-                                       default:
-                                               return op.getType();
-                               }
+               Opcodes op = _lookupMap.get(opcode.trim().toLowerCase());
+               if( op != null ) {
+                       switch (type) {
+                               case SPARK:
+                                       return (op.getSpType() != null) ? 
op.getSpType() : op.getType();
+                               case FED:
+                                       return (op.getFedType() != null) ? 
op.getFedType() : op.getType();
+                               default:
+                                       return op.getType();
                        }
                }
                return null;
        }
 }
-

Reply via email to