Skip to content

Commit

Permalink
parse modules in parallel (#1103)
Browse files Browse the repository at this point in the history
* create a flag to parse modules in parallel

* better solution for parallel mapping that only parses rules once
  • Loading branch information
Dwight Guth committed Feb 14, 2020
1 parent 4dd4a1c commit 30960d6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ public Definition resolveNonConfigBubbles(Definition defWithConfig, RuleGrammarG
Module ruleParserModule = gen.getRuleGrammar(defWithConfig.mainModule());
ParseCache cache = loadCache(ruleParserModule);
try (ParseInModule parser = RuleGrammarGenerator.getCombinedGrammar(cache.getModule(), isStrict, profileRules, files)) {
return DefinitionTransformer.from(m -> this.resolveNonConfigBubbles(m, parser.getScanner(), gen), "parsing rules").apply(defWithConfig);
Map<String, Module> parsed = defWithConfig.parMap(m -> this.resolveNonConfigBubbles(m, parser.getScanner(), gen));
return DefinitionTransformer.from(m -> Module(m.name(), m.imports(), parsed.get(m.name()).localSentences(), m.att()), "parsing rules").apply(defWithConfig);
}
}

Expand Down
4 changes: 4 additions & 0 deletions kore/src/main/scala/org/kframework/definition/outer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ case class Definition(
case Definition(`mainModule`, `entryModules`, _) => true
case _ => false
}

def parMap(f: Module => Module): java.util.Map[String, Module] = {
(entryModules | entryModules.flatMap(_.importedModules)).par.map(f).seq.map(m => m.name -> m).toMap.asJava
}
}

trait Sorting {
Expand Down

0 comments on commit 30960d6

Please sign in to comment.