Skip to content

Commit d85363e

Browse files
committed
Minor bugfix to prevent issues with multithreading
1 parent 0cf96b4 commit d85363e

1 file changed

Lines changed: 6 additions & 24 deletions

File tree

src/main/java/org/apache/sysds/utils/Statistics.java

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@ public static void reset()
335335
FederatedStatistics.reset();
336336

337337
_instStatsNGram.clear();
338+
_instStatsLineageTracker.clear();
339+
_instStats.clear();
338340
}
339341

340342
public static void resetJITCompileTime(){
@@ -449,21 +451,21 @@ public static Optional<Entry<String, LineageItem>> getCurrentLineageItem() {
449451
return item == null ? Optional.empty() : Optional.of(item);
450452
}
451453

452-
public static void clearNGramRecording() {
454+
public static synchronized void clearNGramRecording() {
453455
NGramBuilder<String, NGramStats>[] bl = _instStatsNGram.get(Thread.currentThread().getName());
454456
for (NGramBuilder<String, NGramStats> b : bl)
455457
b.clearCurrentRecording();
456458
}
457459

458-
public static void extendLineageItem(LineageItem li, LineageNGramExtension ext) {
460+
public static synchronized void extendLineageItem(LineageItem li, LineageNGramExtension ext) {
459461
_lineageExtensions.put(li, ext);
460462
}
461463

462-
public static LineageNGramExtension getExtendedLineage(LineageItem li) {
464+
public static synchronized LineageNGramExtension getExtendedLineage(LineageItem li) {
463465
return _lineageExtensions.get(li);
464466
}
465467

466-
public static void maintainNGramsFromLineage(LineageItem li) {
468+
public static synchronized void maintainNGramsFromLineage(LineageItem li) {
467469
NGramBuilder<String, NGramStats>[] tmp = _instStatsNGram.computeIfAbsent(Thread.currentThread().getName(), k -> {
468470
NGramBuilder<String, NGramStats>[] threadEntry = new NGramBuilder[DMLScript.STATISTICS_NGRAM_SIZES.length];
469471
for (int i = 0; i < threadEntry.length; i++) {
@@ -474,26 +476,6 @@ public static void maintainNGramsFromLineage(LineageItem li) {
474476
addLineagePaths(li, new ArrayList<>(), new ArrayList<>(), tmp);
475477
}
476478

477-
/**
478-
* Count the number of paths from the current lineage item with a minimum size
479-
* @param li the root item
480-
* @param size the minimum size of the path
481-
* @return
482-
*/
483-
private static int countLineageLinesOfSize(LineageItem li, int size) {
484-
if (li.getInputs() == null)
485-
return 0;
486-
487-
if (size == 1)
488-
return li.getInputs().length;
489-
490-
int lines = 0;
491-
for (LineageItem in : li.getInputs())
492-
lines += countLineageLinesOfSize(in, size-1);
493-
494-
return lines;
495-
}
496-
497479
/**
498480
* Adds the corresponding sequences of instructions to the n-grams.
499481
* <p></p>

0 commit comments

Comments
 (0)