forked from apache/systemds
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYSTEMML-1879] Performance parfor remote spark (reuse shared inputs)
In parfor remote spark jobs, each worker is initialized with its own deserialized symbol table, which causes redundant reads of shared inputs in each parfor worker and is unnecessarily memory-inefficient. This patch introduces a principled approach to reusing shared inputs, where we reuse all variables except for result variables and partitioned matrices. By simply using common instances of matrix objects, the sharing happens automatically through the bufferpool similar to local parfor execution and without additional pinned memory requirements. On the perftest scenario MSVM 1M x 1K, sparse with 150 classes and 25 iterations, the end-to-end runtime (including read and spark context creation) improved from 94s to 72s.
- Loading branch information
Showing
9 changed files
with
356 additions
and
337 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
464 changes: 201 additions & 263 deletions
464
src/main/java/org/apache/sysml/runtime/controlprogram/ParForProgramBlock.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/main/java/org/apache/sysml/runtime/controlprogram/parfor/CachedReuseVariables.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.sysml.runtime.controlprogram.parfor; | ||
|
||
import java.lang.ref.SoftReference; | ||
import java.util.Collection; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
|
||
import org.apache.sysml.runtime.controlprogram.LocalVariableMap; | ||
|
||
public class CachedReuseVariables | ||
{ | ||
private final HashMap<Long, SoftReference<LocalVariableMap>> _data; | ||
|
||
public CachedReuseVariables() { | ||
_data = new HashMap<>(); | ||
} | ||
|
||
public synchronized void reuseVariables(long pfid, LocalVariableMap vars, Collection<String> blacklist) { | ||
//check for existing reuse map | ||
LocalVariableMap tmp = null; | ||
if( _data.containsKey(pfid) ) | ||
tmp = _data.get(pfid).get(); | ||
|
||
//build reuse map if not created yet or evicted | ||
if( tmp == null ) { | ||
tmp = new LocalVariableMap(vars); | ||
tmp.removeAllIn(new HashSet<>(blacklist)); | ||
_data.put(pfid, new SoftReference<>(tmp)); | ||
} | ||
//reuse existing reuse map | ||
else { | ||
for( String varName : tmp.keySet() ) | ||
vars.put(varName, tmp.get(varName)); | ||
} | ||
} | ||
|
||
public synchronized void clearVariables(long pfid) { | ||
_data.remove(pfid); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.