-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix inline compilation benchmarks and Improve searching Graph.Link pe…
…rformance (#9520) As benchmarks show, a significant amount of time is spent traversing `Set` of `Graph.Link`s. That's unfortunate and unnecessary. We can equally keep helper maps that make search constant time. Fixed inline compilation benchmarks by properly cleaning up scopes after runs. Closes #9237. # Important Notes Things like   are all gone. There is plenty of it those are just samples. Benchmarks are back in order: ``` [info] # Warmup Iteration 1: 2.702 ms/op [info] # Warmup Iteration 2: 3.080 ms/op [info] # Warmup Iteration 3: 2.818 ms/op [info] # Warmup Iteration 4: 3.334 ms/op [info] # Warmup Iteration 5: 2.448 ms/op [info] # Warmup Iteration 6: 2.583 ms/op [info] Iteration 1: 2.908 ms/op [info] Iteration 2: 2.915 ms/op [info] Iteration 3: 2.774 ms/op [info] Iteration 4: 2.601 ms/op [info] Result "org.enso.compiler.benchmarks.inline.InlineCompilerBenchmark.longExpression": [info] 2.799 ±(99.9%) 0.953 ms/op [Average] [info] (min, avg, max) = (2.601, 2.799, 2.915), stdev = 0.148 [info] CI (99.9%): [1.846, 3.753] (assumes normal distribution) ```
- Loading branch information
Showing
9 changed files
with
153 additions
and
58 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
23 changes: 23 additions & 0 deletions
23
...e-benchmarks/src/main/java/org/enso/compiler/benchmarks/inline/InlineContextResource.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,23 @@ | ||
package org.enso.compiler.benchmarks.inline; | ||
|
||
import java.io.IOException; | ||
import org.enso.compiler.context.InlineContext; | ||
|
||
/** | ||
* InlineContextResource ensures that the underlying InlineContext is properly cleaned up after | ||
* usage. | ||
* | ||
* @param inlineContext InlineContext for the main method | ||
*/ | ||
public record InlineContextResource(InlineContext inlineContext) implements AutoCloseable { | ||
@Override | ||
public void close() throws IOException { | ||
inlineContext | ||
.localScope() | ||
.foreach( | ||
s -> { | ||
s.scope().removeScopeFromParent(); | ||
return null; | ||
}); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...marks/src/main/java/org/enso/compiler/benchmarks/inline/InlineContextResourceFactory.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,28 @@ | ||
package org.enso.compiler.benchmarks.inline; | ||
|
||
import org.enso.compiler.PackageRepository; | ||
import org.enso.compiler.context.InlineContext; | ||
import org.enso.interpreter.node.MethodRootNode; | ||
import org.enso.interpreter.runtime.EnsoContext; | ||
import org.enso.interpreter.runtime.data.Type; | ||
import org.enso.interpreter.runtime.scope.ModuleScope; | ||
|
||
public record InlineContextResourceFactory( | ||
ModuleScope moduleScope, | ||
Type assocTypeReceiver, | ||
EnsoContext ensoCtx, | ||
PackageRepository pkgRepository) { | ||
|
||
public InlineContextResource create() { | ||
var mainFunc = moduleScope.getMethodForType(assocTypeReceiver, "main"); | ||
var mainFuncRootNode = (MethodRootNode) mainFunc.getCallTarget().getRootNode(); | ||
var mainLocalScope = mainFuncRootNode.getLocalScope(); | ||
return new InlineContextResource( | ||
InlineContext.fromJava( | ||
mainLocalScope.createChild(), | ||
moduleScope.getModule().asCompilerModule(), | ||
scala.Option.apply(false), | ||
ensoCtx.getCompilerConfig(), | ||
scala.Option.apply(pkgRepository))); | ||
} | ||
} |
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
5 changes: 2 additions & 3 deletions
5
...ne/runtime-benchmarks/src/main/java/org/enso/compiler/benchmarks/inline/InlineSource.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 |
---|---|---|
@@ -1,11 +1,10 @@ | ||
package org.enso.compiler.benchmarks.inline; | ||
|
||
import java.util.Set; | ||
import org.enso.compiler.context.InlineContext; | ||
|
||
record InlineSource( | ||
String source, | ||
// InlineContext for the main method | ||
InlineContext mainInlineContext, | ||
// InlineContextResource for the main method | ||
InlineContextResourceFactory inlineContextFactory, | ||
// Local variables in main method | ||
Set<String> localVarNames) {} |
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.