You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@systemml.apache.org by mb...@apache.org on 2017/11/10 06:06:55 UTC

[4/4] systemml git commit: [SYSTEMML-2009] Performance multi-threaded JMLC scoring (contention)

[SYSTEMML-2009] Performance multi-threaded JMLC scoring (contention)

This patch makes a major performance improvement to multi-threaded JMLC
scoring and script execution. For scripts with many small intermediates,
concurrent JMLC prepared scripts were contended on sequence ID
generators for unique matrix IDs, which is unnecessary because these IDs
are only used in the bufferpool which is disabled through JMLC. On an
end-to-end application with above characteristics, this changed improved
performance from 487s to 94s (in a test environment w/ 24 vcores).
 

Project: http://git-wip-us.apache.org/repos/asf/systemml/repo
Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/6a11413b
Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/6a11413b
Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/6a11413b

Branch: refs/heads/master
Commit: 6a11413b13d88712745ba88a7f58f5544a1018e4
Parents: ffefd8e
Author: Matthias Boehm <mb...@gmail.com>
Authored: Thu Nov 9 21:46:06 2017 -0800
Committer: Matthias Boehm <mb...@gmail.com>
Committed: Thu Nov 9 22:08:03 2017 -0800

----------------------------------------------------------------------
 .../org/apache/sysml/api/jmlc/Connection.java   |  1 +
 .../org/apache/sysml/conf/CompilerConfig.java   |  2 ++
 .../controlprogram/caching/CacheableData.java   | 20 ++++++++------------
 .../instructions/cp/VariableCPInstruction.java  |  9 ++++++++-
 4 files changed, 19 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/systemml/blob/6a11413b/src/main/java/org/apache/sysml/api/jmlc/Connection.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/api/jmlc/Connection.java b/src/main/java/org/apache/sysml/api/jmlc/Connection.java
index 705d784..be75a95 100644
--- a/src/main/java/org/apache/sysml/api/jmlc/Connection.java
+++ b/src/main/java/org/apache/sysml/api/jmlc/Connection.java
@@ -112,6 +112,7 @@ public class Connection implements Closeable
 		CompilerConfig cconf = new CompilerConfig();
 		cconf.set(ConfigType.IGNORE_UNSPECIFIED_ARGS, true);
 		cconf.set(ConfigType.IGNORE_READ_WRITE_METADATA, true);
+		cconf.set(ConfigType.IGNORE_TEMPORARY_FILENAMES, true);
 		cconf.set(ConfigType.REJECT_READ_WRITE_UNKNOWNS, false);
 		cconf.set(ConfigType.PARALLEL_CP_READ_TEXTFORMATS, false);
 		cconf.set(ConfigType.PARALLEL_CP_WRITE_TEXTFORMATS, false);

http://git-wip-us.apache.org/repos/asf/systemml/blob/6a11413b/src/main/java/org/apache/sysml/conf/CompilerConfig.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/conf/CompilerConfig.java b/src/main/java/org/apache/sysml/conf/CompilerConfig.java
index bafe0ce..8c2c672 100644
--- a/src/main/java/org/apache/sysml/conf/CompilerConfig.java
+++ b/src/main/java/org/apache/sysml/conf/CompilerConfig.java
@@ -70,6 +70,7 @@ public class CompilerConfig
 		//Data expression configuration (modified by mlcontext, jmlc apis); no read of meta 
 		//data on mlcontext (local) /jmlc (global); ignore unknowns on jmlc
 		IGNORE_READ_WRITE_METADATA, // global skip meta data reads
+		IGNORE_TEMPORARY_FILENAMES, // global skip temporary filename modifications
 		REJECT_READ_WRITE_UNKNOWNS, // ignore missing meta data	
 		MLCONTEXT, // execution via new MLContext
 		
@@ -99,6 +100,7 @@ public class CompilerConfig
 		_bmap.put(ConfigType.ALLOW_CSE_PERSISTENT_READS, true);
 		_bmap.put(ConfigType.IGNORE_UNSPECIFIED_ARGS, false);
 		_bmap.put(ConfigType.IGNORE_READ_WRITE_METADATA, false);
+		_bmap.put(ConfigType.IGNORE_TEMPORARY_FILENAMES, false);
 		_bmap.put(ConfigType.REJECT_READ_WRITE_UNKNOWNS, true);
 		_bmap.put(ConfigType.MLCONTEXT, false);
 		_bmap.put(ConfigType.CODEGEN_ENABLED, false);

http://git-wip-us.apache.org/repos/asf/systemml/blob/6a11413b/src/main/java/org/apache/sysml/runtime/controlprogram/caching/CacheableData.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/controlprogram/caching/CacheableData.java b/src/main/java/org/apache/sysml/runtime/controlprogram/caching/CacheableData.java
index 885fedb..9e787de 100644
--- a/src/main/java/org/apache/sysml/runtime/controlprogram/caching/CacheableData.java
+++ b/src/main/java/org/apache/sysml/runtime/controlprogram/caching/CacheableData.java
@@ -110,7 +110,7 @@ public abstract class CacheableData<T extends CacheBlock> extends Data
     }
 	
 	/** Global flag indicating if caching is enabled (controls eviction) */
-	private static boolean _activeFlag = false;
+	private static volatile boolean _activeFlag = false;
 	
 	/** Global sequence for generating unique ids. */
 	private static IDSequence _seq = null;   
@@ -140,7 +140,7 @@ public abstract class CacheableData<T extends CacheBlock> extends Data
 	 * The unique (JVM-wide) ID of a cacheable data object; to ensure unique IDs across JVMs, we
 	 * concatenate filenames with a unique prefix (map task ID). 
 	 */
-	private final int _uniqueID;
+	private final long _uniqueID;
 	
 	/** The cache status of the data blob (whether it can be or is evicted, etc. */
 	private CacheStatus _cacheStatus = null;
@@ -205,7 +205,7 @@ public abstract class CacheableData<T extends CacheBlock> extends Data
 	 */
 	protected CacheableData(DataType dt, ValueType vt) {
 		super (dt, vt);
-		_uniqueID = (int)_seq.getNextID();
+		_uniqueID = isCachingActive() ? _seq.getNextID() : -1;
 		_cacheStatus = CacheStatus.EMPTY;
 		_numReadThreads = 0;
 		_gpuObjects = new HashMap<>();
@@ -1047,17 +1047,13 @@ public abstract class CacheableData<T extends CacheBlock> extends Data
 	
 	// ------------- IMPLEMENTED CACHE LOGIC METHODS --------------	
 	
-	protected int getUniqueCacheID() {
-		return _uniqueID;
-	}
-
 	protected String getCacheFilePathAndName () {
 		if( _cacheFileName==null ) {
 			StringBuilder sb = new StringBuilder();
 			sb.append(CacheableData.cacheEvictionLocalFilePath); 
 			sb.append(CacheableData.cacheEvictionLocalFilePrefix);
-			sb.append(String.format ("%09d", getUniqueCacheID()));
-			sb.append(CacheableData.CACHING_EVICTION_FILEEXTENSION);			
+			sb.append(String.format ("%09d", _uniqueID));
+			sb.append(CacheableData.CACHING_EVICTION_FILEEXTENSION);
 			_cacheFileName = sb.toString();
 		}
 		
@@ -1361,15 +1357,15 @@ public abstract class CacheableData<T extends CacheBlock> extends Data
 		_activeFlag = true; //turn on caching
 	}
 	
-	public static synchronized boolean isCachingActive() {
+	public static boolean isCachingActive() {
 		return _activeFlag;
 	}
 	
-	public static synchronized void disableCaching() {
+	public static void disableCaching() {
 		_activeFlag = false;
 	}
 	
-	public static synchronized void enableCaching() {
+	public static void enableCaching() {
 		_activeFlag = true;
 	}
 

http://git-wip-us.apache.org/repos/asf/systemml/blob/6a11413b/src/main/java/org/apache/sysml/runtime/instructions/cp/VariableCPInstruction.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/instructions/cp/VariableCPInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/cp/VariableCPInstruction.java
index 659924c..92750f7 100644
--- a/src/main/java/org/apache/sysml/runtime/instructions/cp/VariableCPInstruction.java
+++ b/src/main/java/org/apache/sysml/runtime/instructions/cp/VariableCPInstruction.java
@@ -28,6 +28,8 @@ import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.LocalFileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.sysml.api.DMLScript;
+import org.apache.sysml.conf.CompilerConfig.ConfigType;
+import org.apache.sysml.conf.ConfigurationManager;
 import org.apache.sysml.lops.Lop;
 import org.apache.sysml.lops.UnaryCP;
 import org.apache.sysml.parser.Expression.DataType;
@@ -1006,6 +1008,11 @@ public class VariableCPInstruction extends CPInstruction {
 	}
 	
 	private static String getBasicCreateVarString(String varName, String fileName, boolean fNameOverride, DataType dt, String format) {
+		//note: the filename override property leads to concatenation of unique ids in order to 
+		//ensure conflicting filenames for objects that originate from the same instruction
+		boolean lfNameOverride = fNameOverride && !ConfigurationManager
+			.getCompilerConfigFlag(ConfigType.IGNORE_TEMPORARY_FILENAMES);
+		
 		StringBuilder sb = new StringBuilder();
 		sb.append("CP");
 		sb.append(Lop.OPERAND_DELIMITOR);
@@ -1016,7 +1023,7 @@ public class VariableCPInstruction extends CPInstruction {
 		sb.append(fileName);		// Constant CREATEVAR_FILE_NAME_VAR_POS is used to find a position of filename within a string generated through this function.
 									// If this position of filename within this string changes then constant CREATEVAR_FILE_NAME_VAR_POS to be updated.
 		sb.append(Lop.OPERAND_DELIMITOR);
-		sb.append(fNameOverride);
+		sb.append(lfNameOverride);
 		sb.append(Lop.OPERAND_DELIMITOR);
 		sb.append(dt.toString());
 		sb.append(Lop.OPERAND_DELIMITOR);